Remove redundant type arguments.
This commit is contained in:
parent
f4a63c4c72
commit
eef8f1a0aa
|
@ -40,14 +40,14 @@ public class BagUtils {
|
|||
* An empty unmodifiable bag.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes") // OK, empty bag is compatible with any type
|
||||
public static final Bag EMPTY_BAG = UnmodifiableBag.unmodifiableBag(new HashBag<Object>());
|
||||
public static final Bag EMPTY_BAG = UnmodifiableBag.unmodifiableBag(new HashBag<>());
|
||||
|
||||
/**
|
||||
* An empty unmodifiable sorted bag.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes") // OK, empty bag is compatible with any type
|
||||
public static final Bag EMPTY_SORTED_BAG =
|
||||
UnmodifiableSortedBag.unmodifiableSortedBag(new TreeBag<Object>());
|
||||
UnmodifiableSortedBag.unmodifiableSortedBag(new TreeBag<>());
|
||||
|
||||
/**
|
||||
* Instantiation of BagUtils is not intended or required.
|
||||
|
|
|
@ -140,11 +140,11 @@ public class CollectionUtils {
|
|||
*/
|
||||
public SetOperationCardinalityHelper(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
||||
super(a, b);
|
||||
elements = new HashSet<O>();
|
||||
elements = new HashSet<>();
|
||||
addAll(elements, a);
|
||||
addAll(elements, b);
|
||||
// the resulting list must contain at least each unique element, but may grow
|
||||
newList = new ArrayList<O>(elements.size());
|
||||
newList = new ArrayList<>(elements.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -228,7 +228,7 @@ public class CollectionUtils {
|
|||
* @see Collection#addAll
|
||||
*/
|
||||
public static <O> Collection<O> union(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
||||
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<O>(a, b);
|
||||
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<>(a, b);
|
||||
for (final O obj : helper) {
|
||||
helper.setCardinality(obj, helper.max(obj));
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ public class CollectionUtils {
|
|||
* @see #containsAny
|
||||
*/
|
||||
public static <O> Collection<O> intersection(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
||||
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<O>(a, b);
|
||||
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<>(a, b);
|
||||
for (final O obj : helper) {
|
||||
helper.setCardinality(obj, helper.min(obj));
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ public class CollectionUtils {
|
|||
* @return the symmetric difference of the two collections
|
||||
*/
|
||||
public static <O> Collection<O> disjunction(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
||||
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<O>(a, b);
|
||||
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<>(a, b);
|
||||
for (final O obj : helper) {
|
||||
helper.setCardinality(obj, helper.max(obj) - helper.min(obj));
|
||||
}
|
||||
|
@ -329,8 +329,8 @@ public class CollectionUtils {
|
|||
public static <O> Collection<O> subtract(final Iterable<? extends O> a,
|
||||
final Iterable<? extends O> b,
|
||||
final Predicate<O> p) {
|
||||
final ArrayList<O> list = new ArrayList<O>();
|
||||
final HashBag<O> bag = new HashBag<O>();
|
||||
final ArrayList<O> list = new ArrayList<>();
|
||||
final HashBag<O> bag = new HashBag<>();
|
||||
for (final O element : b) {
|
||||
if (p.evaluate(element)) {
|
||||
bag.add(element);
|
||||
|
@ -371,7 +371,7 @@ public class CollectionUtils {
|
|||
return true;
|
||||
} else {
|
||||
final Iterator<?> it = coll1.iterator();
|
||||
final Set<Object> elementsAlreadySeen = new HashSet<Object>();
|
||||
final Set<Object> elementsAlreadySeen = new HashSet<>();
|
||||
for (final Object nextElement : coll2) {
|
||||
if (elementsAlreadySeen.contains(nextElement)) {
|
||||
continue;
|
||||
|
@ -437,7 +437,7 @@ public class CollectionUtils {
|
|||
* @return the populated cardinality map
|
||||
*/
|
||||
public static <O> Map<O, Integer> getCardinalityMap(final Iterable<? extends O> coll) {
|
||||
final Map<O, Integer> count = new HashMap<O, Integer>();
|
||||
final Map<O, Integer> count = new HashMap<>();
|
||||
for (final O obj : coll) {
|
||||
final Integer c = count.get(obj);
|
||||
if (c == null) {
|
||||
|
@ -462,7 +462,7 @@ public class CollectionUtils {
|
|||
* @see Collection#containsAll
|
||||
*/
|
||||
public static boolean isSubCollection(final Collection<?> a, final Collection<?> b) {
|
||||
final CardinalityHelper<Object> helper = new CardinalityHelper<Object>(a, b);
|
||||
final CardinalityHelper<Object> helper = new CardinalityHelper<>(a, b);
|
||||
for (final Object obj : a) {
|
||||
if (helper.freqA(obj) > helper.freqB(obj)) {
|
||||
return false;
|
||||
|
@ -512,7 +512,7 @@ public class CollectionUtils {
|
|||
if(a.size() != b.size()) {
|
||||
return false;
|
||||
}
|
||||
final CardinalityHelper<Object> helper = new CardinalityHelper<Object>(a, b);
|
||||
final CardinalityHelper<Object> helper = new CardinalityHelper<>(a, b);
|
||||
if(helper.cardinalityA.size() != helper.cardinalityB.size()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1582,11 +1582,11 @@ public class CollectionUtils {
|
|||
final int totalSize = a instanceof Collection<?> && b instanceof Collection<?> ?
|
||||
Math.max(1, ((Collection<?>) a).size() + ((Collection<?>) b).size()) : 10;
|
||||
|
||||
final Iterator<O> iterator = new CollatingIterator<O>(c, a.iterator(), b.iterator());
|
||||
final Iterator<O> iterator = new CollatingIterator<>(c, a.iterator(), b.iterator());
|
||||
if (includeDuplicates) {
|
||||
return IteratorUtils.toList(iterator, totalSize);
|
||||
} else {
|
||||
final ArrayList<O> mergedList = new ArrayList<O>(totalSize);
|
||||
final ArrayList<O> mergedList = new ArrayList<>(totalSize);
|
||||
|
||||
O lastItem = null;
|
||||
while (iterator.hasNext()) {
|
||||
|
@ -1623,8 +1623,8 @@ public class CollectionUtils {
|
|||
* @since 4.0
|
||||
*/
|
||||
public static <E> Collection<List<E>> permutations(final Collection<E> collection) {
|
||||
final PermutationIterator<E> it = new PermutationIterator<E>(collection);
|
||||
final Collection<List<E>> result = new ArrayList<List<E>>();
|
||||
final PermutationIterator<E> it = new PermutationIterator<>(collection);
|
||||
final Collection<List<E>> result = new ArrayList<>();
|
||||
while (it.hasNext()) {
|
||||
result.add(it.next());
|
||||
}
|
||||
|
@ -1690,16 +1690,16 @@ public class CollectionUtils {
|
|||
final Transformer<E, EquatorWrapper<E>> transformer = new Transformer<E, EquatorWrapper<E>>() {
|
||||
@Override
|
||||
public EquatorWrapper<E> transform(E input) {
|
||||
return new EquatorWrapper<E>(equator, input);
|
||||
return new EquatorWrapper<>(equator, input);
|
||||
}
|
||||
};
|
||||
|
||||
final Set<EquatorWrapper<E>> retainSet =
|
||||
collect(retain, transformer, new HashSet<EquatorWrapper<E>>());
|
||||
|
||||
final List<E> list = new ArrayList<E>();
|
||||
final List<E> list = new ArrayList<>();
|
||||
for (final E element : collection) {
|
||||
if (retainSet.contains(new EquatorWrapper<E>(equator, element))) {
|
||||
if (retainSet.contains(new EquatorWrapper<>(equator, element))) {
|
||||
list.add(element);
|
||||
}
|
||||
}
|
||||
|
@ -1766,16 +1766,16 @@ public class CollectionUtils {
|
|||
final Transformer<E, EquatorWrapper<E>> transformer = new Transformer<E, EquatorWrapper<E>>() {
|
||||
@Override
|
||||
public EquatorWrapper<E> transform(E input) {
|
||||
return new EquatorWrapper<E>(equator, input);
|
||||
return new EquatorWrapper<>(equator, input);
|
||||
}
|
||||
};
|
||||
|
||||
final Set<EquatorWrapper<E>> removeSet =
|
||||
collect(remove, transformer, new HashSet<EquatorWrapper<E>>());
|
||||
|
||||
final List<E> list = new ArrayList<E>();
|
||||
final List<E> list = new ArrayList<>();
|
||||
for (final E element : collection) {
|
||||
if (!removeSet.contains(new EquatorWrapper<E>(equator, element))) {
|
||||
if (!removeSet.contains(new EquatorWrapper<>(equator, element))) {
|
||||
list.add(element);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ComparatorUtils {
|
|||
* @see ComparatorChain
|
||||
*/
|
||||
public static <E> Comparator<E> chainedComparator(final Comparator<E>... comparators) {
|
||||
final ComparatorChain<E> chain = new ComparatorChain<E>();
|
||||
final ComparatorChain<E> chain = new ComparatorChain<>();
|
||||
for (final Comparator<E> comparator : comparators) {
|
||||
if (comparator == null) {
|
||||
throw new NullPointerException("Comparator cannot be null");
|
||||
|
@ -113,7 +113,7 @@ public class ComparatorUtils {
|
|||
* @see ReverseComparator
|
||||
*/
|
||||
public static <E> Comparator<E> reversedComparator(final Comparator<E> comparator) {
|
||||
return new ReverseComparator<E>(comparator);
|
||||
return new ReverseComparator<>(comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,7 +149,7 @@ public class ComparatorUtils {
|
|||
if (comparator == null) {
|
||||
comparator = NATURAL_COMPARATOR;
|
||||
}
|
||||
return new NullComparator<E>(comparator, false);
|
||||
return new NullComparator<>(comparator, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,7 +169,7 @@ public class ComparatorUtils {
|
|||
if (comparator == null) {
|
||||
comparator = NATURAL_COMPARATOR;
|
||||
}
|
||||
return new NullComparator<E>(comparator, true);
|
||||
return new NullComparator<>(comparator, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,7 +193,7 @@ public class ComparatorUtils {
|
|||
if (comparator == null) {
|
||||
comparator = NATURAL_COMPARATOR;
|
||||
}
|
||||
return new TransformingComparator<I, O>(transformer, comparator);
|
||||
return new TransformingComparator<>(transformer, comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -77,7 +77,7 @@ public class EnumerationUtils {
|
|||
* @throws NullPointerException if the enumeration parameter is <code>null</code>.
|
||||
*/
|
||||
public static <E> List<E> toList(final Enumeration<? extends E> enumeration) {
|
||||
return IteratorUtils.toList(new EnumerationIterator<E>(enumeration));
|
||||
return IteratorUtils.toList(new EnumerationIterator<>(enumeration));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ public class EnumerationUtils {
|
|||
* @return a list containing all tokens of the given StringTokenizer
|
||||
*/
|
||||
public static List<String> toList(final StringTokenizer stringTokenizer) {
|
||||
final List<String> result = new ArrayList<String>(stringTokenizer.countTokens());
|
||||
final List<String> result = new ArrayList<>(stringTokenizer.countTokens());
|
||||
while (stringTokenizer.hasMoreTokens()) {
|
||||
result.add(stringTokenizer.nextToken());
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class FluentIterable<E> implements Iterable<E> {
|
|||
* @return a new FluentIterable containing the singleton
|
||||
*/
|
||||
public static <T> FluentIterable<T> of(final T singleton) {
|
||||
return of(IteratorUtils.asIterable(new SingletonIterator<T>(singleton, false)));
|
||||
return of(IteratorUtils.asIterable(new SingletonIterator<>(singleton, false)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +126,7 @@ public class FluentIterable<E> implements Iterable<E> {
|
|||
if (iterable instanceof FluentIterable<?>) {
|
||||
return (FluentIterable<T>) iterable;
|
||||
} else {
|
||||
return new FluentIterable<T>(iterable);
|
||||
return new FluentIterable<>(iterable);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -365,7 +365,7 @@ public class IterableUtils {
|
|||
final List<E> list = (iterable instanceof List<?>) ?
|
||||
(List<E>) iterable :
|
||||
IteratorUtils.toList(iterable.iterator());
|
||||
return new ReverseListIterator<E>(list);
|
||||
return new ReverseListIterator<>(list);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ public class IterableUtils {
|
|||
return new FluentIterable<E>() {
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new UniqueFilterIterator<E>(iterable.iterator());
|
||||
return new UniqueFilterIterator<>(iterable.iterator());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ public class IterableUtils {
|
|||
if (iterable instanceof UnmodifiableIterable<?>) {
|
||||
return iterable;
|
||||
}
|
||||
return new UnmodifiableIterable<E>(iterable);
|
||||
return new UnmodifiableIterable<>(iterable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -937,7 +937,7 @@ public class IterableUtils {
|
|||
// create the empty partitions
|
||||
final int numberOfPredicates = predicates.length;
|
||||
final int numberOfPartitions = numberOfPredicates + 1;
|
||||
final List<R> partitions = new ArrayList<R>(numberOfPartitions);
|
||||
final List<R> partitions = new ArrayList<>(numberOfPartitions);
|
||||
for (int i = 0; i < numberOfPartitions; ++i) {
|
||||
partitions.add(partitionFactory.create());
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ public class IteratorUtils {
|
|||
* @return a singleton iterator over the object
|
||||
*/
|
||||
public static <E> ResettableIterator<E> singletonIterator(final E object) {
|
||||
return new SingletonIterator<E>(object);
|
||||
return new SingletonIterator<>(object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -222,7 +222,7 @@ public class IteratorUtils {
|
|||
* @return a singleton list iterator over the object
|
||||
*/
|
||||
public static <E> ListIterator<E> singletonListIterator(final E object) {
|
||||
return new SingletonListIterator<E>(object);
|
||||
return new SingletonListIterator<>(object);
|
||||
}
|
||||
|
||||
// Arrays
|
||||
|
@ -236,7 +236,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableIterator<E> arrayIterator(final E... array) {
|
||||
return new ObjectArrayIterator<E>(array);
|
||||
return new ObjectArrayIterator<>(array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,7 +252,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableIterator<E> arrayIterator(final Object array) {
|
||||
return new ArrayIterator<E>(array);
|
||||
return new ArrayIterator<>(array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -267,7 +267,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableIterator<E> arrayIterator(final E[] array, final int start) {
|
||||
return new ObjectArrayIterator<E>(array, start);
|
||||
return new ObjectArrayIterator<>(array, start);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -286,7 +286,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableIterator<E> arrayIterator(final Object array, final int start) {
|
||||
return new ArrayIterator<E>(array, start);
|
||||
return new ArrayIterator<>(array, start);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -302,7 +302,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableIterator<E> arrayIterator(final E[] array, final int start, final int end) {
|
||||
return new ObjectArrayIterator<E>(array, start, end);
|
||||
return new ObjectArrayIterator<>(array, start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -321,7 +321,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableIterator<E> arrayIterator(final Object array, final int start, final int end) {
|
||||
return new ArrayIterator<E>(array, start, end);
|
||||
return new ArrayIterator<>(array, start, end);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -334,7 +334,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableListIterator<E> arrayListIterator(final E... array) {
|
||||
return new ObjectArrayListIterator<E>(array);
|
||||
return new ObjectArrayListIterator<>(array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -350,7 +350,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableListIterator<E> arrayListIterator(final Object array) {
|
||||
return new ArrayListIterator<E>(array);
|
||||
return new ArrayListIterator<>(array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,7 +364,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableListIterator<E> arrayListIterator(final E[] array, final int start) {
|
||||
return new ObjectArrayListIterator<E>(array, start);
|
||||
return new ObjectArrayListIterator<>(array, start);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -382,7 +382,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableListIterator<E> arrayListIterator(final Object array, final int start) {
|
||||
return new ArrayListIterator<E>(array, start);
|
||||
return new ArrayListIterator<>(array, start);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -398,7 +398,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableListIterator<E> arrayListIterator(final E[] array, final int start, final int end) {
|
||||
return new ObjectArrayListIterator<E>(array, start, end);
|
||||
return new ObjectArrayListIterator<>(array, start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -417,7 +417,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if array is null
|
||||
*/
|
||||
public static <E> ResettableListIterator<E> arrayListIterator(final Object array, final int start, final int end) {
|
||||
return new ArrayListIterator<E>(array, start, end);
|
||||
return new ArrayListIterator<>(array, start, end);
|
||||
}
|
||||
|
||||
// Bounded
|
||||
|
@ -457,7 +457,7 @@ public class IteratorUtils {
|
|||
*/
|
||||
public static <E> BoundedIterator<E> boundedIterator(final Iterator<? extends E> iterator,
|
||||
long offset, long max) {
|
||||
return new BoundedIterator<E>(iterator, offset, max);
|
||||
return new BoundedIterator<>(iterator, offset, max);
|
||||
}
|
||||
|
||||
// Unmodifiable
|
||||
|
@ -520,7 +520,7 @@ public class IteratorUtils {
|
|||
final Iterator<? extends E> iterator2) {
|
||||
// keep a version with two iterators to avoid the following warning in client code (Java 5 & 6)
|
||||
// "A generic array of E is created for a varargs parameter"
|
||||
return new IteratorChain<E>(iterator1, iterator2);
|
||||
return new IteratorChain<>(iterator1, iterator2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -533,7 +533,7 @@ public class IteratorUtils {
|
|||
* @throws NullPointerException if iterators array is null or contains a null
|
||||
*/
|
||||
public static <E> Iterator<E> chainedIterator(final Iterator<? extends E>... iterators) {
|
||||
return new IteratorChain<E>(iterators);
|
||||
return new IteratorChain<>(iterators);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -547,7 +547,7 @@ public class IteratorUtils {
|
|||
* @throws ClassCastException if the iterators collection contains the wrong object type
|
||||
*/
|
||||
public static <E> Iterator<E> chainedIterator(final Collection<Iterator<? extends E>> iterators) {
|
||||
return new IteratorChain<E>(iterators);
|
||||
return new IteratorChain<>(iterators);
|
||||
}
|
||||
|
||||
// Collated
|
||||
|
@ -575,7 +575,7 @@ public class IteratorUtils {
|
|||
@SuppressWarnings("unchecked")
|
||||
final Comparator<E> comp =
|
||||
comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator<E>) comparator;
|
||||
return new CollatingIterator<E>(comp, iterator1, iterator2);
|
||||
return new CollatingIterator<>(comp, iterator1, iterator2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -599,7 +599,7 @@ public class IteratorUtils {
|
|||
@SuppressWarnings("unchecked")
|
||||
final Comparator<E> comp =
|
||||
comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator<E>) comparator;
|
||||
return new CollatingIterator<E>(comp, iterators);
|
||||
return new CollatingIterator<>(comp, iterators);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -624,7 +624,7 @@ public class IteratorUtils {
|
|||
@SuppressWarnings("unchecked")
|
||||
final Comparator<E> comp =
|
||||
comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator<E>) comparator;
|
||||
return new CollatingIterator<E>(comp, iterators);
|
||||
return new CollatingIterator<>(comp, iterators);
|
||||
}
|
||||
|
||||
// Object Graph
|
||||
|
@ -685,7 +685,7 @@ public class IteratorUtils {
|
|||
*/
|
||||
public static <E> Iterator<E> objectGraphIterator(final E root,
|
||||
final Transformer<? super E, ? extends E> transformer) {
|
||||
return new ObjectGraphIterator<E>(root, transformer);
|
||||
return new ObjectGraphIterator<>(root, transformer);
|
||||
}
|
||||
|
||||
// Transformed
|
||||
|
@ -712,7 +712,7 @@ public class IteratorUtils {
|
|||
if (transform == null) {
|
||||
throw new NullPointerException("Transformer must not be null");
|
||||
}
|
||||
return new TransformIterator<I, O>(iterator, transform);
|
||||
return new TransformIterator<>(iterator, transform);
|
||||
}
|
||||
|
||||
// Filtered
|
||||
|
@ -737,7 +737,7 @@ public class IteratorUtils {
|
|||
if (predicate == null) {
|
||||
throw new NullPointerException("Predicate must not be null");
|
||||
}
|
||||
return new FilterIterator<E>(iterator, predicate);
|
||||
return new FilterIterator<>(iterator, predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -761,7 +761,7 @@ public class IteratorUtils {
|
|||
if (predicate == null) {
|
||||
throw new NullPointerException("Predicate must not be null");
|
||||
}
|
||||
return new FilterListIterator<E>(listIterator, predicate);
|
||||
return new FilterListIterator<>(listIterator, predicate);
|
||||
}
|
||||
|
||||
// Looping
|
||||
|
@ -782,7 +782,7 @@ public class IteratorUtils {
|
|||
if (coll == null) {
|
||||
throw new NullPointerException("Collection must not be null");
|
||||
}
|
||||
return new LoopingIterator<E>(coll);
|
||||
return new LoopingIterator<>(coll);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -801,7 +801,7 @@ public class IteratorUtils {
|
|||
if (list == null) {
|
||||
throw new NullPointerException("List must not be null");
|
||||
}
|
||||
return new LoopingListIterator<E>(list);
|
||||
return new LoopingListIterator<>(list);
|
||||
}
|
||||
|
||||
// org.w3c.dom.NodeList iterators
|
||||
|
@ -892,7 +892,7 @@ public class IteratorUtils {
|
|||
* @since 4.1
|
||||
*/
|
||||
public static <E> SkippingIterator<E> skippingIterator(final Iterator<E> iterator, long offset) {
|
||||
return new SkippingIterator<E>(iterator, offset);
|
||||
return new SkippingIterator<>(iterator, offset);
|
||||
}
|
||||
|
||||
// Zipping
|
||||
|
@ -909,7 +909,7 @@ public class IteratorUtils {
|
|||
*/
|
||||
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E> a,
|
||||
final Iterator<? extends E> b) {
|
||||
return new ZippingIterator<E>(a, b);
|
||||
return new ZippingIterator<>(a, b);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -926,7 +926,7 @@ public class IteratorUtils {
|
|||
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E> a,
|
||||
final Iterator<? extends E> b,
|
||||
final Iterator<? extends E> c) {
|
||||
return new ZippingIterator<E>(a, b, c);
|
||||
return new ZippingIterator<>(a, b, c);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -939,7 +939,7 @@ public class IteratorUtils {
|
|||
* @since 4.1
|
||||
*/
|
||||
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E>... iterators) {
|
||||
return new ZippingIterator<E>(iterators);
|
||||
return new ZippingIterator<>(iterators);
|
||||
}
|
||||
|
||||
// Views
|
||||
|
@ -956,7 +956,7 @@ public class IteratorUtils {
|
|||
if (enumeration == null) {
|
||||
throw new NullPointerException("Enumeration must not be null");
|
||||
}
|
||||
return new EnumerationIterator<E>(enumeration);
|
||||
return new EnumerationIterator<>(enumeration);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -977,7 +977,7 @@ public class IteratorUtils {
|
|||
if (removeCollection == null) {
|
||||
throw new NullPointerException("Collection must not be null");
|
||||
}
|
||||
return new EnumerationIterator<E>(enumeration, removeCollection);
|
||||
return new EnumerationIterator<>(enumeration, removeCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -992,7 +992,7 @@ public class IteratorUtils {
|
|||
if (iterator == null) {
|
||||
throw new NullPointerException("Iterator must not be null");
|
||||
}
|
||||
return new IteratorEnumeration<E>(iterator);
|
||||
return new IteratorEnumeration<>(iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1008,7 +1008,7 @@ public class IteratorUtils {
|
|||
if (iterator == null) {
|
||||
throw new NullPointerException("Iterator must not be null");
|
||||
}
|
||||
return new IteratorIterable<E>(iterator, false);
|
||||
return new IteratorIterable<>(iterator, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1024,7 +1024,7 @@ public class IteratorUtils {
|
|||
if (iterator == null) {
|
||||
throw new NullPointerException("Iterator must not be null");
|
||||
}
|
||||
return new IteratorIterable<E>(iterator, true);
|
||||
return new IteratorIterable<>(iterator, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1042,7 +1042,7 @@ public class IteratorUtils {
|
|||
if (iterator == null) {
|
||||
throw new NullPointerException("Iterator must not be null");
|
||||
}
|
||||
return new ListIteratorWrapper<E>(iterator);
|
||||
return new ListIteratorWrapper<>(iterator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1124,7 +1124,7 @@ public class IteratorUtils {
|
|||
if (estimatedSize < 1) {
|
||||
throw new IllegalArgumentException("Estimated size must be greater than 0");
|
||||
}
|
||||
final List<E> list = new ArrayList<E>(estimatedSize);
|
||||
final List<E> list = new ArrayList<>(estimatedSize);
|
||||
while (iterator.hasNext()) {
|
||||
list.add(iterator.next());
|
||||
}
|
||||
|
@ -1163,10 +1163,10 @@ public class IteratorUtils {
|
|||
return ((Iterable<?>) obj).iterator();
|
||||
}
|
||||
if (obj instanceof Object[]) {
|
||||
return new ObjectArrayIterator<Object>((Object[]) obj);
|
||||
return new ObjectArrayIterator<>((Object[]) obj);
|
||||
}
|
||||
if (obj instanceof Enumeration) {
|
||||
return new EnumerationIterator<Object>((Enumeration<?>) obj);
|
||||
return new EnumerationIterator<>((Enumeration<?>) obj);
|
||||
}
|
||||
if (obj instanceof Map) {
|
||||
return ((Map<?, ?>) obj).values().iterator();
|
||||
|
@ -1178,9 +1178,9 @@ public class IteratorUtils {
|
|||
return new NodeListIterator((Node) obj);
|
||||
}
|
||||
if (obj instanceof Dictionary) {
|
||||
return new EnumerationIterator<Object>(((Dictionary<?, ?>) obj).elements());
|
||||
return new EnumerationIterator<>(((Dictionary<?, ?>) obj).elements());
|
||||
} else if (obj.getClass().isArray()) {
|
||||
return new ArrayIterator<Object>(obj);
|
||||
return new ArrayIterator<>(obj);
|
||||
}
|
||||
try {
|
||||
final Method method = obj.getClass().getMethod("iterator", (Class[]) null);
|
||||
|
|
|
@ -87,7 +87,7 @@ public class ListUtils {
|
|||
* @throws NullPointerException if either list is null
|
||||
*/
|
||||
public static <E> List<E> intersection(final List<? extends E> list1, final List<? extends E> list2) {
|
||||
final List<E> result = new ArrayList<E>();
|
||||
final List<E> result = new ArrayList<>();
|
||||
|
||||
List<? extends E> smaller = list1;
|
||||
List<? extends E> larger = list2;
|
||||
|
@ -96,7 +96,7 @@ public class ListUtils {
|
|||
larger = list1;
|
||||
}
|
||||
|
||||
final HashSet<E> hashSet = new HashSet<E>(smaller);
|
||||
final HashSet<E> hashSet = new HashSet<>(smaller);
|
||||
|
||||
for (final E e : larger) {
|
||||
if (hashSet.contains(e)) {
|
||||
|
@ -124,8 +124,8 @@ public class ListUtils {
|
|||
* @throws NullPointerException if either list is null
|
||||
*/
|
||||
public static <E> List<E> subtract(final List<E> list1, final List<? extends E> list2) {
|
||||
final ArrayList<E> result = new ArrayList<E>();
|
||||
final HashBag<E> bag = new HashBag<E>(list2);
|
||||
final ArrayList<E> result = new ArrayList<>();
|
||||
final HashBag<E> bag = new HashBag<>(list2);
|
||||
for (final E e : list1) {
|
||||
if (!bag.remove(e, 1)) {
|
||||
result.add(e);
|
||||
|
@ -160,7 +160,7 @@ public class ListUtils {
|
|||
* @throws NullPointerException if either list is null
|
||||
*/
|
||||
public static <E> List<E> union(final List<? extends E> list1, final List<? extends E> list2) {
|
||||
final ArrayList<E> result = new ArrayList<E>(list1);
|
||||
final ArrayList<E> result = new ArrayList<>(list1);
|
||||
result.addAll(list2);
|
||||
return result;
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ public class ListUtils {
|
|||
* @since 3.2
|
||||
*/
|
||||
public static <E> List<E> retainAll(final Collection<E> collection, final Collection<?> retain) {
|
||||
final List<E> list = new ArrayList<E>(Math.min(collection.size(), retain.size()));
|
||||
final List<E> list = new ArrayList<>(Math.min(collection.size(), retain.size()));
|
||||
|
||||
for (final E obj : collection) {
|
||||
if (retain.contains(obj)) {
|
||||
|
@ -343,7 +343,7 @@ public class ListUtils {
|
|||
* @since 3.2
|
||||
*/
|
||||
public static <E> List<E> removeAll(final Collection<E> collection, final Collection<?> remove) {
|
||||
final List<E> list = new ArrayList<E>();
|
||||
final List<E> list = new ArrayList<>();
|
||||
for (final E obj : collection) {
|
||||
if (!remove.contains(obj)) {
|
||||
list.add(obj);
|
||||
|
@ -545,9 +545,9 @@ public class ListUtils {
|
|||
throw new NullPointerException("Equator must not be null");
|
||||
}
|
||||
|
||||
final SequencesComparator<E> comparator = new SequencesComparator<E>(a, b, equator);
|
||||
final SequencesComparator<E> comparator = new SequencesComparator<>(a, b, equator);
|
||||
final EditScript<E> script = comparator.getScript();
|
||||
final LcsVisitor<E> visitor = new LcsVisitor<E>();
|
||||
final LcsVisitor<E> visitor = new LcsVisitor<>();
|
||||
script.visit(visitor);
|
||||
return visitor.getSubSequence();
|
||||
}
|
||||
|
@ -583,7 +583,7 @@ public class ListUtils {
|
|||
private final ArrayList<E> sequence;
|
||||
|
||||
public LcsVisitor() {
|
||||
sequence = new ArrayList<E>();
|
||||
sequence = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -655,7 +655,7 @@ public class ListUtils {
|
|||
if (size <= 0) {
|
||||
throw new IllegalArgumentException("Size must be greater than 0");
|
||||
}
|
||||
return new Partition<T>(list, size);
|
||||
return new Partition<>(list, size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -85,7 +85,7 @@ public class MapUtils {
|
|||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final SortedMap EMPTY_SORTED_MAP =
|
||||
UnmodifiableSortedMap.unmodifiableSortedMap(new TreeMap<Object, Object>());
|
||||
UnmodifiableSortedMap.unmodifiableSortedMap(new TreeMap<>());
|
||||
|
||||
/**
|
||||
* String used to indent the verbose and debug Map prints.
|
||||
|
@ -888,7 +888,7 @@ public class MapUtils {
|
|||
*/
|
||||
public static Map<String, Object> toMap(final ResourceBundle resourceBundle) {
|
||||
final Enumeration<String> enumeration = resourceBundle.getKeys();
|
||||
final Map<String, Object> map = new HashMap<String, Object>();
|
||||
final Map<String, Object> map = new HashMap<>();
|
||||
|
||||
while (enumeration.hasMoreElements()) {
|
||||
final String key = enumeration.nextElement();
|
||||
|
@ -1065,7 +1065,7 @@ public class MapUtils {
|
|||
* @throws NullPointerException if the map is null
|
||||
*/
|
||||
public static <K, V> Map<V, K> invertMap(final Map<K, V> map) {
|
||||
final Map<V, K> out = new HashMap<V, K>(map.size());
|
||||
final Map<V, K> out = new HashMap<>(map.size());
|
||||
for (final Entry<K, V> entry : map.entrySet()) {
|
||||
out.put(entry.getValue(), entry.getKey());
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ public class MultiMapUtils {
|
|||
if (col instanceof List) {
|
||||
return (List<V>) col;
|
||||
}
|
||||
return new ArrayList<V>(col);
|
||||
return new ArrayList<>(col);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class MultiMapUtils {
|
|||
if (col instanceof Set) {
|
||||
return (Set<V>) col;
|
||||
}
|
||||
return new HashSet<V>(col);
|
||||
return new HashSet<>(col);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ public class MultiMapUtils {
|
|||
if (col instanceof Bag) {
|
||||
return (Bag<V>) col;
|
||||
}
|
||||
return new HashBag<V>(col);
|
||||
return new HashBag<>(col);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ public class MultiMapUtils {
|
|||
* @return a new <code>ListValuedMap</code>
|
||||
*/
|
||||
public static <K, V> ListValuedMap<K, V> newListValuedHashMap() {
|
||||
return new ArrayListValuedHashMap<K, V>();
|
||||
return new ArrayListValuedHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,7 +201,7 @@ public class MultiMapUtils {
|
|||
* @return a new {@link SetValuedMap}
|
||||
*/
|
||||
public static <K, V> SetValuedMap<K, V> newSetValuedHashMap() {
|
||||
return new HashSetValuedHashMap<K, V>();
|
||||
return new HashSetValuedHashMap<>();
|
||||
}
|
||||
|
||||
// MultiValuedMap Decorators
|
||||
|
|
|
@ -34,7 +34,7 @@ public class MultiSetUtils {
|
|||
*/
|
||||
@SuppressWarnings("rawtypes") // OK, empty multiset is compatible with any type
|
||||
public static final MultiSet EMPTY_MULTISET =
|
||||
UnmodifiableMultiSet.unmodifiableMultiSet(new HashMultiSet<Object>());
|
||||
UnmodifiableMultiSet.unmodifiableMultiSet(new HashMultiSet<>());
|
||||
|
||||
/**
|
||||
* Instantiation of MultiSetUtils is not intended or required.
|
||||
|
|
|
@ -35,7 +35,7 @@ public class QueueUtils {
|
|||
* An empty unmodifiable queue.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes") // OK, empty queue is compatible with any type
|
||||
public static final Queue EMPTY_QUEUE = UnmodifiableQueue.unmodifiableQueue(new LinkedList<Object>());
|
||||
public static final Queue EMPTY_QUEUE = UnmodifiableQueue.unmodifiableQueue(new LinkedList<>());
|
||||
|
||||
/**
|
||||
* <code>QueueUtils</code> should not normally be instantiated.
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SetUtils {
|
|||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final SortedSet EMPTY_SORTED_SET =
|
||||
UnmodifiableSortedSet.unmodifiableSortedSet(new TreeSet<Object>());
|
||||
UnmodifiableSortedSet.unmodifiableSortedSet(new TreeSet<>());
|
||||
|
||||
/**
|
||||
* Get a typed empty unmodifiable sorted set.
|
||||
|
@ -637,7 +637,7 @@ public class SetUtils {
|
|||
* @return a new set containing all elements of this view
|
||||
*/
|
||||
public Set<E> toSet() {
|
||||
final Set<E> set = new HashSet<E>(size());
|
||||
final Set<E> set = new HashSet<>(size());
|
||||
copyInto(set);
|
||||
return set;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ public class SplitMapUtils {
|
|||
if (get instanceof IterableGet) {
|
||||
it = ((IterableGet<K, V>) get).mapIterator();
|
||||
} else {
|
||||
it = new EntrySetToMapIteratorAdapter<K, V>(get.entrySet());
|
||||
it = new EntrySetToMapIteratorAdapter<>(get.entrySet());
|
||||
}
|
||||
return UnmodifiableMapIterator.unmodifiableMapIterator(it);
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ public class SplitMapUtils {
|
|||
((IterableMap<K, V>) get) :
|
||||
MapUtils.iterableMap((Map<K, V>) get);
|
||||
}
|
||||
return new WrappedGet<K, V>(get);
|
||||
return new WrappedGet<>(get);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,7 +266,7 @@ public class SplitMapUtils {
|
|||
if (put instanceof Map) {
|
||||
return (Map<K, V>) put;
|
||||
}
|
||||
return new WrappedPut<K, V>(put);
|
||||
return new WrappedPut<>(put);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
if (coll instanceof Bag) {
|
||||
return containsAll((Bag<?>) coll);
|
||||
}
|
||||
return containsAll(new HashBag<Object>(coll));
|
||||
return containsAll(new HashBag<>(coll));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,7 +171,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
*/
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new BagIterator<E>(this);
|
||||
return new BagIterator<>(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -379,7 +379,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
if (coll instanceof Bag) {
|
||||
return retainAll((Bag<?>) coll);
|
||||
}
|
||||
return retainAll(new HashBag<Object>(coll));
|
||||
return retainAll(new HashBag<>(coll));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,7 +392,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
|||
*/
|
||||
boolean retainAll(final Bag<?> other) {
|
||||
boolean result = false;
|
||||
final Bag<E> excess = new HashBag<E>();
|
||||
final Bag<E> excess = new HashBag<>();
|
||||
final Iterator<E> i = uniqueSet().iterator();
|
||||
while (i.hasNext()) {
|
||||
final E current = i.next();
|
||||
|
|
|
@ -52,7 +52,7 @@ public final class CollectionBag<E> extends AbstractBagDecorator<E> {
|
|||
* @throws NullPointerException if bag is null
|
||||
*/
|
||||
public static <E> Bag<E> collectionBag(final Bag<E> bag) {
|
||||
return new CollectionBag<E>(bag);
|
||||
return new CollectionBag<>(bag);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -44,7 +44,7 @@ public final class CollectionSortedBag<E> extends AbstractSortedBagDecorator<E>
|
|||
* @throws NullPointerException if bag is null
|
||||
*/
|
||||
public static <E> SortedBag<E> collectionSortedBag(final SortedBag<E> bag) {
|
||||
return new CollectionSortedBag<E>(bag);
|
||||
return new CollectionSortedBag<>(bag);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -60,7 +60,7 @@ public class PredicatedBag<E> extends PredicatedCollection<E> implements Bag<E>
|
|||
* @since 4.0
|
||||
*/
|
||||
public static <E> PredicatedBag<E> predicatedBag(final Bag<E> bag, final Predicate<? super E> predicate) {
|
||||
return new PredicatedBag<E>(bag, predicate);
|
||||
return new PredicatedBag<>(bag, predicate);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -60,7 +60,7 @@ public class PredicatedSortedBag<E> extends PredicatedBag<E> implements SortedBa
|
|||
*/
|
||||
public static <E> PredicatedSortedBag<E> predicatedSortedBag(final SortedBag<E> bag,
|
||||
final Predicate<? super E> predicate) {
|
||||
return new PredicatedSortedBag<E>(bag, predicate);
|
||||
return new PredicatedSortedBag<>(bag, predicate);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -48,7 +48,7 @@ public class SynchronizedBag<E> extends SynchronizedCollection<E> implements Bag
|
|||
* @since 4.0
|
||||
*/
|
||||
public static <E> SynchronizedBag<E> synchronizedBag(final Bag<E> bag) {
|
||||
return new SynchronizedBag<E>(bag);
|
||||
return new SynchronizedBag<>(bag);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -48,7 +48,7 @@ public class SynchronizedSortedBag<E> extends SynchronizedBag<E> implements Sort
|
|||
* @since 4.0
|
||||
*/
|
||||
public static <E> SynchronizedSortedBag<E> synchronizedSortedBag(final SortedBag<E> bag) {
|
||||
return new SynchronizedSortedBag<E>(bag);
|
||||
return new SynchronizedSortedBag<>(bag);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -55,7 +55,7 @@ public class TransformedBag<E> extends TransformedCollection<E> implements Bag<E
|
|||
* @since 4.0
|
||||
*/
|
||||
public static <E> Bag<E> transformingBag(final Bag<E> bag, final Transformer<? super E, ? extends E> transformer) {
|
||||
return new TransformedBag<E>(bag, transformer);
|
||||
return new TransformedBag<>(bag, transformer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +74,7 @@ public class TransformedBag<E> extends TransformedCollection<E> implements Bag<E
|
|||
* @since 4.0
|
||||
*/
|
||||
public static <E> Bag<E> transformedBag(final Bag<E> bag, final Transformer<? super E, ? extends E> transformer) {
|
||||
final TransformedBag<E> decorated = new TransformedBag<E>(bag, transformer);
|
||||
final TransformedBag<E> decorated = new TransformedBag<>(bag, transformer);
|
||||
if (bag.size() > 0) {
|
||||
@SuppressWarnings("unchecked") // Bag is of type E
|
||||
final E[] values = (E[]) bag.toArray(); // NOPMD - false positive for generics
|
||||
|
|
|
@ -54,7 +54,7 @@ public class TransformedSortedBag<E> extends TransformedBag<E> implements Sorted
|
|||
*/
|
||||
public static <E> TransformedSortedBag<E> transformingSortedBag(final SortedBag<E> bag,
|
||||
final Transformer<? super E, ? extends E> transformer) {
|
||||
return new TransformedSortedBag<E>(bag, transformer);
|
||||
return new TransformedSortedBag<>(bag, transformer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +75,7 @@ public class TransformedSortedBag<E> extends TransformedBag<E> implements Sorted
|
|||
public static <E> TransformedSortedBag<E> transformedSortedBag(final SortedBag<E> bag,
|
||||
final Transformer<? super E, ? extends E> transformer) {
|
||||
|
||||
final TransformedSortedBag<E> decorated = new TransformedSortedBag<E>(bag, transformer);
|
||||
final TransformedSortedBag<E> decorated = new TransformedSortedBag<>(bag, transformer);
|
||||
if (bag.size() > 0) {
|
||||
@SuppressWarnings("unchecked") // bag is type E
|
||||
final E[] values = (E[]) bag.toArray(); // NOPMD - false positive for generics
|
||||
|
|
|
@ -61,7 +61,7 @@ public final class UnmodifiableBag<E>
|
|||
final Bag<E> tmpBag = (Bag<E>) bag;
|
||||
return tmpBag;
|
||||
}
|
||||
return new UnmodifiableBag<E>(bag);
|
||||
return new UnmodifiableBag<>(bag);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -59,7 +59,7 @@ public final class UnmodifiableSortedBag<E>
|
|||
if (bag instanceof Unmodifiable) {
|
||||
return bag;
|
||||
}
|
||||
return new UnmodifiableSortedBag<E>(bag);
|
||||
return new UnmodifiableSortedBag<>(bag);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -225,7 +225,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
|||
*/
|
||||
@Override
|
||||
public MapIterator<K, V> mapIterator() {
|
||||
return new BidiMapIterator<K, V>(this);
|
||||
return new BidiMapIterator<>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -263,7 +263,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
|||
@Override
|
||||
public Set<K> keySet() {
|
||||
if (keySet == null) {
|
||||
keySet = new KeySet<K>(this);
|
||||
keySet = new KeySet<>(this);
|
||||
}
|
||||
return keySet;
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
|||
* @return the keySet iterator
|
||||
*/
|
||||
protected Iterator<K> createKeySetIterator(final Iterator<K> iterator) {
|
||||
return new KeySetIterator<K>(iterator, this);
|
||||
return new KeySetIterator<>(iterator, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -289,7 +289,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
|||
@Override
|
||||
public Set<V> values() {
|
||||
if (values == null) {
|
||||
values = new Values<V>(this);
|
||||
values = new Values<>(this);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
|||
* @return the values iterator
|
||||
*/
|
||||
protected Iterator<V> createValuesIterator(final Iterator<V> iterator) {
|
||||
return new ValuesIterator<V>(iterator, this);
|
||||
return new ValuesIterator<>(iterator, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -319,7 +319,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
|||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
if (entrySet == null) {
|
||||
entrySet = new EntrySet<K, V>(this);
|
||||
entrySet = new EntrySet<>(this);
|
||||
}
|
||||
return entrySet;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
|||
* @return the entrySet iterator
|
||||
*/
|
||||
protected Iterator<Map.Entry<K, V>> createEntrySetIterator(final Iterator<Map.Entry<K, V>> iterator) {
|
||||
return new EntrySetIterator<K, V>(iterator, this);
|
||||
return new EntrySetIterator<>(iterator, this);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -652,7 +652,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
|||
|
||||
@Override
|
||||
public Map.Entry<K, V> next() {
|
||||
last = new MapEntry<K, V>(super.next(), parent);
|
||||
last = new MapEntry<>(super.next(), parent);
|
||||
canRemove = true;
|
||||
return last;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class DualHashBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
|
|||
@Override
|
||||
protected BidiMap<V, K> createBidiMap(final Map<V, K> normalMap, final Map<K, V> reverseMap,
|
||||
final BidiMap<K, V> inverseBidiMap) {
|
||||
return new DualHashBidiMap<V, K>(normalMap, reverseMap, inverseBidiMap);
|
||||
return new DualHashBidiMap<>(normalMap, reverseMap, inverseBidiMap);
|
||||
}
|
||||
|
||||
// Serialization
|
||||
|
@ -97,8 +97,8 @@ public class DualHashBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
|
|||
|
||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
normalMap = new HashMap<K, V>();
|
||||
reverseMap = new HashMap<V, K>();
|
||||
normalMap = new HashMap<>();
|
||||
reverseMap = new HashMap<>();
|
||||
@SuppressWarnings("unchecked") // will fail at runtime if stream is incorrect
|
||||
final Map<K, V> map = (Map<K, V>) in.readObject();
|
||||
putAll(map);
|
||||
|
|
|
@ -80,7 +80,7 @@ public class DualLinkedHashBidiMap<K, V> extends AbstractDualBidiMap<K, V> imple
|
|||
@Override
|
||||
protected BidiMap<V, K> createBidiMap(final Map<V, K> normalMap, final Map<K, V> reverseMap,
|
||||
final BidiMap<K, V> inverseBidiMap) {
|
||||
return new DualLinkedHashBidiMap<V, K>(normalMap, reverseMap, inverseBidiMap);
|
||||
return new DualLinkedHashBidiMap<>(normalMap, reverseMap, inverseBidiMap);
|
||||
}
|
||||
|
||||
// Serialization
|
||||
|
@ -92,8 +92,8 @@ public class DualLinkedHashBidiMap<K, V> extends AbstractDualBidiMap<K, V> imple
|
|||
|
||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
normalMap = new LinkedHashMap<K, V>();
|
||||
reverseMap = new LinkedHashMap<V, K>();
|
||||
normalMap = new LinkedHashMap<>();
|
||||
reverseMap = new LinkedHashMap<>();
|
||||
@SuppressWarnings("unchecked") // will fail at runtime if stream is incorrect
|
||||
final Map<K, V> map = (Map<K, V>) in.readObject();
|
||||
putAll(map);
|
||||
|
|
|
@ -123,7 +123,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
|||
@Override
|
||||
protected DualTreeBidiMap<V, K> createBidiMap(final Map<V, K> normalMap, final Map<K, V> reverseMap,
|
||||
final BidiMap<K, V> inverseMap) {
|
||||
return new DualTreeBidiMap<V, K>(normalMap, reverseMap, inverseMap);
|
||||
return new DualTreeBidiMap<>(normalMap, reverseMap, inverseMap);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -192,7 +192,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
|||
*/
|
||||
@Override
|
||||
public OrderedMapIterator<K, V> mapIterator() {
|
||||
return new BidiOrderedMapIterator<K, V>(this);
|
||||
return new BidiOrderedMapIterator<>(this);
|
||||
}
|
||||
|
||||
public SortedBidiMap<V, K> inverseSortedBidiMap() {
|
||||
|
@ -208,19 +208,19 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
|||
@Override
|
||||
public SortedMap<K, V> headMap(final K toKey) {
|
||||
final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).headMap(toKey);
|
||||
return new ViewMap<K, V>(this, sub);
|
||||
return new ViewMap<>(this, sub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> tailMap(final K fromKey) {
|
||||
final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).tailMap(fromKey);
|
||||
return new ViewMap<K, V>(this, sub);
|
||||
return new ViewMap<>(this, sub);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
|
||||
final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).subMap(fromKey, toKey);
|
||||
return new ViewMap<K, V>(this, sub);
|
||||
return new ViewMap<>(this, sub);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -242,7 +242,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
|||
// the implementation is not great here...
|
||||
// use the normalMap as the filtered map, but reverseMap as the full map
|
||||
// this forces containsValue and clear to be overridden
|
||||
super(new DualTreeBidiMap<K, V>(sm, bidi.reverseMap, bidi.inverseBidiMap));
|
||||
super(new DualTreeBidiMap<>(sm, bidi.reverseMap, bidi.inverseBidiMap));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -262,17 +262,17 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
|||
|
||||
@Override
|
||||
public SortedMap<K, V> headMap(final K toKey) {
|
||||
return new ViewMap<K, V>(decorated(), super.headMap(toKey));
|
||||
return new ViewMap<>(decorated(), super.headMap(toKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> tailMap(final K fromKey) {
|
||||
return new ViewMap<K, V>(decorated(), super.tailMap(fromKey));
|
||||
return new ViewMap<>(decorated(), super.tailMap(fromKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
|
||||
return new ViewMap<K, V>(decorated(), super.subMap(fromKey, toKey));
|
||||
return new ViewMap<>(decorated(), super.subMap(fromKey, toKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -313,7 +313,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
|||
protected BidiOrderedMapIterator(final AbstractDualBidiMap<K, V> parent) {
|
||||
super();
|
||||
this.parent = parent;
|
||||
iterator = new ArrayList<Map.Entry<K, V>>(parent.entrySet()).listIterator();
|
||||
iterator = new ArrayList<>(parent.entrySet()).listIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -384,7 +384,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
|||
|
||||
@Override
|
||||
public void reset() {
|
||||
iterator = new ArrayList<Map.Entry<K, V>>(parent.entrySet()).listIterator();
|
||||
iterator = new ArrayList<>(parent.entrySet()).listIterator();
|
||||
last = null;
|
||||
}
|
||||
|
||||
|
@ -406,8 +406,8 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
|||
|
||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
normalMap = new TreeMap<K, V>(comparator);
|
||||
reverseMap = new TreeMap<V, K>(valueComparator);
|
||||
normalMap = new TreeMap<>(comparator);
|
||||
reverseMap = new TreeMap<>(valueComparator);
|
||||
@SuppressWarnings("unchecked") // will fail at runtime if the stream is incorrect
|
||||
final Map<K, V> map = (Map<K, V>) in.readObject();
|
||||
putAll(map);
|
||||
|
|
|
@ -509,7 +509,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
Node<K, V> node = rootNode[KEY.ordinal()];
|
||||
if (node == null) {
|
||||
// map is empty
|
||||
final Node<K, V> root = new Node<K, V>(key, value);
|
||||
final Node<K, V> root = new Node<>(key, value);
|
||||
rootNode[KEY.ordinal()] = root;
|
||||
rootNode[VALUE.ordinal()] = root;
|
||||
grow();
|
||||
|
@ -526,7 +526,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
if (node.getLeft(KEY) != null) {
|
||||
node = node.getLeft(KEY);
|
||||
} else {
|
||||
final Node<K, V> newNode = new Node<K, V>(key, value);
|
||||
final Node<K, V> newNode = new Node<>(key, value);
|
||||
|
||||
insertValue(newNode);
|
||||
node.setLeft(newNode, KEY);
|
||||
|
@ -540,7 +540,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
if (node.getRight(KEY) != null) {
|
||||
node = node.getRight(KEY);
|
||||
} else {
|
||||
final Node<K, V> newNode = new Node<K, V>(key, value);
|
||||
final Node<K, V> newNode = new Node<>(key, value);
|
||||
|
||||
insertValue(newNode);
|
||||
node.setRight(newNode, KEY);
|
||||
|
@ -1847,7 +1847,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
|||
}
|
||||
|
||||
private Map.Entry<V, K> createEntry(final Node<K, V> node) {
|
||||
return new UnmodifiableMapEntry<V, K>(node.getValue(), node.getKey());
|
||||
return new UnmodifiableMapEntry<>(node.getValue(), node.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public final class UnmodifiableBidiMap<K, V>
|
|||
final BidiMap<K, V> tmpMap = (BidiMap<K, V>) map;
|
||||
return tmpMap;
|
||||
}
|
||||
return new UnmodifiableBidiMap<K, V>(map);
|
||||
return new UnmodifiableBidiMap<>(map);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -127,7 +127,7 @@ public final class UnmodifiableBidiMap<K, V>
|
|||
@Override
|
||||
public synchronized BidiMap<V, K> inverseBidiMap() {
|
||||
if (inverse == null) {
|
||||
inverse = new UnmodifiableBidiMap<V, K>(decorated().inverseBidiMap());
|
||||
inverse = new UnmodifiableBidiMap<>(decorated().inverseBidiMap());
|
||||
inverse.inverse = this;
|
||||
}
|
||||
return inverse;
|
||||
|
|
|
@ -59,7 +59,7 @@ public final class UnmodifiableOrderedBidiMap<K, V>
|
|||
final OrderedBidiMap<K, V> tmpMap = (OrderedBidiMap<K, V>) map;
|
||||
return tmpMap;
|
||||
}
|
||||
return new UnmodifiableOrderedBidiMap<K, V>(map);
|
||||
return new UnmodifiableOrderedBidiMap<>(map);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -138,7 +138,7 @@ public final class UnmodifiableOrderedBidiMap<K, V>
|
|||
*/
|
||||
public OrderedBidiMap<V, K> inverseOrderedBidiMap() {
|
||||
if (inverse == null) {
|
||||
inverse = new UnmodifiableOrderedBidiMap<V, K>(decorated().inverseBidiMap());
|
||||
inverse = new UnmodifiableOrderedBidiMap<>(decorated().inverseBidiMap());
|
||||
inverse.inverse = this;
|
||||
}
|
||||
return inverse;
|
||||
|
|
|
@ -60,7 +60,7 @@ public final class UnmodifiableSortedBidiMap<K, V>
|
|||
final SortedBidiMap<K, V> tmpMap = (SortedBidiMap<K, V>) map;
|
||||
return tmpMap;
|
||||
}
|
||||
return new UnmodifiableSortedBidiMap<K, V>(map);
|
||||
return new UnmodifiableSortedBidiMap<>(map);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -131,7 +131,7 @@ public final class UnmodifiableSortedBidiMap<K, V>
|
|||
@Override
|
||||
public SortedBidiMap<V, K> inverseBidiMap() {
|
||||
if (inverse == null) {
|
||||
inverse = new UnmodifiableSortedBidiMap<V, K>(decorated().inverseBidiMap());
|
||||
inverse = new UnmodifiableSortedBidiMap<>(decorated().inverseBidiMap());
|
||||
inverse.inverse = this;
|
||||
}
|
||||
return inverse;
|
||||
|
|
|
@ -48,7 +48,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
|
|||
private CollectionMutator<E> mutator;
|
||||
|
||||
/** Collections in the composite */
|
||||
private final List<Collection<E>> all = new ArrayList<Collection<E>>();
|
||||
private final List<Collection<E>> all = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Create an empty CompositeCollection.
|
||||
|
@ -156,7 +156,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
|
|||
if (all.isEmpty()) {
|
||||
return EmptyIterator.<E>emptyIterator();
|
||||
}
|
||||
final IteratorChain<E> chain = new IteratorChain<E>();
|
||||
final IteratorChain<E> chain = new IteratorChain<>();
|
||||
for (final Collection<E> item : all) {
|
||||
chain.addIterator(item.iterator());
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
|
|||
* The new collection is <i>not</i> backed by this composite.
|
||||
*/
|
||||
public Collection<E> toCollection() {
|
||||
return new ArrayList<E>(this);
|
||||
return new ArrayList<>(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,7 +71,7 @@ public class IndexedCollection<K, C> extends AbstractCollectionDecorator<C> {
|
|||
*/
|
||||
public static <K, C> IndexedCollection<K, C> uniqueIndexedCollection(final Collection<C> coll,
|
||||
final Transformer<C, K> keyTransformer) {
|
||||
return new IndexedCollection<K, C>(coll, keyTransformer,
|
||||
return new IndexedCollection<>(coll, keyTransformer,
|
||||
MultiValueMap.<K, C>multiValueMap(new HashMap<K, Collection<C>>()),
|
||||
true);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class IndexedCollection<K, C> extends AbstractCollectionDecorator<C> {
|
|||
*/
|
||||
public static <K, C> IndexedCollection<K, C> nonUniqueIndexedCollection(final Collection<C> coll,
|
||||
final Transformer<C, K> keyTransformer) {
|
||||
return new IndexedCollection<K, C>(coll, keyTransformer,
|
||||
return new IndexedCollection<>(coll, keyTransformer,
|
||||
MultiValueMap.<K, C>multiValueMap(new HashMap<K, Collection<C>>()),
|
||||
false);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
|
|||
* @since 4.1
|
||||
*/
|
||||
public static <E> Builder<E> builder(final Predicate<? super E> predicate) {
|
||||
return new Builder<E>(predicate);
|
||||
return new Builder<>(predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
|
|||
* @since 4.1
|
||||
*/
|
||||
public static <E> Builder<E> notNullBuilder() {
|
||||
return new Builder<E>(NotNullPredicate.<E>notNullPredicate());
|
||||
return new Builder<>(NotNullPredicate.<E>notNullPredicate());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,7 +103,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
|
|||
*/
|
||||
public static <T> PredicatedCollection<T> predicatedCollection(final Collection<T> coll,
|
||||
final Predicate<? super T> predicate) {
|
||||
return new PredicatedCollection<T>(coll, predicate);
|
||||
return new PredicatedCollection<>(coll, predicate);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -209,10 +209,10 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
|
|||
private final Predicate<? super E> predicate;
|
||||
|
||||
/** The buffer containing valid elements. */
|
||||
private final List<E> accepted = new ArrayList<E>();
|
||||
private final List<E> accepted = new ArrayList<>();
|
||||
|
||||
/** The buffer containing rejected elements. */
|
||||
private final List<E> rejected = new ArrayList<E>();
|
||||
private final List<E> rejected = new ArrayList<>();
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -58,7 +58,7 @@ public class SynchronizedCollection<E> implements Collection<E>, Serializable {
|
|||
* @since 4.0
|
||||
*/
|
||||
public static <T> SynchronizedCollection<T> synchronizedCollection(final Collection<T> coll) {
|
||||
return new SynchronizedCollection<T>(coll);
|
||||
return new SynchronizedCollection<>(coll);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -60,7 +60,7 @@ public class TransformedCollection<E> extends AbstractCollectionDecorator<E> {
|
|||
*/
|
||||
public static <E> TransformedCollection<E> transformingCollection(final Collection<E> coll,
|
||||
final Transformer<? super E, ? extends E> transformer) {
|
||||
return new TransformedCollection<E>(coll, transformer);
|
||||
return new TransformedCollection<>(coll, transformer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +81,7 @@ public class TransformedCollection<E> extends AbstractCollectionDecorator<E> {
|
|||
public static <E> TransformedCollection<E> transformedCollection(final Collection<E> collection,
|
||||
final Transformer<? super E, ? extends E> transformer) {
|
||||
|
||||
final TransformedCollection<E> decorated = new TransformedCollection<E>(collection, transformer);
|
||||
final TransformedCollection<E> decorated = new TransformedCollection<>(collection, transformer);
|
||||
// null collection & transformer are disallowed by the constructor call above
|
||||
if (collection.size() > 0) {
|
||||
@SuppressWarnings("unchecked") // collection is of type E
|
||||
|
@ -134,7 +134,7 @@ public class TransformedCollection<E> extends AbstractCollectionDecorator<E> {
|
|||
* @return a transformed object
|
||||
*/
|
||||
protected Collection<E> transform(final Collection<? extends E> coll) {
|
||||
final List<E> list = new ArrayList<E>(coll.size());
|
||||
final List<E> list = new ArrayList<>(coll.size());
|
||||
for (final E item : coll) {
|
||||
list.add(transform(item));
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
|
|||
final BoundedCollection<E> tmpColl = (BoundedCollection<E>) coll;
|
||||
return tmpColl;
|
||||
}
|
||||
return new UnmodifiableBoundedCollection<E>(coll);
|
||||
return new UnmodifiableBoundedCollection<>(coll);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,7 +98,7 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
|
|||
if (coll instanceof BoundedCollection == false) {
|
||||
throw new IllegalArgumentException("Collection is not a bounded collection.");
|
||||
}
|
||||
return new UnmodifiableBoundedCollection<E>((BoundedCollection<E>) coll);
|
||||
return new UnmodifiableBoundedCollection<>((BoundedCollection<E>) coll);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,7 +57,7 @@ public final class UnmodifiableCollection<E>
|
|||
final Collection<T> tmpColl = (Collection<T>) coll;
|
||||
return tmpColl;
|
||||
}
|
||||
return new UnmodifiableCollection<T>(coll);
|
||||
return new UnmodifiableCollection<>(coll);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -88,7 +88,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
|
|||
* @param reverse false = forward sort; true = reverse sort
|
||||
*/
|
||||
public ComparatorChain(final Comparator<E> comparator, final boolean reverse) {
|
||||
comparatorChain = new ArrayList<Comparator<E>>(1);
|
||||
comparatorChain = new ArrayList<>(1);
|
||||
comparatorChain.add(comparator);
|
||||
orderingBits = new BitSet(1);
|
||||
if (reverse == true) {
|
||||
|
|
|
@ -60,7 +60,7 @@ public class FixedOrderComparator<T> implements Comparator<T>, Serializable {
|
|||
}
|
||||
|
||||
/** Internal map of object to position */
|
||||
private final Map<T, Integer> map = new HashMap<T, Integer>();
|
||||
private final Map<T, Integer> map = new HashMap<>();
|
||||
|
||||
/** Counter used in determining the position in the map */
|
||||
private int counter = 0;
|
||||
|
|
|
@ -61,7 +61,7 @@ public final class AllPredicate<T> extends AbstractQuantifierPredicate<T> {
|
|||
return coerce(predicates[0]);
|
||||
}
|
||||
|
||||
return new AllPredicate<T>(FunctorUtils.copy(predicates));
|
||||
return new AllPredicate<>(FunctorUtils.copy(predicates));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ public final class AllPredicate<T> extends AbstractQuantifierPredicate<T> {
|
|||
if (preds.length == 1) {
|
||||
return coerce(preds[0]);
|
||||
}
|
||||
return new AllPredicate<T>(preds);
|
||||
return new AllPredicate<>(preds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class AndPredicate<T> implements PredicateDecorator<T>, Serializabl
|
|||
if (predicate1 == null || predicate2 == null) {
|
||||
throw new NullPointerException("Predicate must not be null");
|
||||
}
|
||||
return new AndPredicate<T>(predicate1, predicate2);
|
||||
return new AndPredicate<>(predicate1, predicate2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,7 +57,7 @@ public final class AnyPredicate<T> extends AbstractQuantifierPredicate<T> {
|
|||
if (predicates.length == 1) {
|
||||
return (Predicate<T>) predicates[0];
|
||||
}
|
||||
return new AnyPredicate<T>(FunctorUtils.copy(predicates));
|
||||
return new AnyPredicate<>(FunctorUtils.copy(predicates));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +81,7 @@ public final class AnyPredicate<T> extends AbstractQuantifierPredicate<T> {
|
|||
if (preds.length == 1) {
|
||||
return (Predicate<T>) preds[0];
|
||||
}
|
||||
return new AnyPredicate<T>(preds);
|
||||
return new AnyPredicate<>(preds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ChainedClosure<E> implements Closure<E>, Serializable {
|
|||
if (closures.length == 0) {
|
||||
return NOPClosure.<E>nopClosure();
|
||||
}
|
||||
return new ChainedClosure<E>(closures);
|
||||
return new ChainedClosure<>(closures);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,7 +78,7 @@ public class ChainedClosure<E> implements Closure<E>, Serializable {
|
|||
cmds[i++] = closure;
|
||||
}
|
||||
FunctorUtils.validate(cmds);
|
||||
return new ChainedClosure<E>(false, cmds);
|
||||
return new ChainedClosure<>(false, cmds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ChainedTransformer<T> implements Transformer<T, T>, Serializable {
|
|||
if (transformers.length == 0) {
|
||||
return NOPTransformer.<T>nopTransformer();
|
||||
}
|
||||
return new ChainedTransformer<T>(transformers);
|
||||
return new ChainedTransformer<>(transformers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,7 +78,7 @@ public class ChainedTransformer<T> implements Transformer<T, T>, Serializable {
|
|||
// convert to array like this to guarantee iterator() ordering
|
||||
final Transformer<T, T>[] cmds = transformers.toArray(new Transformer[transformers.size()]);
|
||||
FunctorUtils.validate(cmds);
|
||||
return new ChainedTransformer<T>(false, cmds);
|
||||
return new ChainedTransformer<>(false, cmds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,7 @@ public class CloneTransformer<T> implements Transformer<T, T> {
|
|||
|
||||
/** Singleton predicate instance */
|
||||
@SuppressWarnings("rawtypes") // the singleton instance works for all types
|
||||
public static final Transformer INSTANCE = new CloneTransformer<Object>();
|
||||
public static final Transformer INSTANCE = new CloneTransformer<>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ClosureTransformer<T> implements Transformer<T, T>, Serializable {
|
|||
if (closure == null) {
|
||||
throw new NullPointerException("Closure must not be null");
|
||||
}
|
||||
return new ClosureTransformer<T>(closure);
|
||||
return new ClosureTransformer<>(closure);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -126,7 +126,7 @@ public class ComparatorPredicate<T> implements Predicate<T>, Serializable {
|
|||
if (criterion == null) {
|
||||
throw new NullPointerException("Criterion must not be null.");
|
||||
}
|
||||
return new ComparatorPredicate<T>(object, comparator, criterion);
|
||||
return new ComparatorPredicate<>(object, comparator, criterion);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ConstantFactory<T> implements Factory<T>, Serializable {
|
|||
|
||||
/** Returns null each time */
|
||||
@SuppressWarnings("rawtypes") // The null factory works for all object types
|
||||
public static final Factory NULL_INSTANCE = new ConstantFactory<Object>(null);
|
||||
public static final Factory NULL_INSTANCE = new ConstantFactory<>(null);
|
||||
|
||||
/** The closures to call in turn */
|
||||
private final T iConstant;
|
||||
|
@ -54,7 +54,7 @@ public class ConstantFactory<T> implements Factory<T>, Serializable {
|
|||
if (constantToReturn == null) {
|
||||
return (Factory<T>) NULL_INSTANCE;
|
||||
}
|
||||
return new ConstantFactory<T>(constantToReturn);
|
||||
return new ConstantFactory<>(constantToReturn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ConstantTransformer<I, O> implements Transformer<I, O>, Serializabl
|
|||
|
||||
/** Returns null each time */
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final Transformer NULL_INSTANCE = new ConstantTransformer<Object, Object>(null);
|
||||
public static final Transformer NULL_INSTANCE = new ConstantTransformer<>(null);
|
||||
|
||||
/** The closures to call in turn */
|
||||
private final O iConstant;
|
||||
|
@ -66,7 +66,7 @@ public class ConstantTransformer<I, O> implements Transformer<I, O>, Serializabl
|
|||
if (constantToReturn == null) {
|
||||
return nullTransformer();
|
||||
}
|
||||
return new ConstantTransformer<I, O>(constantToReturn);
|
||||
return new ConstantTransformer<>(constantToReturn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,7 @@ public class DefaultEquator<T> implements Equator<T>, Serializable {
|
|||
|
||||
/** Static instance */
|
||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||
public static final DefaultEquator INSTANCE = new DefaultEquator<Object>();
|
||||
public static final DefaultEquator INSTANCE = new DefaultEquator<>();
|
||||
|
||||
/**
|
||||
* Hashcode used for <code>null</code> objects.
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class EqualPredicate<T> implements Predicate<T>, Serializable {
|
|||
if (object == null) {
|
||||
return NullPredicate.nullPredicate();
|
||||
}
|
||||
return new EqualPredicate<T>(object);
|
||||
return new EqualPredicate<>(object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ public final class EqualPredicate<T> implements Predicate<T>, Serializable {
|
|||
if (object == null) {
|
||||
return NullPredicate.nullPredicate();
|
||||
}
|
||||
return new EqualPredicate<T>(object, equator);
|
||||
return new EqualPredicate<>(object, equator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,7 +34,7 @@ public final class ExceptionClosure<E> implements Closure<E>, Serializable {
|
|||
|
||||
/** Singleton predicate instance */
|
||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||
public static final Closure INSTANCE = new ExceptionClosure<Object>();
|
||||
public static final Closure INSTANCE = new ExceptionClosure<>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -34,7 +34,7 @@ public final class ExceptionFactory<T> implements Factory<T>, Serializable {
|
|||
|
||||
/** Singleton predicate instance */
|
||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||
public static final Factory INSTANCE = new ExceptionFactory<Object>();
|
||||
public static final Factory INSTANCE = new ExceptionFactory<>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -34,7 +34,7 @@ public final class ExceptionPredicate<T> implements Predicate<T>, Serializable {
|
|||
|
||||
/** Singleton predicate instance */
|
||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||
public static final Predicate INSTANCE = new ExceptionPredicate<Object>();
|
||||
public static final Predicate INSTANCE = new ExceptionPredicate<>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -34,7 +34,7 @@ public final class ExceptionTransformer<I, O> implements Transformer<I, O>, Seri
|
|||
|
||||
/** Singleton predicate instance */
|
||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||
public static final Transformer INSTANCE = new ExceptionTransformer<Object, Object>();
|
||||
public static final Transformer INSTANCE = new ExceptionTransformer<>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -48,7 +48,7 @@ public class FactoryTransformer<I, O> implements Transformer<I, O>, Serializable
|
|||
if (factory == null) {
|
||||
throw new NullPointerException("Factory must not be null");
|
||||
}
|
||||
return new FactoryTransformer<I, O>(factory);
|
||||
return new FactoryTransformer<>(factory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class FalsePredicate<T> implements Predicate<T>, Serializable {
|
|||
|
||||
/** Singleton predicate instance */
|
||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||
public static final Predicate INSTANCE = new FalsePredicate<Object>();
|
||||
public static final Predicate INSTANCE = new FalsePredicate<>();
|
||||
|
||||
/**
|
||||
* Get a typed instance.
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ForClosure<E> implements Closure<E> {
|
|||
if (count == 1) {
|
||||
return (Closure<E>) closure;
|
||||
}
|
||||
return new ForClosure<E>(count, closure);
|
||||
return new ForClosure<>(count, closure);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class IdentityPredicate<T> implements Predicate<T>, Serializable {
|
|||
if (object == null) {
|
||||
return NullPredicate.<T>nullPredicate();
|
||||
}
|
||||
return new IdentityPredicate<T>(object);
|
||||
return new IdentityPredicate<>(object);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,7 +76,7 @@ public class IfClosure<E> implements Closure<E>, Serializable {
|
|||
if (trueClosure == null || falseClosure == null) {
|
||||
throw new NullPointerException("Closures must not be null");
|
||||
}
|
||||
return new IfClosure<E>(predicate, trueClosure, falseClosure);
|
||||
return new IfClosure<>(predicate, trueClosure, falseClosure);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -64,7 +64,7 @@ public class IfTransformer<I, O> implements Transformer<I, O>, Serializable {
|
|||
throw new NullPointerException("Transformers must not be null");
|
||||
}
|
||||
|
||||
return new IfTransformer<I, O>(predicate, trueTransformer, falseTransformer);
|
||||
return new IfTransformer<>(predicate, trueTransformer, falseTransformer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,7 +90,7 @@ public class IfTransformer<I, O> implements Transformer<I, O>, Serializable {
|
|||
throw new NullPointerException("Transformer must not be null");
|
||||
}
|
||||
|
||||
return new IfTransformer<T, T>(predicate, trueTransformer, NOPTransformer.<T>nopTransformer());
|
||||
return new IfTransformer<>(predicate, trueTransformer, NOPTransformer.<T>nopTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,9 +68,9 @@ public class InstantiateFactory<T> implements Factory<T> {
|
|||
}
|
||||
|
||||
if (paramTypes == null || paramTypes.length == 0) {
|
||||
return new InstantiateFactory<T>(classToInstantiate);
|
||||
return new InstantiateFactory<>(classToInstantiate);
|
||||
}
|
||||
return new InstantiateFactory<T>(classToInstantiate, paramTypes, args);
|
||||
return new InstantiateFactory<>(classToInstantiate, paramTypes, args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@ public class InstantiateTransformer<T> implements Transformer<Class<? extends T>
|
|||
|
||||
/** Singleton instance that uses the no arg constructor */
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static final Transformer NO_ARG_INSTANCE = new InstantiateTransformer<Object>();
|
||||
private static final Transformer NO_ARG_INSTANCE = new InstantiateTransformer<>();
|
||||
|
||||
/** The constructor parameter types */
|
||||
private final Class<?>[] iParamTypes;
|
||||
|
@ -73,9 +73,9 @@ public class InstantiateTransformer<T> implements Transformer<Class<? extends T>
|
|||
}
|
||||
|
||||
if (paramTypes == null || paramTypes.length == 0) {
|
||||
return new InstantiateTransformer<T>();
|
||||
return new InstantiateTransformer<>();
|
||||
}
|
||||
return new InstantiateTransformer<T>(paramTypes, args);
|
||||
return new InstantiateTransformer<>(paramTypes, args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,7 +56,7 @@ public class InvokerTransformer<I, O> implements Transformer<I, O> {
|
|||
if (methodName == null) {
|
||||
throw new NullPointerException("The method to invoke must not be null");
|
||||
}
|
||||
return new InvokerTransformer<I, O>(methodName);
|
||||
return new InvokerTransformer<>(methodName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,9 +82,9 @@ public class InvokerTransformer<I, O> implements Transformer<I, O> {
|
|||
throw new IllegalArgumentException("The parameter types must match the arguments");
|
||||
}
|
||||
if (paramTypes == null || paramTypes.length == 0) {
|
||||
return new InvokerTransformer<I, O>(methodName);
|
||||
return new InvokerTransformer<>(methodName);
|
||||
}
|
||||
return new InvokerTransformer<I, O>(methodName, paramTypes, args);
|
||||
return new InvokerTransformer<>(methodName, paramTypes, args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class MapTransformer<I, O> implements Transformer<I, O>, Serializab
|
|||
if (map == null) {
|
||||
return ConstantTransformer.<I, O>nullTransformer();
|
||||
}
|
||||
return new MapTransformer<I, O>(map);
|
||||
return new MapTransformer<>(map);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class NOPClosure<E> implements Closure<E>, Serializable {
|
|||
|
||||
/** Singleton predicate instance */
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final Closure INSTANCE = new NOPClosure<Object>();
|
||||
public static final Closure INSTANCE = new NOPClosure<>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -33,7 +33,7 @@ public class NOPTransformer<T> implements Transformer<T, T>, Serializable {
|
|||
|
||||
/** Singleton predicate instance */
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final Transformer INSTANCE = new NOPTransformer<Object>();
|
||||
public static final Transformer INSTANCE = new NOPTransformer<>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -52,7 +52,7 @@ public final class NonePredicate<T> extends AbstractQuantifierPredicate<T> {
|
|||
if (predicates.length == 0) {
|
||||
return TruePredicate.<T>truePredicate();
|
||||
}
|
||||
return new NonePredicate<T>(FunctorUtils.copy(predicates));
|
||||
return new NonePredicate<>(FunctorUtils.copy(predicates));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ public final class NonePredicate<T> extends AbstractQuantifierPredicate<T> {
|
|||
if (preds.length == 0) {
|
||||
return TruePredicate.<T>truePredicate();
|
||||
}
|
||||
return new NonePredicate<T>(preds);
|
||||
return new NonePredicate<>(preds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class NotNullPredicate<T> implements Predicate<T>, Serializable {
|
|||
|
||||
/** Singleton predicate instance */
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final Predicate INSTANCE = new NotNullPredicate<Object>();
|
||||
public static final Predicate INSTANCE = new NotNullPredicate<>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class NotPredicate<T> implements PredicateDecorator<T>, Serializabl
|
|||
if (predicate == null) {
|
||||
throw new NullPointerException("Predicate must not be null");
|
||||
}
|
||||
return new NotPredicate<T>(predicate);
|
||||
return new NotPredicate<>(predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,7 +47,7 @@ public final class NullIsExceptionPredicate<T> implements PredicateDecorator<T>,
|
|||
if (predicate == null) {
|
||||
throw new NullPointerException("Predicate must not be null");
|
||||
}
|
||||
return new NullIsExceptionPredicate<T>(predicate);
|
||||
return new NullIsExceptionPredicate<>(predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class NullIsFalsePredicate<T> implements PredicateDecorator<T>, Ser
|
|||
if (predicate == null) {
|
||||
throw new NullPointerException("Predicate must not be null");
|
||||
}
|
||||
return new NullIsFalsePredicate<T>(predicate);
|
||||
return new NullIsFalsePredicate<>(predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class NullIsTruePredicate<T> implements PredicateDecorator<T>, Seri
|
|||
if (predicate == null) {
|
||||
throw new NullPointerException("Predicate must not be null");
|
||||
}
|
||||
return new NullIsTruePredicate<T>(predicate);
|
||||
return new NullIsTruePredicate<>(predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class NullPredicate<T> implements Predicate<T>, Serializable {
|
|||
|
||||
/** Singleton predicate instance */
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final Predicate INSTANCE = new NullPredicate<Object>();
|
||||
public static final Predicate INSTANCE = new NullPredicate<>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -57,7 +57,7 @@ public final class OnePredicate<T> extends AbstractQuantifierPredicate<T> {
|
|||
if (predicates.length == 1) {
|
||||
return (Predicate<T>) predicates[0];
|
||||
}
|
||||
return new OnePredicate<T>(FunctorUtils.copy(predicates));
|
||||
return new OnePredicate<>(FunctorUtils.copy(predicates));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ public final class OnePredicate<T> extends AbstractQuantifierPredicate<T> {
|
|||
*/
|
||||
public static <T> Predicate<T> onePredicate(final Collection<? extends Predicate<? super T>> predicates) {
|
||||
final Predicate<? super T>[] preds = FunctorUtils.validate(predicates);
|
||||
return new OnePredicate<T>(preds);
|
||||
return new OnePredicate<>(preds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class OrPredicate<T> implements PredicateDecorator<T>, Serializable
|
|||
if (predicate1 == null || predicate2 == null) {
|
||||
throw new NullPointerException("Predicate must not be null");
|
||||
}
|
||||
return new OrPredicate<T>(predicate1, predicate2);
|
||||
return new OrPredicate<>(predicate1, predicate2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,7 +48,7 @@ public class PredicateTransformer<T> implements Transformer<T, Boolean>, Seriali
|
|||
if (predicate == null) {
|
||||
throw new IllegalArgumentException("Predicate must not be null");
|
||||
}
|
||||
return new PredicateTransformer<T>(predicate);
|
||||
return new PredicateTransformer<>(predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,18 +67,18 @@ public class PrototypeFactory {
|
|||
}
|
||||
try {
|
||||
final Method method = prototype.getClass().getMethod("clone", (Class[]) null);
|
||||
return new PrototypeCloneFactory<T>(prototype, method);
|
||||
return new PrototypeCloneFactory<>(prototype, method);
|
||||
|
||||
} catch (final NoSuchMethodException ex) {
|
||||
try {
|
||||
prototype.getClass().getConstructor(new Class<?>[] { prototype.getClass() });
|
||||
return new InstantiateFactory<T>(
|
||||
return new InstantiateFactory<>(
|
||||
(Class<T>) prototype.getClass(),
|
||||
new Class<?>[] { prototype.getClass() },
|
||||
new Object[] { prototype });
|
||||
} catch (final NoSuchMethodException ex2) {
|
||||
if (prototype instanceof Serializable) {
|
||||
return (Factory<T>) new PrototypeSerializationFactory<Serializable>((Serializable) prototype);
|
||||
return (Factory<T>) new PrototypeSerializationFactory<>((Serializable) prototype);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class StringValueTransformer<T> implements Transformer<T, String>,
|
|||
private static final long serialVersionUID = 7511110693171758606L;
|
||||
|
||||
/** Singleton predicate instance */
|
||||
private static final Transformer<Object, String> INSTANCE = new StringValueTransformer<Object>();
|
||||
private static final Transformer<Object, String> INSTANCE = new StringValueTransformer<>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -65,7 +65,7 @@ public class SwitchClosure<E> implements Closure<E>, Serializable {
|
|||
if (predicates.length == 0) {
|
||||
return (Closure<E>) (defaultClosure == null ? NOPClosure.<E>nopClosure(): defaultClosure);
|
||||
}
|
||||
return new SwitchClosure<E>(predicates, closures, defaultClosure);
|
||||
return new SwitchClosure<>(predicates, closures, defaultClosure);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,7 +105,7 @@ public class SwitchClosure<E> implements Closure<E>, Serializable {
|
|||
closures[i] = entry.getValue();
|
||||
i++;
|
||||
}
|
||||
return new SwitchClosure<E>(false, preds, closures, defaultClosure);
|
||||
return new SwitchClosure<>(false, preds, closures, defaultClosure);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,7 +66,7 @@ public class SwitchTransformer<I, O> implements Transformer<I, O>, Serializable
|
|||
return (Transformer<I, O>) (defaultTransformer == null ? ConstantTransformer.<I, O>nullTransformer() :
|
||||
defaultTransformer);
|
||||
}
|
||||
return new SwitchTransformer<I, O>(predicates, transformers, defaultTransformer);
|
||||
return new SwitchTransformer<>(predicates, transformers, defaultTransformer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ public class SwitchTransformer<I, O> implements Transformer<I, O>, Serializable
|
|||
transformers[i] = entry.getValue();
|
||||
i++;
|
||||
}
|
||||
return new SwitchTransformer<I, O>(false, preds, transformers, defaultTransformer);
|
||||
return new SwitchTransformer<>(false, preds, transformers, defaultTransformer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,7 +56,7 @@ public final class TransformedPredicate<T> implements PredicateDecorator<T>, Ser
|
|||
if (predicate == null) {
|
||||
throw new NullPointerException("The predicate to call must not be null");
|
||||
}
|
||||
return new TransformedPredicate<T>(transformer, predicate);
|
||||
return new TransformedPredicate<>(transformer, predicate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TransformerClosure<E> implements Closure<E>, Serializable {
|
|||
if (transformer == null) {
|
||||
return NOPClosure.<E>nopClosure();
|
||||
}
|
||||
return new TransformerClosure<E>(transformer);
|
||||
return new TransformerClosure<>(transformer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,7 +48,7 @@ public final class TransformerPredicate<T> implements Predicate<T>, Serializable
|
|||
if (transformer == null) {
|
||||
throw new NullPointerException("The transformer to call must not be null");
|
||||
}
|
||||
return new TransformerPredicate<T>(transformer);
|
||||
return new TransformerPredicate<>(transformer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class TruePredicate<T> implements Predicate<T>, Serializable {
|
|||
|
||||
/** Singleton predicate instance */
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final Predicate INSTANCE = new TruePredicate<Object>();
|
||||
public static final Predicate INSTANCE = new TruePredicate<>();
|
||||
|
||||
/**
|
||||
* Factory returning the singleton instance.
|
||||
|
|
|
@ -35,7 +35,7 @@ public final class UniquePredicate<T> implements Predicate<T>, Serializable {
|
|||
private static final long serialVersionUID = -3319417438027438040L;
|
||||
|
||||
/** The set of previously seen objects */
|
||||
private final Set<T> iSet = new HashSet<T>();
|
||||
private final Set<T> iSet = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Factory to create the predicate.
|
||||
|
@ -45,7 +45,7 @@ public final class UniquePredicate<T> implements Predicate<T>, Serializable {
|
|||
* @throws IllegalArgumentException if the predicate is null
|
||||
*/
|
||||
public static <T> Predicate<T> uniquePredicate() {
|
||||
return new UniquePredicate<T>();
|
||||
return new UniquePredicate<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,7 +58,7 @@ public class WhileClosure<E> implements Closure<E> {
|
|||
if (closure == null) {
|
||||
throw new NullPointerException("Closure must not be null");
|
||||
}
|
||||
return new WhileClosure<E>(predicate, closure, doLoop);
|
||||
return new WhileClosure<>(predicate, closure, doLoop);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -95,7 +95,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
* child iterators
|
||||
*/
|
||||
public CollatingIterator(final Comparator<? super E> comp, final int initIterCapacity) {
|
||||
iterators = new ArrayList<Iterator<? extends E>>(initIterCapacity);
|
||||
iterators = new ArrayList<>(initIterCapacity);
|
||||
setComparator(comp);
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
*/
|
||||
private void start() {
|
||||
if (values == null) {
|
||||
values = new ArrayList<E>(iterators.size());
|
||||
values = new ArrayList<>(iterators.size());
|
||||
valueSet = new BitSet(iterators.size());
|
||||
for (int i = 0; i < iterators.size(); i++) {
|
||||
values.add(null);
|
||||
|
|
|
@ -37,7 +37,7 @@ public class EmptyIterator<E> extends AbstractEmptyIterator<E> implements Resett
|
|||
* @since 3.1
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final ResettableIterator RESETTABLE_INSTANCE = new EmptyIterator<Object>();
|
||||
public static final ResettableIterator RESETTABLE_INSTANCE = new EmptyIterator<>();
|
||||
|
||||
/**
|
||||
* Singleton instance of the iterator.
|
||||
|
|
|
@ -38,7 +38,7 @@ public class EmptyListIterator<E> extends AbstractEmptyIterator<E> implements
|
|||
* @since 3.1
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final ResettableListIterator RESETTABLE_INSTANCE = new EmptyListIterator<Object>();
|
||||
public static final ResettableListIterator RESETTABLE_INSTANCE = new EmptyListIterator<>();
|
||||
|
||||
/**
|
||||
* Singleton instance of the iterator.
|
||||
|
|
|
@ -33,7 +33,7 @@ public class EmptyMapIterator<K, V> extends AbstractEmptyMapIterator<K, V> imple
|
|||
* @since 3.1
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final MapIterator INSTANCE = new EmptyMapIterator<Object, Object>();
|
||||
public static final MapIterator INSTANCE = new EmptyMapIterator<>();
|
||||
|
||||
/**
|
||||
* Get a typed instance of the iterator.
|
||||
|
|
|
@ -33,7 +33,7 @@ public class EmptyOrderedIterator<E> extends AbstractEmptyIterator<E>
|
|||
* @since 3.1
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final OrderedIterator INSTANCE = new EmptyOrderedIterator<Object>();
|
||||
public static final OrderedIterator INSTANCE = new EmptyOrderedIterator<>();
|
||||
|
||||
/**
|
||||
* Typed instance of the iterator.
|
||||
|
|
|
@ -33,7 +33,7 @@ public class EmptyOrderedMapIterator<K, V> extends AbstractEmptyMapIterator<K, V
|
|||
* @since 3.1
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final OrderedMapIterator INSTANCE = new EmptyOrderedMapIterator<Object, Object>();
|
||||
public static final OrderedMapIterator INSTANCE = new EmptyOrderedMapIterator<>();
|
||||
|
||||
/**
|
||||
* Get a typed instance of the iterator.
|
||||
|
|
|
@ -51,7 +51,7 @@ import java.util.Queue;
|
|||
public class IteratorChain<E> implements Iterator<E> {
|
||||
|
||||
/** The chain of iterators */
|
||||
private final Queue<Iterator<? extends E>> iteratorChain = new LinkedList<Iterator<? extends E>>();
|
||||
private final Queue<Iterator<? extends E>> iteratorChain = new LinkedList<>();
|
||||
|
||||
/** The current iterator */
|
||||
private Iterator<? extends E> currentIterator = null;
|
||||
|
|
|
@ -111,7 +111,7 @@ public class IteratorIterable<E> implements Iterable<E> {
|
|||
public IteratorIterable(final Iterator<? extends E> iterator, final boolean multipleUse) {
|
||||
super();
|
||||
if (multipleUse && !(iterator instanceof ResettableIterator)) {
|
||||
this.iterator = new ListIteratorWrapper<E>(iterator);
|
||||
this.iterator = new ListIteratorWrapper<>(iterator);
|
||||
} else {
|
||||
this.iterator = iterator;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ListIteratorWrapper<E> implements ResettableListIterator<E> {
|
|||
/** The underlying iterator being decorated. */
|
||||
private final Iterator<? extends E> iterator;
|
||||
/** The list being used to cache the iterator. */
|
||||
private final List<E> list = new ArrayList<E>();
|
||||
private final List<E> list = new ArrayList<>();
|
||||
|
||||
/** The current index of this iterator. */
|
||||
private int currentIndex = 0;
|
||||
|
|
|
@ -77,7 +77,7 @@ import org.apache.commons.collections4.Transformer;
|
|||
public class ObjectGraphIterator<E> implements Iterator<E> {
|
||||
|
||||
/** The stack of iterators */
|
||||
private final Deque<Iterator<? extends E>> stack = new ArrayDeque<Iterator<? extends E>>(8);
|
||||
private final Deque<Iterator<? extends E>> stack = new ArrayDeque<>(8);
|
||||
/** The root object in the tree */
|
||||
private E root;
|
||||
/** The transformer to use */
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue