diff --git a/src/main/java/org/apache/commons/collections4/BagUtils.java b/src/main/java/org/apache/commons/collections4/BagUtils.java index c0e39634f..ac60e4757 100644 --- a/src/main/java/org/apache/commons/collections4/BagUtils.java +++ b/src/main/java/org/apache/commons/collections4/BagUtils.java @@ -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()); + 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()); + UnmodifiableSortedBag.unmodifiableSortedBag(new TreeBag<>()); /** * Instantiation of BagUtils is not intended or required. diff --git a/src/main/java/org/apache/commons/collections4/CollectionUtils.java b/src/main/java/org/apache/commons/collections4/CollectionUtils.java index 5bab383df..fb99785a8 100644 --- a/src/main/java/org/apache/commons/collections4/CollectionUtils.java +++ b/src/main/java/org/apache/commons/collections4/CollectionUtils.java @@ -140,11 +140,11 @@ public class CollectionUtils { */ public SetOperationCardinalityHelper(final Iterable a, final Iterable b) { super(a, b); - elements = new HashSet(); + 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(elements.size()); + newList = new ArrayList<>(elements.size()); } @Override @@ -228,7 +228,7 @@ public class CollectionUtils { * @see Collection#addAll */ public static Collection union(final Iterable a, final Iterable b) { - final SetOperationCardinalityHelper helper = new SetOperationCardinalityHelper(a, b); + final SetOperationCardinalityHelper 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 Collection intersection(final Iterable a, final Iterable b) { - final SetOperationCardinalityHelper helper = new SetOperationCardinalityHelper(a, b); + final SetOperationCardinalityHelper 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 Collection disjunction(final Iterable a, final Iterable b) { - final SetOperationCardinalityHelper helper = new SetOperationCardinalityHelper(a, b); + final SetOperationCardinalityHelper 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 Collection subtract(final Iterable a, final Iterable b, final Predicate p) { - final ArrayList list = new ArrayList(); - final HashBag bag = new HashBag(); + final ArrayList list = new ArrayList<>(); + final HashBag 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 elementsAlreadySeen = new HashSet(); + final Set 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 Map getCardinalityMap(final Iterable coll) { - final Map count = new HashMap(); + final Map 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 helper = new CardinalityHelper(a, b); + final CardinalityHelper 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 helper = new CardinalityHelper(a, b); + final CardinalityHelper 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 iterator = new CollatingIterator(c, a.iterator(), b.iterator()); + final Iterator iterator = new CollatingIterator<>(c, a.iterator(), b.iterator()); if (includeDuplicates) { return IteratorUtils.toList(iterator, totalSize); } else { - final ArrayList mergedList = new ArrayList(totalSize); + final ArrayList mergedList = new ArrayList<>(totalSize); O lastItem = null; while (iterator.hasNext()) { @@ -1623,8 +1623,8 @@ public class CollectionUtils { * @since 4.0 */ public static Collection> permutations(final Collection collection) { - final PermutationIterator it = new PermutationIterator(collection); - final Collection> result = new ArrayList>(); + final PermutationIterator it = new PermutationIterator<>(collection); + final Collection> result = new ArrayList<>(); while (it.hasNext()) { result.add(it.next()); } @@ -1690,16 +1690,16 @@ public class CollectionUtils { final Transformer> transformer = new Transformer>() { @Override public EquatorWrapper transform(E input) { - return new EquatorWrapper(equator, input); + return new EquatorWrapper<>(equator, input); } }; final Set> retainSet = collect(retain, transformer, new HashSet>()); - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final E element : collection) { - if (retainSet.contains(new EquatorWrapper(equator, element))) { + if (retainSet.contains(new EquatorWrapper<>(equator, element))) { list.add(element); } } @@ -1766,16 +1766,16 @@ public class CollectionUtils { final Transformer> transformer = new Transformer>() { @Override public EquatorWrapper transform(E input) { - return new EquatorWrapper(equator, input); + return new EquatorWrapper<>(equator, input); } }; final Set> removeSet = collect(remove, transformer, new HashSet>()); - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final E element : collection) { - if (!removeSet.contains(new EquatorWrapper(equator, element))) { + if (!removeSet.contains(new EquatorWrapper<>(equator, element))) { list.add(element); } } diff --git a/src/main/java/org/apache/commons/collections4/ComparatorUtils.java b/src/main/java/org/apache/commons/collections4/ComparatorUtils.java index e17a3d837..fa7da4339 100644 --- a/src/main/java/org/apache/commons/collections4/ComparatorUtils.java +++ b/src/main/java/org/apache/commons/collections4/ComparatorUtils.java @@ -75,7 +75,7 @@ public class ComparatorUtils { * @see ComparatorChain */ public static Comparator chainedComparator(final Comparator... comparators) { - final ComparatorChain chain = new ComparatorChain(); + final ComparatorChain chain = new ComparatorChain<>(); for (final Comparator comparator : comparators) { if (comparator == null) { throw new NullPointerException("Comparator cannot be null"); @@ -113,7 +113,7 @@ public class ComparatorUtils { * @see ReverseComparator */ public static Comparator reversedComparator(final Comparator comparator) { - return new ReverseComparator(comparator); + return new ReverseComparator<>(comparator); } /** @@ -149,7 +149,7 @@ public class ComparatorUtils { if (comparator == null) { comparator = NATURAL_COMPARATOR; } - return new NullComparator(comparator, false); + return new NullComparator<>(comparator, false); } /** @@ -169,7 +169,7 @@ public class ComparatorUtils { if (comparator == null) { comparator = NATURAL_COMPARATOR; } - return new NullComparator(comparator, true); + return new NullComparator<>(comparator, true); } /** @@ -193,7 +193,7 @@ public class ComparatorUtils { if (comparator == null) { comparator = NATURAL_COMPARATOR; } - return new TransformingComparator(transformer, comparator); + return new TransformingComparator<>(transformer, comparator); } /** diff --git a/src/main/java/org/apache/commons/collections4/EnumerationUtils.java b/src/main/java/org/apache/commons/collections4/EnumerationUtils.java index 69aa63fd6..301abec2b 100644 --- a/src/main/java/org/apache/commons/collections4/EnumerationUtils.java +++ b/src/main/java/org/apache/commons/collections4/EnumerationUtils.java @@ -77,7 +77,7 @@ public class EnumerationUtils { * @throws NullPointerException if the enumeration parameter is null. */ public static List toList(final Enumeration enumeration) { - return IteratorUtils.toList(new EnumerationIterator(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 toList(final StringTokenizer stringTokenizer) { - final List result = new ArrayList(stringTokenizer.countTokens()); + final List result = new ArrayList<>(stringTokenizer.countTokens()); while (stringTokenizer.hasMoreTokens()) { result.add(stringTokenizer.nextToken()); } diff --git a/src/main/java/org/apache/commons/collections4/FluentIterable.java b/src/main/java/org/apache/commons/collections4/FluentIterable.java index 49005989f..b6de3c015 100644 --- a/src/main/java/org/apache/commons/collections4/FluentIterable.java +++ b/src/main/java/org/apache/commons/collections4/FluentIterable.java @@ -92,7 +92,7 @@ public class FluentIterable implements Iterable { * @return a new FluentIterable containing the singleton */ public static FluentIterable of(final T singleton) { - return of(IteratorUtils.asIterable(new SingletonIterator(singleton, false))); + return of(IteratorUtils.asIterable(new SingletonIterator<>(singleton, false))); } /** @@ -126,7 +126,7 @@ public class FluentIterable implements Iterable { if (iterable instanceof FluentIterable) { return (FluentIterable) iterable; } else { - return new FluentIterable(iterable); + return new FluentIterable<>(iterable); } } diff --git a/src/main/java/org/apache/commons/collections4/IterableUtils.java b/src/main/java/org/apache/commons/collections4/IterableUtils.java index 845332ea9..d7ec92c27 100644 --- a/src/main/java/org/apache/commons/collections4/IterableUtils.java +++ b/src/main/java/org/apache/commons/collections4/IterableUtils.java @@ -365,7 +365,7 @@ public class IterableUtils { final List list = (iterable instanceof List) ? (List) iterable : IteratorUtils.toList(iterable.iterator()); - return new ReverseListIterator(list); + return new ReverseListIterator<>(list); } }; } @@ -451,7 +451,7 @@ public class IterableUtils { return new FluentIterable() { @Override public Iterator iterator() { - return new UniqueFilterIterator(iterable.iterator()); + return new UniqueFilterIterator<>(iterable.iterator()); } }; } @@ -474,7 +474,7 @@ public class IterableUtils { if (iterable instanceof UnmodifiableIterable) { return iterable; } - return new UnmodifiableIterable(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 partitions = new ArrayList(numberOfPartitions); + final List partitions = new ArrayList<>(numberOfPartitions); for (int i = 0; i < numberOfPartitions; ++i) { partitions.add(partitionFactory.create()); } diff --git a/src/main/java/org/apache/commons/collections4/IteratorUtils.java b/src/main/java/org/apache/commons/collections4/IteratorUtils.java index 6a7e354d5..c603b7cff 100644 --- a/src/main/java/org/apache/commons/collections4/IteratorUtils.java +++ b/src/main/java/org/apache/commons/collections4/IteratorUtils.java @@ -208,7 +208,7 @@ public class IteratorUtils { * @return a singleton iterator over the object */ public static ResettableIterator singletonIterator(final E object) { - return new SingletonIterator(object); + return new SingletonIterator<>(object); } /** @@ -222,7 +222,7 @@ public class IteratorUtils { * @return a singleton list iterator over the object */ public static ListIterator singletonListIterator(final E object) { - return new SingletonListIterator(object); + return new SingletonListIterator<>(object); } // Arrays @@ -236,7 +236,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableIterator arrayIterator(final E... array) { - return new ObjectArrayIterator(array); + return new ObjectArrayIterator<>(array); } /** @@ -252,7 +252,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableIterator arrayIterator(final Object array) { - return new ArrayIterator(array); + return new ArrayIterator<>(array); } /** @@ -267,7 +267,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableIterator arrayIterator(final E[] array, final int start) { - return new ObjectArrayIterator(array, start); + return new ObjectArrayIterator<>(array, start); } /** @@ -286,7 +286,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableIterator arrayIterator(final Object array, final int start) { - return new ArrayIterator(array, start); + return new ArrayIterator<>(array, start); } /** @@ -302,7 +302,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableIterator arrayIterator(final E[] array, final int start, final int end) { - return new ObjectArrayIterator(array, start, end); + return new ObjectArrayIterator<>(array, start, end); } /** @@ -321,7 +321,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableIterator arrayIterator(final Object array, final int start, final int end) { - return new ArrayIterator(array, start, end); + return new ArrayIterator<>(array, start, end); } //----------------------------------------------------------------------- @@ -334,7 +334,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableListIterator arrayListIterator(final E... array) { - return new ObjectArrayListIterator(array); + return new ObjectArrayListIterator<>(array); } /** @@ -350,7 +350,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableListIterator arrayListIterator(final Object array) { - return new ArrayListIterator(array); + return new ArrayListIterator<>(array); } /** @@ -364,7 +364,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableListIterator arrayListIterator(final E[] array, final int start) { - return new ObjectArrayListIterator(array, start); + return new ObjectArrayListIterator<>(array, start); } /** @@ -382,7 +382,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableListIterator arrayListIterator(final Object array, final int start) { - return new ArrayListIterator(array, start); + return new ArrayListIterator<>(array, start); } /** @@ -398,7 +398,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableListIterator arrayListIterator(final E[] array, final int start, final int end) { - return new ObjectArrayListIterator(array, start, end); + return new ObjectArrayListIterator<>(array, start, end); } /** @@ -417,7 +417,7 @@ public class IteratorUtils { * @throws NullPointerException if array is null */ public static ResettableListIterator arrayListIterator(final Object array, final int start, final int end) { - return new ArrayListIterator(array, start, end); + return new ArrayListIterator<>(array, start, end); } // Bounded @@ -457,7 +457,7 @@ public class IteratorUtils { */ public static BoundedIterator boundedIterator(final Iterator iterator, long offset, long max) { - return new BoundedIterator(iterator, offset, max); + return new BoundedIterator<>(iterator, offset, max); } // Unmodifiable @@ -520,7 +520,7 @@ public class IteratorUtils { final Iterator 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(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 Iterator chainedIterator(final Iterator... iterators) { - return new IteratorChain(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 Iterator chainedIterator(final Collection> iterators) { - return new IteratorChain(iterators); + return new IteratorChain<>(iterators); } // Collated @@ -575,7 +575,7 @@ public class IteratorUtils { @SuppressWarnings("unchecked") final Comparator comp = comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator) comparator; - return new CollatingIterator(comp, iterator1, iterator2); + return new CollatingIterator<>(comp, iterator1, iterator2); } /** @@ -599,7 +599,7 @@ public class IteratorUtils { @SuppressWarnings("unchecked") final Comparator comp = comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator) comparator; - return new CollatingIterator(comp, iterators); + return new CollatingIterator<>(comp, iterators); } /** @@ -624,7 +624,7 @@ public class IteratorUtils { @SuppressWarnings("unchecked") final Comparator comp = comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator) comparator; - return new CollatingIterator(comp, iterators); + return new CollatingIterator<>(comp, iterators); } // Object Graph @@ -685,7 +685,7 @@ public class IteratorUtils { */ public static Iterator objectGraphIterator(final E root, final Transformer transformer) { - return new ObjectGraphIterator(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(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(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(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(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(list); + return new LoopingListIterator<>(list); } // org.w3c.dom.NodeList iterators @@ -892,7 +892,7 @@ public class IteratorUtils { * @since 4.1 */ public static SkippingIterator skippingIterator(final Iterator iterator, long offset) { - return new SkippingIterator(iterator, offset); + return new SkippingIterator<>(iterator, offset); } // Zipping @@ -909,7 +909,7 @@ public class IteratorUtils { */ public static ZippingIterator zippingIterator(final Iterator a, final Iterator b) { - return new ZippingIterator(a, b); + return new ZippingIterator<>(a, b); } /** @@ -926,7 +926,7 @@ public class IteratorUtils { public static ZippingIterator zippingIterator(final Iterator a, final Iterator b, final Iterator c) { - return new ZippingIterator(a, b, c); + return new ZippingIterator<>(a, b, c); } /** @@ -939,7 +939,7 @@ public class IteratorUtils { * @since 4.1 */ public static ZippingIterator zippingIterator(final Iterator... iterators) { - return new ZippingIterator(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(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(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(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(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(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(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 list = new ArrayList(estimatedSize); + final List 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[]) obj); + return new ObjectArrayIterator<>((Object[]) obj); } if (obj instanceof Enumeration) { - return new EnumerationIterator((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(((Dictionary) obj).elements()); + return new EnumerationIterator<>(((Dictionary) obj).elements()); } else if (obj.getClass().isArray()) { - return new ArrayIterator(obj); + return new ArrayIterator<>(obj); } try { final Method method = obj.getClass().getMethod("iterator", (Class[]) null); diff --git a/src/main/java/org/apache/commons/collections4/ListUtils.java b/src/main/java/org/apache/commons/collections4/ListUtils.java index 3b0e7bc28..8daf118f2 100644 --- a/src/main/java/org/apache/commons/collections4/ListUtils.java +++ b/src/main/java/org/apache/commons/collections4/ListUtils.java @@ -87,7 +87,7 @@ public class ListUtils { * @throws NullPointerException if either list is null */ public static List intersection(final List list1, final List list2) { - final List result = new ArrayList(); + final List result = new ArrayList<>(); List smaller = list1; List larger = list2; @@ -96,7 +96,7 @@ public class ListUtils { larger = list1; } - final HashSet hashSet = new HashSet(smaller); + final HashSet 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 List subtract(final List list1, final List list2) { - final ArrayList result = new ArrayList(); - final HashBag bag = new HashBag(list2); + final ArrayList result = new ArrayList<>(); + final HashBag 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 List union(final List list1, final List list2) { - final ArrayList result = new ArrayList(list1); + final ArrayList result = new ArrayList<>(list1); result.addAll(list2); return result; } @@ -309,7 +309,7 @@ public class ListUtils { * @since 3.2 */ public static List retainAll(final Collection collection, final Collection retain) { - final List list = new ArrayList(Math.min(collection.size(), retain.size())); + final List 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 List removeAll(final Collection collection, final Collection remove) { - final List list = new ArrayList(); + final List 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 comparator = new SequencesComparator(a, b, equator); + final SequencesComparator comparator = new SequencesComparator<>(a, b, equator); final EditScript script = comparator.getScript(); - final LcsVisitor visitor = new LcsVisitor(); + final LcsVisitor visitor = new LcsVisitor<>(); script.visit(visitor); return visitor.getSubSequence(); } @@ -583,7 +583,7 @@ public class ListUtils { private final ArrayList sequence; public LcsVisitor() { - sequence = new ArrayList(); + 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(list, size); + return new Partition<>(list, size); } /** diff --git a/src/main/java/org/apache/commons/collections4/MapUtils.java b/src/main/java/org/apache/commons/collections4/MapUtils.java index 2b0c65c2d..c11437eb6 100644 --- a/src/main/java/org/apache/commons/collections4/MapUtils.java +++ b/src/main/java/org/apache/commons/collections4/MapUtils.java @@ -85,7 +85,7 @@ public class MapUtils { */ @SuppressWarnings("rawtypes") public static final SortedMap EMPTY_SORTED_MAP = - UnmodifiableSortedMap.unmodifiableSortedMap(new TreeMap()); + UnmodifiableSortedMap.unmodifiableSortedMap(new TreeMap<>()); /** * String used to indent the verbose and debug Map prints. @@ -888,7 +888,7 @@ public class MapUtils { */ public static Map toMap(final ResourceBundle resourceBundle) { final Enumeration enumeration = resourceBundle.getKeys(); - final Map map = new HashMap(); + final Map 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 Map invertMap(final Map map) { - final Map out = new HashMap(map.size()); + final Map out = new HashMap<>(map.size()); for (final Entry entry : map.entrySet()) { out.put(entry.getValue(), entry.getKey()); } diff --git a/src/main/java/org/apache/commons/collections4/MultiMapUtils.java b/src/main/java/org/apache/commons/collections4/MultiMapUtils.java index 5fdee52c1..928a2f9ad 100644 --- a/src/main/java/org/apache/commons/collections4/MultiMapUtils.java +++ b/src/main/java/org/apache/commons/collections4/MultiMapUtils.java @@ -132,7 +132,7 @@ public class MultiMapUtils { if (col instanceof List) { return (List) col; } - return new ArrayList(col); + return new ArrayList<>(col); } return null; } @@ -152,7 +152,7 @@ public class MultiMapUtils { if (col instanceof Set) { return (Set) col; } - return new HashSet(col); + return new HashSet<>(col); } return null; } @@ -172,7 +172,7 @@ public class MultiMapUtils { if (col instanceof Bag) { return (Bag) col; } - return new HashBag(col); + return new HashBag<>(col); } return null; } @@ -189,7 +189,7 @@ public class MultiMapUtils { * @return a new ListValuedMap */ public static ListValuedMap newListValuedHashMap() { - return new ArrayListValuedHashMap(); + return new ArrayListValuedHashMap<>(); } /** @@ -201,7 +201,7 @@ public class MultiMapUtils { * @return a new {@link SetValuedMap} */ public static SetValuedMap newSetValuedHashMap() { - return new HashSetValuedHashMap(); + return new HashSetValuedHashMap<>(); } // MultiValuedMap Decorators diff --git a/src/main/java/org/apache/commons/collections4/MultiSetUtils.java b/src/main/java/org/apache/commons/collections4/MultiSetUtils.java index a88a3e046..aa5078e67 100644 --- a/src/main/java/org/apache/commons/collections4/MultiSetUtils.java +++ b/src/main/java/org/apache/commons/collections4/MultiSetUtils.java @@ -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()); + UnmodifiableMultiSet.unmodifiableMultiSet(new HashMultiSet<>()); /** * Instantiation of MultiSetUtils is not intended or required. diff --git a/src/main/java/org/apache/commons/collections4/QueueUtils.java b/src/main/java/org/apache/commons/collections4/QueueUtils.java index d31770854..7c1d62e97 100644 --- a/src/main/java/org/apache/commons/collections4/QueueUtils.java +++ b/src/main/java/org/apache/commons/collections4/QueueUtils.java @@ -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()); + public static final Queue EMPTY_QUEUE = UnmodifiableQueue.unmodifiableQueue(new LinkedList<>()); /** * QueueUtils should not normally be instantiated. diff --git a/src/main/java/org/apache/commons/collections4/SetUtils.java b/src/main/java/org/apache/commons/collections4/SetUtils.java index 352bcaaaf..5d305c273 100644 --- a/src/main/java/org/apache/commons/collections4/SetUtils.java +++ b/src/main/java/org/apache/commons/collections4/SetUtils.java @@ -62,7 +62,7 @@ public class SetUtils { */ @SuppressWarnings("rawtypes") public static final SortedSet EMPTY_SORTED_SET = - UnmodifiableSortedSet.unmodifiableSortedSet(new TreeSet()); + 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 toSet() { - final Set set = new HashSet(size()); + final Set set = new HashSet<>(size()); copyInto(set); return set; } diff --git a/src/main/java/org/apache/commons/collections4/SplitMapUtils.java b/src/main/java/org/apache/commons/collections4/SplitMapUtils.java index d6822dfe9..3bbc494da 100644 --- a/src/main/java/org/apache/commons/collections4/SplitMapUtils.java +++ b/src/main/java/org/apache/commons/collections4/SplitMapUtils.java @@ -131,7 +131,7 @@ public class SplitMapUtils { if (get instanceof IterableGet) { it = ((IterableGet) get).mapIterator(); } else { - it = new EntrySetToMapIteratorAdapter(get.entrySet()); + it = new EntrySetToMapIteratorAdapter<>(get.entrySet()); } return UnmodifiableMapIterator.unmodifiableMapIterator(it); } @@ -242,7 +242,7 @@ public class SplitMapUtils { ((IterableMap) get) : MapUtils.iterableMap((Map) get); } - return new WrappedGet(get); + return new WrappedGet<>(get); } /** @@ -266,7 +266,7 @@ public class SplitMapUtils { if (put instanceof Map) { return (Map) put; } - return new WrappedPut(put); + return new WrappedPut<>(put); } } diff --git a/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java b/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java index 6970d2b6c..859fafc71 100644 --- a/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java @@ -141,7 +141,7 @@ public abstract class AbstractMapBag implements Bag { if (coll instanceof Bag) { return containsAll((Bag) coll); } - return containsAll(new HashBag(coll)); + return containsAll(new HashBag<>(coll)); } /** @@ -171,7 +171,7 @@ public abstract class AbstractMapBag implements Bag { */ @Override public Iterator iterator() { - return new BagIterator(this); + return new BagIterator<>(this); } /** @@ -379,7 +379,7 @@ public abstract class AbstractMapBag implements Bag { if (coll instanceof Bag) { return retainAll((Bag) coll); } - return retainAll(new HashBag(coll)); + return retainAll(new HashBag<>(coll)); } /** @@ -392,7 +392,7 @@ public abstract class AbstractMapBag implements Bag { */ boolean retainAll(final Bag other) { boolean result = false; - final Bag excess = new HashBag(); + final Bag excess = new HashBag<>(); final Iterator i = uniqueSet().iterator(); while (i.hasNext()) { final E current = i.next(); diff --git a/src/main/java/org/apache/commons/collections4/bag/CollectionBag.java b/src/main/java/org/apache/commons/collections4/bag/CollectionBag.java index ceb7c516f..28c4b7dea 100644 --- a/src/main/java/org/apache/commons/collections4/bag/CollectionBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/CollectionBag.java @@ -52,7 +52,7 @@ public final class CollectionBag extends AbstractBagDecorator { * @throws NullPointerException if bag is null */ public static Bag collectionBag(final Bag bag) { - return new CollectionBag(bag); + return new CollectionBag<>(bag); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/bag/CollectionSortedBag.java b/src/main/java/org/apache/commons/collections4/bag/CollectionSortedBag.java index 1b2c8ff6e..1baea2d35 100644 --- a/src/main/java/org/apache/commons/collections4/bag/CollectionSortedBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/CollectionSortedBag.java @@ -44,7 +44,7 @@ public final class CollectionSortedBag extends AbstractSortedBagDecorator * @throws NullPointerException if bag is null */ public static SortedBag collectionSortedBag(final SortedBag bag) { - return new CollectionSortedBag(bag); + return new CollectionSortedBag<>(bag); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/bag/PredicatedBag.java b/src/main/java/org/apache/commons/collections4/bag/PredicatedBag.java index 46501fb7b..0e6d2dbdd 100644 --- a/src/main/java/org/apache/commons/collections4/bag/PredicatedBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/PredicatedBag.java @@ -60,7 +60,7 @@ public class PredicatedBag extends PredicatedCollection implements Bag * @since 4.0 */ public static PredicatedBag predicatedBag(final Bag bag, final Predicate predicate) { - return new PredicatedBag(bag, predicate); + return new PredicatedBag<>(bag, predicate); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/bag/PredicatedSortedBag.java b/src/main/java/org/apache/commons/collections4/bag/PredicatedSortedBag.java index 404ea7744..190376190 100644 --- a/src/main/java/org/apache/commons/collections4/bag/PredicatedSortedBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/PredicatedSortedBag.java @@ -60,7 +60,7 @@ public class PredicatedSortedBag extends PredicatedBag implements SortedBa */ public static PredicatedSortedBag predicatedSortedBag(final SortedBag bag, final Predicate predicate) { - return new PredicatedSortedBag(bag, predicate); + return new PredicatedSortedBag<>(bag, predicate); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/bag/SynchronizedBag.java b/src/main/java/org/apache/commons/collections4/bag/SynchronizedBag.java index 07a7ab9b0..04e20d180 100644 --- a/src/main/java/org/apache/commons/collections4/bag/SynchronizedBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/SynchronizedBag.java @@ -48,7 +48,7 @@ public class SynchronizedBag extends SynchronizedCollection implements Bag * @since 4.0 */ public static SynchronizedBag synchronizedBag(final Bag bag) { - return new SynchronizedBag(bag); + return new SynchronizedBag<>(bag); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/bag/SynchronizedSortedBag.java b/src/main/java/org/apache/commons/collections4/bag/SynchronizedSortedBag.java index 5f8e803cf..fd0a4e17a 100644 --- a/src/main/java/org/apache/commons/collections4/bag/SynchronizedSortedBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/SynchronizedSortedBag.java @@ -48,7 +48,7 @@ public class SynchronizedSortedBag extends SynchronizedBag implements Sort * @since 4.0 */ public static SynchronizedSortedBag synchronizedSortedBag(final SortedBag bag) { - return new SynchronizedSortedBag(bag); + return new SynchronizedSortedBag<>(bag); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/bag/TransformedBag.java b/src/main/java/org/apache/commons/collections4/bag/TransformedBag.java index 1cb603a7b..f1e614646 100644 --- a/src/main/java/org/apache/commons/collections4/bag/TransformedBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/TransformedBag.java @@ -55,7 +55,7 @@ public class TransformedBag extends TransformedCollection implements Bag Bag transformingBag(final Bag bag, final Transformer transformer) { - return new TransformedBag(bag, transformer); + return new TransformedBag<>(bag, transformer); } /** @@ -74,7 +74,7 @@ public class TransformedBag extends TransformedCollection implements Bag Bag transformedBag(final Bag bag, final Transformer transformer) { - final TransformedBag decorated = new TransformedBag(bag, transformer); + final TransformedBag 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 diff --git a/src/main/java/org/apache/commons/collections4/bag/TransformedSortedBag.java b/src/main/java/org/apache/commons/collections4/bag/TransformedSortedBag.java index 14ee634cb..feb289167 100644 --- a/src/main/java/org/apache/commons/collections4/bag/TransformedSortedBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/TransformedSortedBag.java @@ -54,7 +54,7 @@ public class TransformedSortedBag extends TransformedBag implements Sorted */ public static TransformedSortedBag transformingSortedBag(final SortedBag bag, final Transformer transformer) { - return new TransformedSortedBag(bag, transformer); + return new TransformedSortedBag<>(bag, transformer); } /** @@ -75,7 +75,7 @@ public class TransformedSortedBag extends TransformedBag implements Sorted public static TransformedSortedBag transformedSortedBag(final SortedBag bag, final Transformer transformer) { - final TransformedSortedBag decorated = new TransformedSortedBag(bag, transformer); + final TransformedSortedBag 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 diff --git a/src/main/java/org/apache/commons/collections4/bag/UnmodifiableBag.java b/src/main/java/org/apache/commons/collections4/bag/UnmodifiableBag.java index b01043d68..0f500e414 100644 --- a/src/main/java/org/apache/commons/collections4/bag/UnmodifiableBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/UnmodifiableBag.java @@ -61,7 +61,7 @@ public final class UnmodifiableBag final Bag tmpBag = (Bag) bag; return tmpBag; } - return new UnmodifiableBag(bag); + return new UnmodifiableBag<>(bag); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/bag/UnmodifiableSortedBag.java b/src/main/java/org/apache/commons/collections4/bag/UnmodifiableSortedBag.java index 14399883c..3560f3eff 100644 --- a/src/main/java/org/apache/commons/collections4/bag/UnmodifiableSortedBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/UnmodifiableSortedBag.java @@ -59,7 +59,7 @@ public final class UnmodifiableSortedBag if (bag instanceof Unmodifiable) { return bag; } - return new UnmodifiableSortedBag(bag); + return new UnmodifiableSortedBag<>(bag); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java index a3a1c207f..d332a893c 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java @@ -225,7 +225,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { */ @Override public MapIterator mapIterator() { - return new BidiMapIterator(this); + return new BidiMapIterator<>(this); } @Override @@ -263,7 +263,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { @Override public Set keySet() { if (keySet == null) { - keySet = new KeySet(this); + keySet = new KeySet<>(this); } return keySet; } @@ -276,7 +276,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { * @return the keySet iterator */ protected Iterator createKeySetIterator(final Iterator iterator) { - return new KeySetIterator(iterator, this); + return new KeySetIterator<>(iterator, this); } /** @@ -289,7 +289,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { @Override public Set values() { if (values == null) { - values = new Values(this); + values = new Values<>(this); } return values; } @@ -302,7 +302,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { * @return the values iterator */ protected Iterator createValuesIterator(final Iterator iterator) { - return new ValuesIterator(iterator, this); + return new ValuesIterator<>(iterator, this); } /** @@ -319,7 +319,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { @Override public Set> entrySet() { if (entrySet == null) { - entrySet = new EntrySet(this); + entrySet = new EntrySet<>(this); } return entrySet; } @@ -332,7 +332,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { * @return the entrySet iterator */ protected Iterator> createEntrySetIterator(final Iterator> iterator) { - return new EntrySetIterator(iterator, this); + return new EntrySetIterator<>(iterator, this); } //----------------------------------------------------------------------- @@ -652,7 +652,7 @@ public abstract class AbstractDualBidiMap implements BidiMap { @Override public Map.Entry next() { - last = new MapEntry(super.next(), parent); + last = new MapEntry<>(super.next(), parent); canRemove = true; return last; } diff --git a/src/main/java/org/apache/commons/collections4/bidimap/DualHashBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/DualHashBidiMap.java index 269cf3fd1..e11f553bf 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/DualHashBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/DualHashBidiMap.java @@ -85,7 +85,7 @@ public class DualHashBidiMap extends AbstractDualBidiMap implements @Override protected BidiMap createBidiMap(final Map normalMap, final Map reverseMap, final BidiMap inverseBidiMap) { - return new DualHashBidiMap(normalMap, reverseMap, inverseBidiMap); + return new DualHashBidiMap<>(normalMap, reverseMap, inverseBidiMap); } // Serialization @@ -97,8 +97,8 @@ public class DualHashBidiMap extends AbstractDualBidiMap implements private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); - normalMap = new HashMap(); - reverseMap = new HashMap(); + normalMap = new HashMap<>(); + reverseMap = new HashMap<>(); @SuppressWarnings("unchecked") // will fail at runtime if stream is incorrect final Map map = (Map) in.readObject(); putAll(map); diff --git a/src/main/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMap.java index fdec37e37..2f2679385 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMap.java @@ -80,7 +80,7 @@ public class DualLinkedHashBidiMap extends AbstractDualBidiMap imple @Override protected BidiMap createBidiMap(final Map normalMap, final Map reverseMap, final BidiMap inverseBidiMap) { - return new DualLinkedHashBidiMap(normalMap, reverseMap, inverseBidiMap); + return new DualLinkedHashBidiMap<>(normalMap, reverseMap, inverseBidiMap); } // Serialization @@ -92,8 +92,8 @@ public class DualLinkedHashBidiMap extends AbstractDualBidiMap imple private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); - normalMap = new LinkedHashMap(); - reverseMap = new LinkedHashMap(); + normalMap = new LinkedHashMap<>(); + reverseMap = new LinkedHashMap<>(); @SuppressWarnings("unchecked") // will fail at runtime if stream is incorrect final Map map = (Map) in.readObject(); putAll(map); diff --git a/src/main/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap.java index 92978ce75..9e6418ede 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap.java @@ -123,7 +123,7 @@ public class DualTreeBidiMap extends AbstractDualBidiMap @Override protected DualTreeBidiMap createBidiMap(final Map normalMap, final Map reverseMap, final BidiMap inverseMap) { - return new DualTreeBidiMap(normalMap, reverseMap, inverseMap); + return new DualTreeBidiMap<>(normalMap, reverseMap, inverseMap); } //----------------------------------------------------------------------- @@ -192,7 +192,7 @@ public class DualTreeBidiMap extends AbstractDualBidiMap */ @Override public OrderedMapIterator mapIterator() { - return new BidiOrderedMapIterator(this); + return new BidiOrderedMapIterator<>(this); } public SortedBidiMap inverseSortedBidiMap() { @@ -208,19 +208,19 @@ public class DualTreeBidiMap extends AbstractDualBidiMap @Override public SortedMap headMap(final K toKey) { final SortedMap sub = ((SortedMap) normalMap).headMap(toKey); - return new ViewMap(this, sub); + return new ViewMap<>(this, sub); } @Override public SortedMap tailMap(final K fromKey) { final SortedMap sub = ((SortedMap) normalMap).tailMap(fromKey); - return new ViewMap(this, sub); + return new ViewMap<>(this, sub); } @Override public SortedMap subMap(final K fromKey, final K toKey) { final SortedMap sub = ((SortedMap) normalMap).subMap(fromKey, toKey); - return new ViewMap(this, sub); + return new ViewMap<>(this, sub); } @Override @@ -242,7 +242,7 @@ public class DualTreeBidiMap extends AbstractDualBidiMap // 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(sm, bidi.reverseMap, bidi.inverseBidiMap)); + super(new DualTreeBidiMap<>(sm, bidi.reverseMap, bidi.inverseBidiMap)); } @Override @@ -262,17 +262,17 @@ public class DualTreeBidiMap extends AbstractDualBidiMap @Override public SortedMap headMap(final K toKey) { - return new ViewMap(decorated(), super.headMap(toKey)); + return new ViewMap<>(decorated(), super.headMap(toKey)); } @Override public SortedMap tailMap(final K fromKey) { - return new ViewMap(decorated(), super.tailMap(fromKey)); + return new ViewMap<>(decorated(), super.tailMap(fromKey)); } @Override public SortedMap subMap(final K fromKey, final K toKey) { - return new ViewMap(decorated(), super.subMap(fromKey, toKey)); + return new ViewMap<>(decorated(), super.subMap(fromKey, toKey)); } @Override @@ -313,7 +313,7 @@ public class DualTreeBidiMap extends AbstractDualBidiMap protected BidiOrderedMapIterator(final AbstractDualBidiMap parent) { super(); this.parent = parent; - iterator = new ArrayList>(parent.entrySet()).listIterator(); + iterator = new ArrayList<>(parent.entrySet()).listIterator(); } @Override @@ -384,7 +384,7 @@ public class DualTreeBidiMap extends AbstractDualBidiMap @Override public void reset() { - iterator = new ArrayList>(parent.entrySet()).listIterator(); + iterator = new ArrayList<>(parent.entrySet()).listIterator(); last = null; } @@ -406,8 +406,8 @@ public class DualTreeBidiMap extends AbstractDualBidiMap private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); - normalMap = new TreeMap(comparator); - reverseMap = new TreeMap(valueComparator); + normalMap = new TreeMap<>(comparator); + reverseMap = new TreeMap<>(valueComparator); @SuppressWarnings("unchecked") // will fail at runtime if the stream is incorrect final Map map = (Map) in.readObject(); putAll(map); diff --git a/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java index d6d1ea8c0..23adc3f77 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java @@ -509,7 +509,7 @@ public class TreeBidiMap, V extends Comparable> Node node = rootNode[KEY.ordinal()]; if (node == null) { // map is empty - final Node root = new Node(key, value); + final Node root = new Node<>(key, value); rootNode[KEY.ordinal()] = root; rootNode[VALUE.ordinal()] = root; grow(); @@ -526,7 +526,7 @@ public class TreeBidiMap, V extends Comparable> if (node.getLeft(KEY) != null) { node = node.getLeft(KEY); } else { - final Node newNode = new Node(key, value); + final Node newNode = new Node<>(key, value); insertValue(newNode); node.setLeft(newNode, KEY); @@ -540,7 +540,7 @@ public class TreeBidiMap, V extends Comparable> if (node.getRight(KEY) != null) { node = node.getRight(KEY); } else { - final Node newNode = new Node(key, value); + final Node newNode = new Node<>(key, value); insertValue(newNode); node.setRight(newNode, KEY); @@ -1847,7 +1847,7 @@ public class TreeBidiMap, V extends Comparable> } private Map.Entry createEntry(final Node node) { - return new UnmodifiableMapEntry(node.getValue(), node.getKey()); + return new UnmodifiableMapEntry<>(node.getValue(), node.getKey()); } } diff --git a/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMap.java index 0b59dd7dd..bad687467 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMap.java @@ -58,7 +58,7 @@ public final class UnmodifiableBidiMap final BidiMap tmpMap = (BidiMap) map; return tmpMap; } - return new UnmodifiableBidiMap(map); + return new UnmodifiableBidiMap<>(map); } //----------------------------------------------------------------------- @@ -127,7 +127,7 @@ public final class UnmodifiableBidiMap @Override public synchronized BidiMap inverseBidiMap() { if (inverse == null) { - inverse = new UnmodifiableBidiMap(decorated().inverseBidiMap()); + inverse = new UnmodifiableBidiMap<>(decorated().inverseBidiMap()); inverse.inverse = this; } return inverse; diff --git a/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMap.java index 73d4fd977..581734bd7 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMap.java @@ -59,7 +59,7 @@ public final class UnmodifiableOrderedBidiMap final OrderedBidiMap tmpMap = (OrderedBidiMap) map; return tmpMap; } - return new UnmodifiableOrderedBidiMap(map); + return new UnmodifiableOrderedBidiMap<>(map); } //----------------------------------------------------------------------- @@ -138,7 +138,7 @@ public final class UnmodifiableOrderedBidiMap */ public OrderedBidiMap inverseOrderedBidiMap() { if (inverse == null) { - inverse = new UnmodifiableOrderedBidiMap(decorated().inverseBidiMap()); + inverse = new UnmodifiableOrderedBidiMap<>(decorated().inverseBidiMap()); inverse.inverse = this; } return inverse; diff --git a/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMap.java index 398a2cfd7..7705718b2 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMap.java @@ -60,7 +60,7 @@ public final class UnmodifiableSortedBidiMap final SortedBidiMap tmpMap = (SortedBidiMap) map; return tmpMap; } - return new UnmodifiableSortedBidiMap(map); + return new UnmodifiableSortedBidiMap<>(map); } //----------------------------------------------------------------------- @@ -131,7 +131,7 @@ public final class UnmodifiableSortedBidiMap @Override public SortedBidiMap inverseBidiMap() { if (inverse == null) { - inverse = new UnmodifiableSortedBidiMap(decorated().inverseBidiMap()); + inverse = new UnmodifiableSortedBidiMap<>(decorated().inverseBidiMap()); inverse.inverse = this; } return inverse; diff --git a/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java b/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java index d8516a340..3525b76b9 100644 --- a/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java @@ -48,7 +48,7 @@ public class CompositeCollection implements Collection, Serializable { private CollectionMutator mutator; /** Collections in the composite */ - private final List> all = new ArrayList>(); + private final List> all = new ArrayList<>(); /** * Create an empty CompositeCollection. @@ -156,7 +156,7 @@ public class CompositeCollection implements Collection, Serializable { if (all.isEmpty()) { return EmptyIterator.emptyIterator(); } - final IteratorChain chain = new IteratorChain(); + final IteratorChain chain = new IteratorChain<>(); for (final Collection item : all) { chain.addIterator(item.iterator()); } @@ -401,7 +401,7 @@ public class CompositeCollection implements Collection, Serializable { * The new collection is not backed by this composite. */ public Collection toCollection() { - return new ArrayList(this); + return new ArrayList<>(this); } /** diff --git a/src/main/java/org/apache/commons/collections4/collection/IndexedCollection.java b/src/main/java/org/apache/commons/collections4/collection/IndexedCollection.java index c70c3f3da..a0ed46b25 100644 --- a/src/main/java/org/apache/commons/collections4/collection/IndexedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/IndexedCollection.java @@ -71,7 +71,7 @@ public class IndexedCollection extends AbstractCollectionDecorator { */ public static IndexedCollection uniqueIndexedCollection(final Collection coll, final Transformer keyTransformer) { - return new IndexedCollection(coll, keyTransformer, + return new IndexedCollection<>(coll, keyTransformer, MultiValueMap.multiValueMap(new HashMap>()), true); } @@ -87,7 +87,7 @@ public class IndexedCollection extends AbstractCollectionDecorator { */ public static IndexedCollection nonUniqueIndexedCollection(final Collection coll, final Transformer keyTransformer) { - return new IndexedCollection(coll, keyTransformer, + return new IndexedCollection<>(coll, keyTransformer, MultiValueMap.multiValueMap(new HashMap>()), false); } diff --git a/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java b/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java index 7c181ff4f..468d5fc87 100644 --- a/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java @@ -73,7 +73,7 @@ public class PredicatedCollection extends AbstractCollectionDecorator { * @since 4.1 */ public static Builder builder(final Predicate predicate) { - return new Builder(predicate); + return new Builder<>(predicate); } /** @@ -84,7 +84,7 @@ public class PredicatedCollection extends AbstractCollectionDecorator { * @since 4.1 */ public static Builder notNullBuilder() { - return new Builder(NotNullPredicate.notNullPredicate()); + return new Builder<>(NotNullPredicate.notNullPredicate()); } /** @@ -103,7 +103,7 @@ public class PredicatedCollection extends AbstractCollectionDecorator { */ public static PredicatedCollection predicatedCollection(final Collection coll, final Predicate predicate) { - return new PredicatedCollection(coll, predicate); + return new PredicatedCollection<>(coll, predicate); } //----------------------------------------------------------------------- @@ -209,10 +209,10 @@ public class PredicatedCollection extends AbstractCollectionDecorator { private final Predicate predicate; /** The buffer containing valid elements. */ - private final List accepted = new ArrayList(); + private final List accepted = new ArrayList<>(); /** The buffer containing rejected elements. */ - private final List rejected = new ArrayList(); + private final List rejected = new ArrayList<>(); // ----------------------------------------------------------------------- /** diff --git a/src/main/java/org/apache/commons/collections4/collection/SynchronizedCollection.java b/src/main/java/org/apache/commons/collections4/collection/SynchronizedCollection.java index e09ea8bbf..88138ca8b 100644 --- a/src/main/java/org/apache/commons/collections4/collection/SynchronizedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/SynchronizedCollection.java @@ -58,7 +58,7 @@ public class SynchronizedCollection implements Collection, Serializable { * @since 4.0 */ public static SynchronizedCollection synchronizedCollection(final Collection coll) { - return new SynchronizedCollection(coll); + return new SynchronizedCollection<>(coll); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/collection/TransformedCollection.java b/src/main/java/org/apache/commons/collections4/collection/TransformedCollection.java index 60342583c..1bf13b8b0 100644 --- a/src/main/java/org/apache/commons/collections4/collection/TransformedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/TransformedCollection.java @@ -60,7 +60,7 @@ public class TransformedCollection extends AbstractCollectionDecorator { */ public static TransformedCollection transformingCollection(final Collection coll, final Transformer transformer) { - return new TransformedCollection(coll, transformer); + return new TransformedCollection<>(coll, transformer); } /** @@ -81,7 +81,7 @@ public class TransformedCollection extends AbstractCollectionDecorator { public static TransformedCollection transformedCollection(final Collection collection, final Transformer transformer) { - final TransformedCollection decorated = new TransformedCollection(collection, transformer); + final TransformedCollection 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 extends AbstractCollectionDecorator { * @return a transformed object */ protected Collection transform(final Collection coll) { - final List list = new ArrayList(coll.size()); + final List list = new ArrayList<>(coll.size()); for (final E item : coll) { list.add(transform(item)); } diff --git a/src/main/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollection.java b/src/main/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollection.java index 323f7b4c2..2704bfa02 100644 --- a/src/main/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollection.java @@ -61,7 +61,7 @@ public final class UnmodifiableBoundedCollection extends AbstractCollectionDe final BoundedCollection tmpColl = (BoundedCollection) coll; return tmpColl; } - return new UnmodifiableBoundedCollection(coll); + return new UnmodifiableBoundedCollection<>(coll); } /** @@ -98,7 +98,7 @@ public final class UnmodifiableBoundedCollection extends AbstractCollectionDe if (coll instanceof BoundedCollection == false) { throw new IllegalArgumentException("Collection is not a bounded collection."); } - return new UnmodifiableBoundedCollection((BoundedCollection) coll); + return new UnmodifiableBoundedCollection<>((BoundedCollection) coll); } /** diff --git a/src/main/java/org/apache/commons/collections4/collection/UnmodifiableCollection.java b/src/main/java/org/apache/commons/collections4/collection/UnmodifiableCollection.java index 8d248b33b..de9eb3657 100644 --- a/src/main/java/org/apache/commons/collections4/collection/UnmodifiableCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/UnmodifiableCollection.java @@ -57,7 +57,7 @@ public final class UnmodifiableCollection final Collection tmpColl = (Collection) coll; return tmpColl; } - return new UnmodifiableCollection(coll); + return new UnmodifiableCollection<>(coll); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java b/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java index e9f43b97f..33e123143 100644 --- a/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java +++ b/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java @@ -88,7 +88,7 @@ public class ComparatorChain implements Comparator, Serializable { * @param reverse false = forward sort; true = reverse sort */ public ComparatorChain(final Comparator comparator, final boolean reverse) { - comparatorChain = new ArrayList>(1); + comparatorChain = new ArrayList<>(1); comparatorChain.add(comparator); orderingBits = new BitSet(1); if (reverse == true) { diff --git a/src/main/java/org/apache/commons/collections4/comparators/FixedOrderComparator.java b/src/main/java/org/apache/commons/collections4/comparators/FixedOrderComparator.java index f9a4d7de8..1b96b34fe 100644 --- a/src/main/java/org/apache/commons/collections4/comparators/FixedOrderComparator.java +++ b/src/main/java/org/apache/commons/collections4/comparators/FixedOrderComparator.java @@ -60,7 +60,7 @@ public class FixedOrderComparator implements Comparator, Serializable { } /** Internal map of object to position */ - private final Map map = new HashMap(); + private final Map map = new HashMap<>(); /** Counter used in determining the position in the map */ private int counter = 0; diff --git a/src/main/java/org/apache/commons/collections4/functors/AllPredicate.java b/src/main/java/org/apache/commons/collections4/functors/AllPredicate.java index 583e34751..aecfbe7c8 100644 --- a/src/main/java/org/apache/commons/collections4/functors/AllPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/AllPredicate.java @@ -61,7 +61,7 @@ public final class AllPredicate extends AbstractQuantifierPredicate { return coerce(predicates[0]); } - return new AllPredicate(FunctorUtils.copy(predicates)); + return new AllPredicate<>(FunctorUtils.copy(predicates)); } /** @@ -84,7 +84,7 @@ public final class AllPredicate extends AbstractQuantifierPredicate { if (preds.length == 1) { return coerce(preds[0]); } - return new AllPredicate(preds); + return new AllPredicate<>(preds); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java b/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java index 96b5ed8d9..db080c427 100644 --- a/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java @@ -50,7 +50,7 @@ public final class AndPredicate implements PredicateDecorator, Serializabl if (predicate1 == null || predicate2 == null) { throw new NullPointerException("Predicate must not be null"); } - return new AndPredicate(predicate1, predicate2); + return new AndPredicate<>(predicate1, predicate2); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/AnyPredicate.java b/src/main/java/org/apache/commons/collections4/functors/AnyPredicate.java index 95a0dd128..60180bf2f 100644 --- a/src/main/java/org/apache/commons/collections4/functors/AnyPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/AnyPredicate.java @@ -57,7 +57,7 @@ public final class AnyPredicate extends AbstractQuantifierPredicate { if (predicates.length == 1) { return (Predicate) predicates[0]; } - return new AnyPredicate(FunctorUtils.copy(predicates)); + return new AnyPredicate<>(FunctorUtils.copy(predicates)); } /** @@ -81,7 +81,7 @@ public final class AnyPredicate extends AbstractQuantifierPredicate { if (preds.length == 1) { return (Predicate) preds[0]; } - return new AnyPredicate(preds); + return new AnyPredicate<>(preds); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/ChainedClosure.java b/src/main/java/org/apache/commons/collections4/functors/ChainedClosure.java index 326383c1f..ae7930f6a 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ChainedClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/ChainedClosure.java @@ -49,7 +49,7 @@ public class ChainedClosure implements Closure, Serializable { if (closures.length == 0) { return NOPClosure.nopClosure(); } - return new ChainedClosure(closures); + return new ChainedClosure<>(closures); } /** @@ -78,7 +78,7 @@ public class ChainedClosure implements Closure, Serializable { cmds[i++] = closure; } FunctorUtils.validate(cmds); - return new ChainedClosure(false, cmds); + return new ChainedClosure<>(false, cmds); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java b/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java index 1c07dfa94..d84fb2462 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/ChainedTransformer.java @@ -52,7 +52,7 @@ public class ChainedTransformer implements Transformer, Serializable { if (transformers.length == 0) { return NOPTransformer.nopTransformer(); } - return new ChainedTransformer(transformers); + return new ChainedTransformer<>(transformers); } /** @@ -78,7 +78,7 @@ public class ChainedTransformer implements Transformer, Serializable { // convert to array like this to guarantee iterator() ordering final Transformer[] cmds = transformers.toArray(new Transformer[transformers.size()]); FunctorUtils.validate(cmds); - return new ChainedTransformer(false, cmds); + return new ChainedTransformer<>(false, cmds); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/CloneTransformer.java b/src/main/java/org/apache/commons/collections4/functors/CloneTransformer.java index 4361845a7..04a4384cc 100644 --- a/src/main/java/org/apache/commons/collections4/functors/CloneTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/CloneTransformer.java @@ -35,7 +35,7 @@ public class CloneTransformer implements Transformer { /** Singleton predicate instance */ @SuppressWarnings("rawtypes") // the singleton instance works for all types - public static final Transformer INSTANCE = new CloneTransformer(); + public static final Transformer INSTANCE = new CloneTransformer<>(); /** * Factory returning the singleton instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/ClosureTransformer.java b/src/main/java/org/apache/commons/collections4/functors/ClosureTransformer.java index 9e640e955..6d1795d9d 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ClosureTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/ClosureTransformer.java @@ -48,7 +48,7 @@ public class ClosureTransformer implements Transformer, Serializable { if (closure == null) { throw new NullPointerException("Closure must not be null"); } - return new ClosureTransformer(closure); + return new ClosureTransformer<>(closure); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/ComparatorPredicate.java b/src/main/java/org/apache/commons/collections4/functors/ComparatorPredicate.java index 4c4a7ecbd..fd1d8297c 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ComparatorPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/ComparatorPredicate.java @@ -126,7 +126,7 @@ public class ComparatorPredicate implements Predicate, Serializable { if (criterion == null) { throw new NullPointerException("Criterion must not be null."); } - return new ComparatorPredicate(object, comparator, criterion); + return new ComparatorPredicate<>(object, comparator, criterion); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/ConstantFactory.java b/src/main/java/org/apache/commons/collections4/functors/ConstantFactory.java index 4a0f91a64..367f5abdf 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ConstantFactory.java +++ b/src/main/java/org/apache/commons/collections4/functors/ConstantFactory.java @@ -37,7 +37,7 @@ public class ConstantFactory implements Factory, Serializable { /** Returns null each time */ @SuppressWarnings("rawtypes") // The null factory works for all object types - public static final Factory NULL_INSTANCE = new ConstantFactory(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 implements Factory, Serializable { if (constantToReturn == null) { return (Factory) NULL_INSTANCE; } - return new ConstantFactory(constantToReturn); + return new ConstantFactory<>(constantToReturn); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java b/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java index 03fdc7b62..30b99c52d 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/ConstantTransformer.java @@ -37,7 +37,7 @@ public class ConstantTransformer implements Transformer, Serializabl /** Returns null each time */ @SuppressWarnings("rawtypes") - public static final Transformer NULL_INSTANCE = new ConstantTransformer(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 implements Transformer, Serializabl if (constantToReturn == null) { return nullTransformer(); } - return new ConstantTransformer(constantToReturn); + return new ConstantTransformer<>(constantToReturn); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java b/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java index d49db4491..4de4f673f 100644 --- a/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java +++ b/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java @@ -34,7 +34,7 @@ public class DefaultEquator implements Equator, Serializable { /** Static instance */ @SuppressWarnings("rawtypes") // the static instance works for all types - public static final DefaultEquator INSTANCE = new DefaultEquator(); + public static final DefaultEquator INSTANCE = new DefaultEquator<>(); /** * Hashcode used for null objects. diff --git a/src/main/java/org/apache/commons/collections4/functors/EqualPredicate.java b/src/main/java/org/apache/commons/collections4/functors/EqualPredicate.java index d4a51b01f..041adee52 100644 --- a/src/main/java/org/apache/commons/collections4/functors/EqualPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/EqualPredicate.java @@ -50,7 +50,7 @@ public final class EqualPredicate implements Predicate, Serializable { if (object == null) { return NullPredicate.nullPredicate(); } - return new EqualPredicate(object); + return new EqualPredicate<>(object); } /** @@ -66,7 +66,7 @@ public final class EqualPredicate implements Predicate, Serializable { if (object == null) { return NullPredicate.nullPredicate(); } - return new EqualPredicate(object, equator); + return new EqualPredicate<>(object, equator); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/ExceptionClosure.java b/src/main/java/org/apache/commons/collections4/functors/ExceptionClosure.java index fa1bce898..bca8f6b50 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ExceptionClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/ExceptionClosure.java @@ -34,7 +34,7 @@ public final class ExceptionClosure implements Closure, Serializable { /** Singleton predicate instance */ @SuppressWarnings("rawtypes") // the static instance works for all types - public static final Closure INSTANCE = new ExceptionClosure(); + public static final Closure INSTANCE = new ExceptionClosure<>(); /** * Factory returning the singleton instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/ExceptionFactory.java b/src/main/java/org/apache/commons/collections4/functors/ExceptionFactory.java index fe71fa5f8..3437ec161 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ExceptionFactory.java +++ b/src/main/java/org/apache/commons/collections4/functors/ExceptionFactory.java @@ -34,7 +34,7 @@ public final class ExceptionFactory implements Factory, Serializable { /** Singleton predicate instance */ @SuppressWarnings("rawtypes") // the static instance works for all types - public static final Factory INSTANCE = new ExceptionFactory(); + public static final Factory INSTANCE = new ExceptionFactory<>(); /** * Factory returning the singleton instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java b/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java index c5b668d54..dd6c5852d 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/ExceptionPredicate.java @@ -34,7 +34,7 @@ public final class ExceptionPredicate implements Predicate, Serializable { /** Singleton predicate instance */ @SuppressWarnings("rawtypes") // the static instance works for all types - public static final Predicate INSTANCE = new ExceptionPredicate(); + public static final Predicate INSTANCE = new ExceptionPredicate<>(); /** * Factory returning the singleton instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java b/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java index 51269c703..11fb318ff 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/ExceptionTransformer.java @@ -34,7 +34,7 @@ public final class ExceptionTransformer implements Transformer, Seri /** Singleton predicate instance */ @SuppressWarnings("rawtypes") // the static instance works for all types - public static final Transformer INSTANCE = new ExceptionTransformer(); + public static final Transformer INSTANCE = new ExceptionTransformer<>(); /** * Factory returning the singleton instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/FactoryTransformer.java b/src/main/java/org/apache/commons/collections4/functors/FactoryTransformer.java index cf8a5d192..4f6d4327b 100644 --- a/src/main/java/org/apache/commons/collections4/functors/FactoryTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/FactoryTransformer.java @@ -48,7 +48,7 @@ public class FactoryTransformer implements Transformer, Serializable if (factory == null) { throw new NullPointerException("Factory must not be null"); } - return new FactoryTransformer(factory); + return new FactoryTransformer<>(factory); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java b/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java index 388deee4d..9ba26e6c6 100644 --- a/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/FalsePredicate.java @@ -33,7 +33,7 @@ public final class FalsePredicate implements Predicate, Serializable { /** Singleton predicate instance */ @SuppressWarnings("rawtypes") // the static instance works for all types - public static final Predicate INSTANCE = new FalsePredicate(); + public static final Predicate INSTANCE = new FalsePredicate<>(); /** * Get a typed instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/ForClosure.java b/src/main/java/org/apache/commons/collections4/functors/ForClosure.java index e2e945949..20a9e87d5 100644 --- a/src/main/java/org/apache/commons/collections4/functors/ForClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/ForClosure.java @@ -55,7 +55,7 @@ public class ForClosure implements Closure { if (count == 1) { return (Closure) closure; } - return new ForClosure(count, closure); + return new ForClosure<>(count, closure); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/IdentityPredicate.java b/src/main/java/org/apache/commons/collections4/functors/IdentityPredicate.java index 369e5c9c8..d991b2a57 100644 --- a/src/main/java/org/apache/commons/collections4/functors/IdentityPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/IdentityPredicate.java @@ -46,7 +46,7 @@ public final class IdentityPredicate implements Predicate, Serializable { if (object == null) { return NullPredicate.nullPredicate(); } - return new IdentityPredicate(object); + return new IdentityPredicate<>(object); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/IfClosure.java b/src/main/java/org/apache/commons/collections4/functors/IfClosure.java index 895a76614..99027cda6 100644 --- a/src/main/java/org/apache/commons/collections4/functors/IfClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/IfClosure.java @@ -76,7 +76,7 @@ public class IfClosure implements Closure, Serializable { if (trueClosure == null || falseClosure == null) { throw new NullPointerException("Closures must not be null"); } - return new IfClosure(predicate, trueClosure, falseClosure); + return new IfClosure<>(predicate, trueClosure, falseClosure); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java b/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java index 933e53e03..f4e60f710 100644 --- a/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java @@ -64,7 +64,7 @@ public class IfTransformer implements Transformer, Serializable { throw new NullPointerException("Transformers must not be null"); } - return new IfTransformer(predicate, trueTransformer, falseTransformer); + return new IfTransformer<>(predicate, trueTransformer, falseTransformer); } /** @@ -90,7 +90,7 @@ public class IfTransformer implements Transformer, Serializable { throw new NullPointerException("Transformer must not be null"); } - return new IfTransformer(predicate, trueTransformer, NOPTransformer.nopTransformer()); + return new IfTransformer<>(predicate, trueTransformer, NOPTransformer.nopTransformer()); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/InstantiateFactory.java b/src/main/java/org/apache/commons/collections4/functors/InstantiateFactory.java index 457643c89..1329afa8b 100644 --- a/src/main/java/org/apache/commons/collections4/functors/InstantiateFactory.java +++ b/src/main/java/org/apache/commons/collections4/functors/InstantiateFactory.java @@ -68,9 +68,9 @@ public class InstantiateFactory implements Factory { } if (paramTypes == null || paramTypes.length == 0) { - return new InstantiateFactory(classToInstantiate); + return new InstantiateFactory<>(classToInstantiate); } - return new InstantiateFactory(classToInstantiate, paramTypes, args); + return new InstantiateFactory<>(classToInstantiate, paramTypes, args); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java b/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java index 757f2a9ac..58fcf9d7d 100644 --- a/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java @@ -37,7 +37,7 @@ public class InstantiateTransformer implements Transformer /** Singleton instance that uses the no arg constructor */ @SuppressWarnings("rawtypes") - private static final Transformer NO_ARG_INSTANCE = new InstantiateTransformer(); + private static final Transformer NO_ARG_INSTANCE = new InstantiateTransformer<>(); /** The constructor parameter types */ private final Class[] iParamTypes; @@ -73,9 +73,9 @@ public class InstantiateTransformer implements Transformer } if (paramTypes == null || paramTypes.length == 0) { - return new InstantiateTransformer(); + return new InstantiateTransformer<>(); } - return new InstantiateTransformer(paramTypes, args); + return new InstantiateTransformer<>(paramTypes, args); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java b/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java index 45d90b2ff..b58509859 100644 --- a/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java @@ -56,7 +56,7 @@ public class InvokerTransformer implements Transformer { if (methodName == null) { throw new NullPointerException("The method to invoke must not be null"); } - return new InvokerTransformer(methodName); + return new InvokerTransformer<>(methodName); } /** @@ -82,9 +82,9 @@ public class InvokerTransformer implements Transformer { throw new IllegalArgumentException("The parameter types must match the arguments"); } if (paramTypes == null || paramTypes.length == 0) { - return new InvokerTransformer(methodName); + return new InvokerTransformer<>(methodName); } - return new InvokerTransformer(methodName, paramTypes, args); + return new InvokerTransformer<>(methodName, paramTypes, args); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/MapTransformer.java b/src/main/java/org/apache/commons/collections4/functors/MapTransformer.java index cfcbc10a8..9e93ec0ed 100644 --- a/src/main/java/org/apache/commons/collections4/functors/MapTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/MapTransformer.java @@ -50,7 +50,7 @@ public final class MapTransformer implements Transformer, Serializab if (map == null) { return ConstantTransformer.nullTransformer(); } - return new MapTransformer(map); + return new MapTransformer<>(map); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/NOPClosure.java b/src/main/java/org/apache/commons/collections4/functors/NOPClosure.java index 9e6889859..e8df5ab3d 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NOPClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/NOPClosure.java @@ -33,7 +33,7 @@ public final class NOPClosure implements Closure, Serializable { /** Singleton predicate instance */ @SuppressWarnings("rawtypes") - public static final Closure INSTANCE = new NOPClosure(); + public static final Closure INSTANCE = new NOPClosure<>(); /** * Factory returning the singleton instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java b/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java index 13e3fbed3..9d223e15d 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/NOPTransformer.java @@ -33,7 +33,7 @@ public class NOPTransformer implements Transformer, Serializable { /** Singleton predicate instance */ @SuppressWarnings("rawtypes") - public static final Transformer INSTANCE = new NOPTransformer(); + public static final Transformer INSTANCE = new NOPTransformer<>(); /** * Factory returning the singleton instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/NonePredicate.java b/src/main/java/org/apache/commons/collections4/functors/NonePredicate.java index 7539a57f3..cdbdfa23b 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NonePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NonePredicate.java @@ -52,7 +52,7 @@ public final class NonePredicate extends AbstractQuantifierPredicate { if (predicates.length == 0) { return TruePredicate.truePredicate(); } - return new NonePredicate(FunctorUtils.copy(predicates)); + return new NonePredicate<>(FunctorUtils.copy(predicates)); } /** @@ -71,7 +71,7 @@ public final class NonePredicate extends AbstractQuantifierPredicate { if (preds.length == 0) { return TruePredicate.truePredicate(); } - return new NonePredicate(preds); + return new NonePredicate<>(preds); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java b/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java index f06b275fb..5b6c78b18 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NotNullPredicate.java @@ -33,7 +33,7 @@ public final class NotNullPredicate implements Predicate, Serializable { /** Singleton predicate instance */ @SuppressWarnings("rawtypes") - public static final Predicate INSTANCE = new NotNullPredicate(); + public static final Predicate INSTANCE = new NotNullPredicate<>(); /** * Factory returning the singleton instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/NotPredicate.java b/src/main/java/org/apache/commons/collections4/functors/NotPredicate.java index bd3f2578d..994512df2 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NotPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NotPredicate.java @@ -46,7 +46,7 @@ public final class NotPredicate implements PredicateDecorator, Serializabl if (predicate == null) { throw new NullPointerException("Predicate must not be null"); } - return new NotPredicate(predicate); + return new NotPredicate<>(predicate); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/NullIsExceptionPredicate.java b/src/main/java/org/apache/commons/collections4/functors/NullIsExceptionPredicate.java index 8fdba9b9a..18bbf0549 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NullIsExceptionPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NullIsExceptionPredicate.java @@ -47,7 +47,7 @@ public final class NullIsExceptionPredicate implements PredicateDecorator, if (predicate == null) { throw new NullPointerException("Predicate must not be null"); } - return new NullIsExceptionPredicate(predicate); + return new NullIsExceptionPredicate<>(predicate); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/NullIsFalsePredicate.java b/src/main/java/org/apache/commons/collections4/functors/NullIsFalsePredicate.java index 20195c151..a2ca7b2b5 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NullIsFalsePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NullIsFalsePredicate.java @@ -46,7 +46,7 @@ public final class NullIsFalsePredicate implements PredicateDecorator, Ser if (predicate == null) { throw new NullPointerException("Predicate must not be null"); } - return new NullIsFalsePredicate(predicate); + return new NullIsFalsePredicate<>(predicate); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/NullIsTruePredicate.java b/src/main/java/org/apache/commons/collections4/functors/NullIsTruePredicate.java index 34ce9c28d..626c3b65d 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NullIsTruePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NullIsTruePredicate.java @@ -46,7 +46,7 @@ public final class NullIsTruePredicate implements PredicateDecorator, Seri if (predicate == null) { throw new NullPointerException("Predicate must not be null"); } - return new NullIsTruePredicate(predicate); + return new NullIsTruePredicate<>(predicate); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java b/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java index 354b04c6e..993e8ef19 100644 --- a/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/NullPredicate.java @@ -33,7 +33,7 @@ public final class NullPredicate implements Predicate, Serializable { /** Singleton predicate instance */ @SuppressWarnings("rawtypes") - public static final Predicate INSTANCE = new NullPredicate(); + public static final Predicate INSTANCE = new NullPredicate<>(); /** * Factory returning the singleton instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/OnePredicate.java b/src/main/java/org/apache/commons/collections4/functors/OnePredicate.java index cb829f0c7..975cb5b39 100644 --- a/src/main/java/org/apache/commons/collections4/functors/OnePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/OnePredicate.java @@ -57,7 +57,7 @@ public final class OnePredicate extends AbstractQuantifierPredicate { if (predicates.length == 1) { return (Predicate) predicates[0]; } - return new OnePredicate(FunctorUtils.copy(predicates)); + return new OnePredicate<>(FunctorUtils.copy(predicates)); } /** @@ -71,7 +71,7 @@ public final class OnePredicate extends AbstractQuantifierPredicate { */ public static Predicate onePredicate(final Collection> predicates) { final Predicate[] preds = FunctorUtils.validate(predicates); - return new OnePredicate(preds); + return new OnePredicate<>(preds); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java b/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java index 60781914f..18c0a0fd3 100644 --- a/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java @@ -50,7 +50,7 @@ public final class OrPredicate implements PredicateDecorator, Serializable if (predicate1 == null || predicate2 == null) { throw new NullPointerException("Predicate must not be null"); } - return new OrPredicate(predicate1, predicate2); + return new OrPredicate<>(predicate1, predicate2); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/PredicateTransformer.java b/src/main/java/org/apache/commons/collections4/functors/PredicateTransformer.java index 5abda005a..c20970ccd 100644 --- a/src/main/java/org/apache/commons/collections4/functors/PredicateTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/PredicateTransformer.java @@ -48,7 +48,7 @@ public class PredicateTransformer implements Transformer, Seriali if (predicate == null) { throw new IllegalArgumentException("Predicate must not be null"); } - return new PredicateTransformer(predicate); + return new PredicateTransformer<>(predicate); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/PrototypeFactory.java b/src/main/java/org/apache/commons/collections4/functors/PrototypeFactory.java index 13186cd31..bde28780c 100644 --- a/src/main/java/org/apache/commons/collections4/functors/PrototypeFactory.java +++ b/src/main/java/org/apache/commons/collections4/functors/PrototypeFactory.java @@ -67,18 +67,18 @@ public class PrototypeFactory { } try { final Method method = prototype.getClass().getMethod("clone", (Class[]) null); - return new PrototypeCloneFactory(prototype, method); + return new PrototypeCloneFactory<>(prototype, method); } catch (final NoSuchMethodException ex) { try { prototype.getClass().getConstructor(new Class[] { prototype.getClass() }); - return new InstantiateFactory( + return new InstantiateFactory<>( (Class) prototype.getClass(), new Class[] { prototype.getClass() }, new Object[] { prototype }); } catch (final NoSuchMethodException ex2) { if (prototype instanceof Serializable) { - return (Factory) new PrototypeSerializationFactory((Serializable) prototype); + return (Factory) new PrototypeSerializationFactory<>((Serializable) prototype); } } } diff --git a/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java b/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java index 3749db120..18acda47b 100644 --- a/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/StringValueTransformer.java @@ -33,7 +33,7 @@ public final class StringValueTransformer implements Transformer, private static final long serialVersionUID = 7511110693171758606L; /** Singleton predicate instance */ - private static final Transformer INSTANCE = new StringValueTransformer(); + private static final Transformer INSTANCE = new StringValueTransformer<>(); /** * Factory returning the singleton instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java b/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java index 39fe371e3..48f4a4efb 100644 --- a/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java @@ -65,7 +65,7 @@ public class SwitchClosure implements Closure, Serializable { if (predicates.length == 0) { return (Closure) (defaultClosure == null ? NOPClosure.nopClosure(): defaultClosure); } - return new SwitchClosure(predicates, closures, defaultClosure); + return new SwitchClosure<>(predicates, closures, defaultClosure); } /** @@ -105,7 +105,7 @@ public class SwitchClosure implements Closure, Serializable { closures[i] = entry.getValue(); i++; } - return new SwitchClosure(false, preds, closures, defaultClosure); + return new SwitchClosure<>(false, preds, closures, defaultClosure); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java b/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java index 6d8c97a33..93a258731 100644 --- a/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java +++ b/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java @@ -66,7 +66,7 @@ public class SwitchTransformer implements Transformer, Serializable return (Transformer) (defaultTransformer == null ? ConstantTransformer.nullTransformer() : defaultTransformer); } - return new SwitchTransformer(predicates, transformers, defaultTransformer); + return new SwitchTransformer<>(predicates, transformers, defaultTransformer); } /** @@ -114,7 +114,7 @@ public class SwitchTransformer implements Transformer, Serializable transformers[i] = entry.getValue(); i++; } - return new SwitchTransformer(false, preds, transformers, defaultTransformer); + return new SwitchTransformer<>(false, preds, transformers, defaultTransformer); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java b/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java index c91e8dfce..155c06996 100644 --- a/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/TransformedPredicate.java @@ -56,7 +56,7 @@ public final class TransformedPredicate implements PredicateDecorator, Ser if (predicate == null) { throw new NullPointerException("The predicate to call must not be null"); } - return new TransformedPredicate(transformer, predicate); + return new TransformedPredicate<>(transformer, predicate); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/TransformerClosure.java b/src/main/java/org/apache/commons/collections4/functors/TransformerClosure.java index f75e9c690..d072d173c 100644 --- a/src/main/java/org/apache/commons/collections4/functors/TransformerClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/TransformerClosure.java @@ -49,7 +49,7 @@ public class TransformerClosure implements Closure, Serializable { if (transformer == null) { return NOPClosure.nopClosure(); } - return new TransformerClosure(transformer); + return new TransformerClosure<>(transformer); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java b/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java index f5ed6baf3..becefb43b 100644 --- a/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/TransformerPredicate.java @@ -48,7 +48,7 @@ public final class TransformerPredicate implements Predicate, Serializable if (transformer == null) { throw new NullPointerException("The transformer to call must not be null"); } - return new TransformerPredicate(transformer); + return new TransformerPredicate<>(transformer); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java b/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java index fb56a914e..58b6a0eb3 100644 --- a/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/TruePredicate.java @@ -33,7 +33,7 @@ public final class TruePredicate implements Predicate, Serializable { /** Singleton predicate instance */ @SuppressWarnings("rawtypes") - public static final Predicate INSTANCE = new TruePredicate(); + public static final Predicate INSTANCE = new TruePredicate<>(); /** * Factory returning the singleton instance. diff --git a/src/main/java/org/apache/commons/collections4/functors/UniquePredicate.java b/src/main/java/org/apache/commons/collections4/functors/UniquePredicate.java index 50528adfa..18009ad71 100644 --- a/src/main/java/org/apache/commons/collections4/functors/UniquePredicate.java +++ b/src/main/java/org/apache/commons/collections4/functors/UniquePredicate.java @@ -35,7 +35,7 @@ public final class UniquePredicate implements Predicate, Serializable { private static final long serialVersionUID = -3319417438027438040L; /** The set of previously seen objects */ - private final Set iSet = new HashSet(); + private final Set iSet = new HashSet<>(); /** * Factory to create the predicate. @@ -45,7 +45,7 @@ public final class UniquePredicate implements Predicate, Serializable { * @throws IllegalArgumentException if the predicate is null */ public static Predicate uniquePredicate() { - return new UniquePredicate(); + return new UniquePredicate<>(); } /** diff --git a/src/main/java/org/apache/commons/collections4/functors/WhileClosure.java b/src/main/java/org/apache/commons/collections4/functors/WhileClosure.java index 8f1834907..c3c0ecb52 100644 --- a/src/main/java/org/apache/commons/collections4/functors/WhileClosure.java +++ b/src/main/java/org/apache/commons/collections4/functors/WhileClosure.java @@ -58,7 +58,7 @@ public class WhileClosure implements Closure { if (closure == null) { throw new NullPointerException("Closure must not be null"); } - return new WhileClosure(predicate, closure, doLoop); + return new WhileClosure<>(predicate, closure, doLoop); } /** diff --git a/src/main/java/org/apache/commons/collections4/iterators/CollatingIterator.java b/src/main/java/org/apache/commons/collections4/iterators/CollatingIterator.java index 3e5aebbe7..4ff1c94bc 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/CollatingIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/CollatingIterator.java @@ -95,7 +95,7 @@ public class CollatingIterator implements Iterator { * child iterators */ public CollatingIterator(final Comparator comp, final int initIterCapacity) { - iterators = new ArrayList>(initIterCapacity); + iterators = new ArrayList<>(initIterCapacity); setComparator(comp); } @@ -289,7 +289,7 @@ public class CollatingIterator implements Iterator { */ private void start() { if (values == null) { - values = new ArrayList(iterators.size()); + values = new ArrayList<>(iterators.size()); valueSet = new BitSet(iterators.size()); for (int i = 0; i < iterators.size(); i++) { values.add(null); diff --git a/src/main/java/org/apache/commons/collections4/iterators/EmptyIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EmptyIterator.java index f2cea2d2d..6f5b0c99c 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/EmptyIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/EmptyIterator.java @@ -37,7 +37,7 @@ public class EmptyIterator extends AbstractEmptyIterator implements Resett * @since 3.1 */ @SuppressWarnings("rawtypes") - public static final ResettableIterator RESETTABLE_INSTANCE = new EmptyIterator(); + public static final ResettableIterator RESETTABLE_INSTANCE = new EmptyIterator<>(); /** * Singleton instance of the iterator. diff --git a/src/main/java/org/apache/commons/collections4/iterators/EmptyListIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EmptyListIterator.java index 23c1e6d7b..6c6f8b413 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/EmptyListIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/EmptyListIterator.java @@ -38,7 +38,7 @@ public class EmptyListIterator extends AbstractEmptyIterator implements * @since 3.1 */ @SuppressWarnings("rawtypes") - public static final ResettableListIterator RESETTABLE_INSTANCE = new EmptyListIterator(); + public static final ResettableListIterator RESETTABLE_INSTANCE = new EmptyListIterator<>(); /** * Singleton instance of the iterator. diff --git a/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java index 9d71ded8b..90fee4a2e 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java @@ -33,7 +33,7 @@ public class EmptyMapIterator extends AbstractEmptyMapIterator imple * @since 3.1 */ @SuppressWarnings("rawtypes") - public static final MapIterator INSTANCE = new EmptyMapIterator(); + public static final MapIterator INSTANCE = new EmptyMapIterator<>(); /** * Get a typed instance of the iterator. diff --git a/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedIterator.java index fd4727432..200cae90f 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedIterator.java @@ -33,7 +33,7 @@ public class EmptyOrderedIterator extends AbstractEmptyIterator * @since 3.1 */ @SuppressWarnings("rawtypes") - public static final OrderedIterator INSTANCE = new EmptyOrderedIterator(); + public static final OrderedIterator INSTANCE = new EmptyOrderedIterator<>(); /** * Typed instance of the iterator. diff --git a/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java index e24d8b3d2..6a5023b1d 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java @@ -33,7 +33,7 @@ public class EmptyOrderedMapIterator extends AbstractEmptyMapIterator(); + public static final OrderedMapIterator INSTANCE = new EmptyOrderedMapIterator<>(); /** * Get a typed instance of the iterator. diff --git a/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java b/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java index 2f86245b9..5db1c076a 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java +++ b/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java @@ -51,7 +51,7 @@ import java.util.Queue; public class IteratorChain implements Iterator { /** The chain of iterators */ - private final Queue> iteratorChain = new LinkedList>(); + private final Queue> iteratorChain = new LinkedList<>(); /** The current iterator */ private Iterator currentIterator = null; diff --git a/src/main/java/org/apache/commons/collections4/iterators/IteratorIterable.java b/src/main/java/org/apache/commons/collections4/iterators/IteratorIterable.java index be1261b4e..b26e08963 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/IteratorIterable.java +++ b/src/main/java/org/apache/commons/collections4/iterators/IteratorIterable.java @@ -111,7 +111,7 @@ public class IteratorIterable implements Iterable { public IteratorIterable(final Iterator iterator, final boolean multipleUse) { super(); if (multipleUse && !(iterator instanceof ResettableIterator)) { - this.iterator = new ListIteratorWrapper(iterator); + this.iterator = new ListIteratorWrapper<>(iterator); } else { this.iterator = iterator; } diff --git a/src/main/java/org/apache/commons/collections4/iterators/ListIteratorWrapper.java b/src/main/java/org/apache/commons/collections4/iterators/ListIteratorWrapper.java index 54afd3172..3468011fd 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/ListIteratorWrapper.java +++ b/src/main/java/org/apache/commons/collections4/iterators/ListIteratorWrapper.java @@ -57,7 +57,7 @@ public class ListIteratorWrapper implements ResettableListIterator { /** The underlying iterator being decorated. */ private final Iterator iterator; /** The list being used to cache the iterator. */ - private final List list = new ArrayList(); + private final List list = new ArrayList<>(); /** The current index of this iterator. */ private int currentIndex = 0; diff --git a/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java index 1b98f1cce..b3afc0be0 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java @@ -77,7 +77,7 @@ import org.apache.commons.collections4.Transformer; public class ObjectGraphIterator implements Iterator { /** The stack of iterators */ - private final Deque> stack = new ArrayDeque>(8); + private final Deque> stack = new ArrayDeque<>(8); /** The root object in the tree */ private E root; /** The transformer to use */ diff --git a/src/main/java/org/apache/commons/collections4/iterators/PeekingIterator.java b/src/main/java/org/apache/commons/collections4/iterators/PeekingIterator.java index 56d2dd980..e6a2d89da 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/PeekingIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/PeekingIterator.java @@ -64,7 +64,7 @@ public class PeekingIterator implements Iterator { final PeekingIterator it = (PeekingIterator) iterator; return it; } - return new PeekingIterator(iterator); + return new PeekingIterator<>(iterator); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java b/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java index 456a3fd65..cbb5c33dd 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java @@ -82,13 +82,13 @@ public class PermutationIterator implements Iterator> { direction = new boolean[coll.size()]; Arrays.fill(direction, false); int value = 1; - objectMap = new HashMap(); + objectMap = new HashMap<>(); for (E e : coll) { objectMap.put(Integer.valueOf(value), e); keys[value - 1] = value; value++; } - nextPermutation = new ArrayList(coll); + nextPermutation = new ArrayList<>(coll); } /** @@ -139,7 +139,7 @@ public class PermutationIterator implements Iterator> { direction[indexOfLargestMobileInteger + offset] = tmpDirection; // reverse the direction of all integers larger than k and build the result - final List nextP = new ArrayList(); + final List nextP = new ArrayList<>(); for (int i = 0; i < keys.length; i++) { if (keys[i] > largestKey) { direction[i] = !direction[i]; diff --git a/src/main/java/org/apache/commons/collections4/iterators/PushbackIterator.java b/src/main/java/org/apache/commons/collections4/iterators/PushbackIterator.java index 7d1962793..fdc1eb683 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/PushbackIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/PushbackIterator.java @@ -39,7 +39,7 @@ public class PushbackIterator implements Iterator { private final Iterator iterator; /** The LIFO queue containing the pushed back items. */ - private final Deque items = new ArrayDeque(); + private final Deque items = new ArrayDeque<>(); //----------------------------------------------------------------------- /** @@ -61,7 +61,7 @@ public class PushbackIterator implements Iterator { final PushbackIterator it = (PushbackIterator) iterator; return it; } - return new PushbackIterator(iterator); + return new PushbackIterator<>(iterator); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableIterator.java b/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableIterator.java index bee6d2564..4f7eb6369 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableIterator.java @@ -53,7 +53,7 @@ public final class UnmodifiableIterator implements Iterator, Unmodifiable final Iterator tmpIterator = (Iterator) iterator; return tmpIterator; } - return new UnmodifiableIterator(iterator); + return new UnmodifiableIterator<>(iterator); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableListIterator.java b/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableListIterator.java index 6861fd924..8b104177c 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableListIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableListIterator.java @@ -51,7 +51,7 @@ public final class UnmodifiableListIterator implements ListIterator, Unmod final ListIterator tmpIterator = (ListIterator) iterator; return tmpIterator; } - return new UnmodifiableListIterator(iterator); + return new UnmodifiableListIterator<>(iterator); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableMapIterator.java b/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableMapIterator.java index 154fd8a0a..0b4d926b1 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableMapIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableMapIterator.java @@ -52,7 +52,7 @@ public final class UnmodifiableMapIterator implements MapIterator, U final MapIterator tmpIterator = (MapIterator) iterator; return tmpIterator; } - return new UnmodifiableMapIterator(iterator); + return new UnmodifiableMapIterator<>(iterator); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIterator.java b/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIterator.java index 52421e78f..34b5711ab 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIterator.java @@ -54,7 +54,7 @@ public final class UnmodifiableOrderedMapIterator implements OrderedMapIte final OrderedMapIterator tmpIterator = (OrderedMapIterator) iterator; return tmpIterator; } - return new UnmodifiableOrderedMapIterator(iterator); + return new UnmodifiableOrderedMapIterator<>(iterator); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/iterators/ZippingIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ZippingIterator.java index 45584987b..6b05872cd 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/ZippingIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/ZippingIterator.java @@ -86,7 +86,7 @@ public class ZippingIterator implements Iterator { */ public ZippingIterator(final Iterator... iterators) { // create a mutable list to be able to remove exhausted iterators - final List> list = new ArrayList>(); + final List> list = new ArrayList<>(); for (final Iterator iterator : iterators) { if (iterator == null) { throw new NullPointerException("Iterator must not be null."); diff --git a/src/main/java/org/apache/commons/collections4/keyvalue/DefaultKeyValue.java b/src/main/java/org/apache/commons/collections4/keyvalue/DefaultKeyValue.java index 6a584ebb8..99b46f6ed 100644 --- a/src/main/java/org/apache/commons/collections4/keyvalue/DefaultKeyValue.java +++ b/src/main/java/org/apache/commons/collections4/keyvalue/DefaultKeyValue.java @@ -109,7 +109,7 @@ public class DefaultKeyValue extends AbstractKeyValue { * @return a MapEntry instance */ public Map.Entry toMapEntry() { - return new DefaultMapEntry(this); + return new DefaultMapEntry<>(this); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java index 2d3ea0d52..9fdc2efc2 100644 --- a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java +++ b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java @@ -125,12 +125,12 @@ public abstract class AbstractLinkedList implements List { @Override public ListIterator listIterator() { - return new LinkedListIterator(this, 0); + return new LinkedListIterator<>(this, 0); } @Override public ListIterator listIterator(final int fromIndex) { - return new LinkedListIterator(this, fromIndex); + return new LinkedListIterator<>(this, fromIndex); } //----------------------------------------------------------------------- @@ -210,7 +210,7 @@ public abstract class AbstractLinkedList implements List { */ @Override public List subList(final int fromIndexInclusive, final int toIndexExclusive) { - return new LinkedSubList(this, fromIndexInclusive, toIndexExclusive); + return new LinkedSubList<>(this, fromIndexInclusive, toIndexExclusive); } //----------------------------------------------------------------------- @@ -459,7 +459,7 @@ public abstract class AbstractLinkedList implements List { * @return newly created node */ protected Node createHeaderNode() { - return new Node(); + return new Node<>(); } /** @@ -471,7 +471,7 @@ public abstract class AbstractLinkedList implements List { * @return a new node containing the value */ protected Node createNode(final E value) { - return new Node(value); + return new Node<>(value); } /** @@ -608,7 +608,7 @@ public abstract class AbstractLinkedList implements List { * @return a new list iterator on the given sublist */ protected ListIterator createSubListListIterator(final LinkedSubList subList, final int fromIndex) { - return new LinkedSubListIterator(subList, fromIndex); + return new LinkedSubListIterator<>(subList, fromIndex); } //----------------------------------------------------------------------- @@ -1080,7 +1080,7 @@ public abstract class AbstractLinkedList implements List { @Override public List subList(final int fromIndexInclusive, final int toIndexExclusive) { - return new LinkedSubList(parent, fromIndexInclusive + offset, toIndexExclusive + offset); + return new LinkedSubList<>(parent, fromIndexInclusive + offset, toIndexExclusive + offset); } protected void rangeCheck(final int index, final int beyond) { diff --git a/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java b/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java index 8f673a1dc..101bf43a5 100644 --- a/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java +++ b/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java @@ -88,7 +88,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Se @Override protected void init() { super.init(); - cursors = new ArrayList>>(); + cursors = new ArrayList<>(); } //----------------------------------------------------------------------- @@ -202,7 +202,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Se * (index < 0 || index > size()). */ public CursorableLinkedList.Cursor cursor(final int fromIndex) { - final Cursor cursor = new Cursor(this, fromIndex); + final Cursor cursor = new Cursor<>(this, fromIndex); registerCursor(cursor); return cursor; } @@ -277,7 +277,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Se it.remove(); } } - cursors.add(new WeakReference>(cursor)); + cursors.add(new WeakReference<>(cursor)); } /** @@ -387,7 +387,7 @@ public class CursorableLinkedList extends AbstractLinkedList implements Se */ @Override protected ListIterator createSubListListIterator(final LinkedSubList subList, final int fromIndex) { - final SubCursor cursor = new SubCursor(subList, fromIndex); + final SubCursor cursor = new SubCursor<>(subList, fromIndex); registerCursor(cursor); return cursor; } diff --git a/src/main/java/org/apache/commons/collections4/list/FixedSizeList.java b/src/main/java/org/apache/commons/collections4/list/FixedSizeList.java index 7c2f16fe8..d397019c3 100644 --- a/src/main/java/org/apache/commons/collections4/list/FixedSizeList.java +++ b/src/main/java/org/apache/commons/collections4/list/FixedSizeList.java @@ -53,7 +53,7 @@ public class FixedSizeList * @since 4.0 */ public static FixedSizeList fixedSizeList(final List list) { - return new FixedSizeList(list); + return new FixedSizeList<>(list); } //----------------------------------------------------------------------- @@ -151,7 +151,7 @@ public class FixedSizeList @Override public List subList(final int fromIndex, final int toIndex) { final List sub = decorated().subList(fromIndex, toIndex); - return new FixedSizeList(sub); + return new FixedSizeList<>(sub); } /** diff --git a/src/main/java/org/apache/commons/collections4/list/GrowthList.java b/src/main/java/org/apache/commons/collections4/list/GrowthList.java index a809d7f57..10ce036d8 100644 --- a/src/main/java/org/apache/commons/collections4/list/GrowthList.java +++ b/src/main/java/org/apache/commons/collections4/list/GrowthList.java @@ -67,7 +67,7 @@ public class GrowthList extends AbstractSerializableListDecorator { * @since 4.0 */ public static GrowthList growthList(final List list) { - return new GrowthList(list); + return new GrowthList<>(list); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/list/LazyList.java b/src/main/java/org/apache/commons/collections4/list/LazyList.java index 14324619d..22f6b047b 100644 --- a/src/main/java/org/apache/commons/collections4/list/LazyList.java +++ b/src/main/java/org/apache/commons/collections4/list/LazyList.java @@ -76,7 +76,7 @@ public class LazyList extends AbstractSerializableListDecorator { * @since 4.0 */ public static LazyList lazyList(final List list, final Factory factory) { - return new LazyList(list, factory); + return new LazyList<>(list, factory); } //----------------------------------------------------------------------- @@ -135,7 +135,7 @@ public class LazyList extends AbstractSerializableListDecorator { @Override public List subList(final int fromIndex, final int toIndex) { final List sub = decorated().subList(fromIndex, toIndex); - return new LazyList(sub, factory); + return new LazyList<>(sub, factory); } } diff --git a/src/main/java/org/apache/commons/collections4/list/PredicatedList.java b/src/main/java/org/apache/commons/collections4/list/PredicatedList.java index bc475beb9..0501d9e02 100644 --- a/src/main/java/org/apache/commons/collections4/list/PredicatedList.java +++ b/src/main/java/org/apache/commons/collections4/list/PredicatedList.java @@ -65,7 +65,7 @@ public class PredicatedList extends PredicatedCollection implements List PredicatedList predicatedList(final List list, final Predicate predicate) { - return new PredicatedList(list, predicate); + return new PredicatedList<>(list, predicate); } //----------------------------------------------------------------------- @@ -161,7 +161,7 @@ public class PredicatedList extends PredicatedCollection implements List subList(final int fromIndex, final int toIndex) { final List sub = decorated().subList(fromIndex, toIndex); - return new PredicatedList(sub, predicate); + return new PredicatedList<>(sub, predicate); } /** diff --git a/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java b/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java index ac4c6aab3..f1e3bb6ae 100644 --- a/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java +++ b/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java @@ -73,11 +73,11 @@ public class SetUniqueList extends AbstractSerializableListDecorator { throw new NullPointerException("List must not be null"); } if (list.isEmpty()) { - return new SetUniqueList(list, new HashSet()); + return new SetUniqueList<>(list, new HashSet()); } - final List temp = new ArrayList(list); + final List temp = new ArrayList<>(list); list.clear(); - final SetUniqueList sl = new SetUniqueList(list, new HashSet()); + final SetUniqueList sl = new SetUniqueList<>(list, new HashSet()); sl.addAll(temp); return sl; } @@ -188,7 +188,7 @@ public class SetUniqueList extends AbstractSerializableListDecorator { */ @Override public boolean addAll(final int index, final Collection coll) { - final List temp = new ArrayList(); + final List temp = new ArrayList<>(); for (final E e : coll) { if (set.add(e)) { temp.add(e); @@ -293,17 +293,17 @@ public class SetUniqueList extends AbstractSerializableListDecorator { @Override public Iterator iterator() { - return new SetListIterator(super.iterator(), set); + return new SetListIterator<>(super.iterator(), set); } @Override public ListIterator listIterator() { - return new SetListListIterator(super.listIterator(), set); + return new SetListListIterator<>(super.listIterator(), set); } @Override public ListIterator listIterator(final int index) { - return new SetListListIterator(super.listIterator(index), set); + return new SetListListIterator<>(super.listIterator(index), set); } /** @@ -316,7 +316,7 @@ public class SetUniqueList extends AbstractSerializableListDecorator { public List subList(final int fromIndex, final int toIndex) { final List superSubList = super.subList(fromIndex, toIndex); final Set subSet = createSetBasedOnList(set, superSubList); - return ListUtils.unmodifiableList(new SetUniqueList(superSubList, subSet)); + return ListUtils.unmodifiableList(new SetUniqueList<>(superSubList, subSet)); } /** @@ -332,14 +332,14 @@ public class SetUniqueList extends AbstractSerializableListDecorator { protected Set createSetBasedOnList(final Set set, final List list) { Set subSet; if (set.getClass().equals(HashSet.class)) { - subSet = new HashSet(list.size()); + subSet = new HashSet<>(list.size()); } else { try { subSet = set.getClass().newInstance(); } catch (final InstantiationException ie) { - subSet = new HashSet(); + subSet = new HashSet<>(); } catch (final IllegalAccessException iae) { - subSet = new HashSet(); + subSet = new HashSet<>(); } } subSet.addAll(list); diff --git a/src/main/java/org/apache/commons/collections4/list/TransformedList.java b/src/main/java/org/apache/commons/collections4/list/TransformedList.java index 01d489441..9c2de739d 100644 --- a/src/main/java/org/apache/commons/collections4/list/TransformedList.java +++ b/src/main/java/org/apache/commons/collections4/list/TransformedList.java @@ -58,7 +58,7 @@ public class TransformedList extends TransformedCollection implements List */ public static TransformedList transformingList(final List list, final Transformer transformer) { - return new TransformedList(list, transformer); + return new TransformedList<>(list, transformer); } /** @@ -78,7 +78,7 @@ public class TransformedList extends TransformedCollection implements List */ public static TransformedList transformedList(final List list, final Transformer transformer) { - final TransformedList decorated = new TransformedList(list, transformer); + final TransformedList decorated = new TransformedList<>(list, transformer); if (list.size() > 0) { @SuppressWarnings("unchecked") // list is of type E final E[] values = (E[]) list.toArray(); // NOPMD - false positive for generics @@ -179,7 +179,7 @@ public class TransformedList extends TransformedCollection implements List @Override public List subList(final int fromIndex, final int toIndex) { final List sub = getList().subList(fromIndex, toIndex); - return new TransformedList(sub, transformer); + return new TransformedList<>(sub, transformer); } /** diff --git a/src/main/java/org/apache/commons/collections4/list/TreeList.java b/src/main/java/org/apache/commons/collections4/list/TreeList.java index c318eaf7e..77285c6e6 100644 --- a/src/main/java/org/apache/commons/collections4/list/TreeList.java +++ b/src/main/java/org/apache/commons/collections4/list/TreeList.java @@ -84,7 +84,7 @@ public class TreeList extends AbstractList { public TreeList(final Collection coll) { super(); if (!coll.isEmpty()) { - root = new AVLNode(coll); + root = new AVLNode<>(coll); size = coll.size(); } } @@ -145,7 +145,7 @@ public class TreeList extends AbstractList { // override to go 75% faster // cannot use EmptyIterator as iterator.add() must work checkInterval(fromIndex, 0, size()); - return new TreeListIterator(this, fromIndex); + return new TreeListIterator<>(this, fromIndex); } /** @@ -201,7 +201,7 @@ public class TreeList extends AbstractList { modCount++; checkInterval(index, 0, size()); if (root == null) { - root = new AVLNode(index, obj, null, null); + root = new AVLNode<>(index, obj, null, null); } else { root = root.insert(index, obj); } @@ -225,7 +225,7 @@ public class TreeList extends AbstractList { return false; } modCount += c.size(); - final AVLNode cTree = new AVLNode(c); + final AVLNode cTree = new AVLNode<>(c); root = root == null ? cTree : root.addAll(cTree, size); size += c.size(); return true; @@ -372,7 +372,7 @@ public class TreeList extends AbstractList { final int absolutePositionOfParent, final AVLNode prev, final AVLNode next) { final int mid = start + (end - start) / 2; if (start < mid) { - left = new AVLNode(iterator, start, mid - 1, mid, prev, this); + left = new AVLNode<>(iterator, start, mid - 1, mid, prev, this); } else { leftIsPrevious = true; left = prev; @@ -380,7 +380,7 @@ public class TreeList extends AbstractList { value = iterator.next(); relativePosition = mid - absolutePositionOfParent; if (mid < end) { - right = new AVLNode(iterator, mid + 1, end, mid, this, next); + right = new AVLNode<>(iterator, mid + 1, end, mid, this, next); } else { rightIsNext = true; right = next; @@ -501,7 +501,7 @@ public class TreeList extends AbstractList { private AVLNode insertOnLeft(final int indexRelativeToMe, final E obj) { if (getLeftSubTree() == null) { - setLeft(new AVLNode(-1, obj, this, left), null); + setLeft(new AVLNode<>(-1, obj, this, left), null); } else { setLeft(left.insert(indexRelativeToMe, obj), null); } @@ -516,7 +516,7 @@ public class TreeList extends AbstractList { private AVLNode insertOnRight(final int indexRelativeToMe, final E obj) { if (getRightSubTree() == null) { - setRight(new AVLNode(+1, obj, right, this), null); + setRight(new AVLNode<>(+1, obj, right, this), null); } else { setRight(right.insert(indexRelativeToMe, obj), null); } @@ -828,7 +828,7 @@ public class TreeList extends AbstractList { // find a subtree, s, that is no taller than me. (While we are // navigating left, we store the nodes we encounter in a stack // so that we can re-balance them in step 4.) - final Deque> sAncestors = new ArrayDeque>(); + final Deque> sAncestors = new ArrayDeque<>(); AVLNode s = otherTree; int sAbsolutePosition = s.relativePosition + currentSize; int sParentAbsolutePosition = 0; @@ -868,7 +868,7 @@ public class TreeList extends AbstractList { } otherTree = otherTree.removeMin(); - final Deque> sAncestors = new ArrayDeque>(); + final Deque> sAncestors = new ArrayDeque<>(); AVLNode s = this; int sAbsolutePosition = s.relativePosition; int sParentAbsolutePosition = 0; diff --git a/src/main/java/org/apache/commons/collections4/list/UnmodifiableList.java b/src/main/java/org/apache/commons/collections4/list/UnmodifiableList.java index 30fbb14d5..c23e4e6dd 100644 --- a/src/main/java/org/apache/commons/collections4/list/UnmodifiableList.java +++ b/src/main/java/org/apache/commons/collections4/list/UnmodifiableList.java @@ -57,7 +57,7 @@ public final class UnmodifiableList final List tmpList = (List) list; return tmpList; } - return new UnmodifiableList(list); + return new UnmodifiableList<>(list); } //----------------------------------------------------------------------- @@ -142,7 +142,7 @@ public final class UnmodifiableList @Override public List subList(final int fromIndex, final int toIndex) { final List sub = decorated().subList(fromIndex, toIndex); - return new UnmodifiableList(sub); + return new UnmodifiableList<>(sub); } } diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java index 6f2867bc0..78ee18e7e 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java @@ -533,7 +533,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab * @return the newly created entry */ protected HashEntry createEntry(final HashEntry next, final int hashCode, final K key, final V value) { - return new HashEntry(next, hashCode, convertKey(key), value); + return new HashEntry<>(next, hashCode, convertKey(key), value); } /** @@ -757,7 +757,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab if (size == 0) { return EmptyMapIterator.emptyMapIterator(); } - return new HashMapIterator(this); + return new HashMapIterator<>(this); } /** @@ -813,7 +813,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab @Override public Set> entrySet() { if (entrySet == null) { - entrySet = new EntrySet(this); + entrySet = new EntrySet<>(this); } return entrySet; } @@ -828,7 +828,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab if (size() == 0) { return EmptyIterator.>emptyIterator(); } - return new EntrySetIterator(this); + return new EntrySetIterator<>(this); } /** @@ -908,7 +908,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab @Override public Set keySet() { if (keySet == null) { - keySet = new KeySet(this); + keySet = new KeySet<>(this); } return keySet; } @@ -923,7 +923,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab if (size() == 0) { return EmptyIterator.emptyIterator(); } - return new KeySetIterator(this); + return new KeySetIterator<>(this); } /** @@ -993,7 +993,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab @Override public Collection values() { if (values == null) { - values = new Values(this); + values = new Values<>(this); } return values; } @@ -1008,7 +1008,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab if (size() == 0) { return EmptyIterator.emptyIterator(); } - return new ValuesIterator(this); + return new ValuesIterator<>(this); } /** diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractIterableMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractIterableMap.java index c66b1be73..2927fff62 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractIterableMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractIterableMap.java @@ -32,6 +32,6 @@ public abstract class AbstractIterableMap implements IterableMap { */ @Override public MapIterator mapIterator() { - return new EntrySetToMapIteratorAdapter(entrySet()); + return new EntrySetToMapIteratorAdapter<>(entrySet()); } } diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java index c4b63dfcf..d06d5cb35 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java @@ -285,7 +285,7 @@ public abstract class AbstractLinkedMap extends AbstractHashedMap im */ @Override protected LinkEntry createEntry(final HashEntry next, final int hashCode, final K key, final V value) { - return new LinkEntry(next, hashCode, convertKey(key), value); + return new LinkEntry<>(next, hashCode, convertKey(key), value); } /** @@ -344,7 +344,7 @@ public abstract class AbstractLinkedMap extends AbstractHashedMap im if (size == 0) { return EmptyOrderedMapIterator.emptyOrderedMapIterator(); } - return new LinkMapIterator(this); + return new LinkMapIterator<>(this); } /** @@ -407,7 +407,7 @@ public abstract class AbstractLinkedMap extends AbstractHashedMap im if (size() == 0) { return EmptyOrderedIterator.>emptyOrderedIterator(); } - return new EntrySetIterator(this); + return new EntrySetIterator<>(this); } /** @@ -443,7 +443,7 @@ public abstract class AbstractLinkedMap extends AbstractHashedMap im if (size() == 0) { return EmptyOrderedIterator.emptyOrderedIterator(); } - return new KeySetIterator(this); + return new KeySetIterator<>(this); } /** @@ -480,7 +480,7 @@ public abstract class AbstractLinkedMap extends AbstractHashedMap im if (size() == 0) { return EmptyOrderedIterator.emptyOrderedIterator(); } - return new ValuesIterator(this); + return new ValuesIterator<>(this); } /** diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java index d32e63fc2..5cbd87b77 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java @@ -175,7 +175,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap */ @Override protected void init() { - queue = new ReferenceQueue(); + queue = new ReferenceQueue<>(); } //----------------------------------------------------------------------- @@ -304,7 +304,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap */ @Override public MapIterator mapIterator() { - return new ReferenceMapIterator(this); + return new ReferenceMapIterator<>(this); } /** @@ -317,7 +317,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap @Override public Set> entrySet() { if (entrySet == null) { - entrySet = new ReferenceEntrySet(this); + entrySet = new ReferenceEntrySet<>(this); } return entrySet; } @@ -330,7 +330,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap @Override public Set keySet() { if (keySet == null) { - keySet = new ReferenceKeySet(this); + keySet = new ReferenceKeySet<>(this); } return keySet; } @@ -343,7 +343,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap @Override public Collection values() { if (values == null) { - values = new ReferenceValues(this); + values = new ReferenceValues<>(this); } return values; } @@ -469,7 +469,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap @Override protected ReferenceEntry createEntry(final HashEntry next, final int hashCode, final K key, final V value) { - return new ReferenceEntry(this, next, hashCode, key, value); + return new ReferenceEntry<>(this, next, hashCode, key, value); } /** @@ -479,7 +479,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap */ @Override protected Iterator> createEntrySetIterator() { - return new ReferenceEntrySetIterator(this); + return new ReferenceEntrySetIterator<>(this); } /** @@ -489,7 +489,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap */ @Override protected Iterator createKeySetIterator() { - return new ReferenceKeySetIterator(this); + return new ReferenceKeySetIterator<>(this); } /** @@ -499,7 +499,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap */ @Override protected Iterator createValuesIterator() { - return new ReferenceValuesIterator(this); + return new ReferenceValuesIterator<>(this); } //----------------------------------------------------------------------- @@ -520,9 +520,9 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap @Override public T[] toArray(final T[] arr) { // special implementation to handle disappearing entries - final ArrayList> list = new ArrayList>(size()); + final ArrayList> list = new ArrayList<>(size()); for (final Map.Entry entry : this) { - list.add(new DefaultMapEntry(entry)); + list.add(new DefaultMapEntry<>(entry)); } return list.toArray(arr); } @@ -546,7 +546,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap @Override public T[] toArray(final T[] arr) { // special implementation to handle disappearing keys - final List list = new ArrayList(size()); + final List list = new ArrayList<>(size()); for (final K key : this) { list.add(key); } @@ -572,7 +572,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap @Override public T[] toArray(final T[] arr) { // special implementation to handle disappearing values - final List list = new ArrayList(size()); + final List list = new ArrayList<>(size()); for (final V value : this) { list.add(value); } @@ -710,10 +710,10 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap return referent; } if (type == ReferenceStrength.SOFT) { - return new SoftRef(hash, referent, parent.queue); + return new SoftRef<>(hash, referent, parent.queue); } if (type == ReferenceStrength.WEAK) { - return new WeakRef(hash, referent, parent.queue); + return new WeakRef<>(hash, referent, parent.queue); } throw new Error(); } diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractSortedMapDecorator.java b/src/main/java/org/apache/commons/collections4/map/AbstractSortedMapDecorator.java index d03219735..1cb568f20 100644 --- a/src/main/java/org/apache/commons/collections4/map/AbstractSortedMapDecorator.java +++ b/src/main/java/org/apache/commons/collections4/map/AbstractSortedMapDecorator.java @@ -124,7 +124,7 @@ public abstract class AbstractSortedMapDecorator extends AbstractMapDecora */ @Override public OrderedMapIterator mapIterator() { - return new SortedMapIterator(entrySet()); + return new SortedMapIterator<>(entrySet()); } /** @@ -150,7 +150,7 @@ public abstract class AbstractSortedMapDecorator extends AbstractMapDecora @Override public synchronized void reset() { super.reset(); - iterator = new ListIteratorWrapper>(iterator); + iterator = new ListIteratorWrapper<>(iterator); } /** diff --git a/src/main/java/org/apache/commons/collections4/map/CompositeMap.java b/src/main/java/org/apache/commons/collections4/map/CompositeMap.java index d5c486149..5f53bef10 100644 --- a/src/main/java/org/apache/commons/collections4/map/CompositeMap.java +++ b/src/main/java/org/apache/commons/collections4/map/CompositeMap.java @@ -251,7 +251,7 @@ public class CompositeMap extends AbstractIterableMap implements Ser */ @Override public Set> entrySet() { - final CompositeSet> entries = new CompositeSet>(); + final CompositeSet> entries = new CompositeSet<>(); for (int i = composite.length - 1; i >= 0; --i) { entries.addComposited(composite[i].entrySet()); } @@ -324,7 +324,7 @@ public class CompositeMap extends AbstractIterableMap implements Ser */ @Override public Set keySet() { - final CompositeSet keys = new CompositeSet(); + final CompositeSet keys = new CompositeSet<>(); for (int i = this.composite.length - 1; i >= 0; --i) { keys.addComposited(this.composite[i].keySet()); } @@ -460,7 +460,7 @@ public class CompositeMap extends AbstractIterableMap implements Ser */ @Override public Collection values() { - final CompositeCollection values = new CompositeCollection(); + final CompositeCollection values = new CompositeCollection<>(); for (int i = composite.length - 1; i >= 0; --i) { values.addComposited(composite[i].values()); } diff --git a/src/main/java/org/apache/commons/collections4/map/DefaultedMap.java b/src/main/java/org/apache/commons/collections4/map/DefaultedMap.java index 7c0d78371..47a1e8af0 100644 --- a/src/main/java/org/apache/commons/collections4/map/DefaultedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/DefaultedMap.java @@ -84,7 +84,7 @@ public class DefaultedMap extends AbstractMapDecorator implements Se * @since 4.0 */ public static DefaultedMap defaultedMap(final Map map, final V defaultValue) { - return new DefaultedMap(map, ConstantTransformer.constantTransformer(defaultValue)); + return new DefaultedMap<>(map, ConstantTransformer.constantTransformer(defaultValue)); } /** @@ -105,7 +105,7 @@ public class DefaultedMap extends AbstractMapDecorator implements Se if (factory == null) { throw new IllegalArgumentException("Factory must not be null"); } - return new DefaultedMap(map, FactoryTransformer.factoryTransformer(factory)); + return new DefaultedMap<>(map, FactoryTransformer.factoryTransformer(factory)); } /** @@ -128,7 +128,7 @@ public class DefaultedMap extends AbstractMapDecorator implements Se if (transformer == null) { throw new IllegalArgumentException("Transformer must not be null"); } - return new DefaultedMap(map, transformer); + return new DefaultedMap<>(map, transformer); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/map/FixedSizeMap.java b/src/main/java/org/apache/commons/collections4/map/FixedSizeMap.java index 706f5dc09..4768b910f 100644 --- a/src/main/java/org/apache/commons/collections4/map/FixedSizeMap.java +++ b/src/main/java/org/apache/commons/collections4/map/FixedSizeMap.java @@ -70,7 +70,7 @@ public class FixedSizeMap * @since 4.0 */ public static FixedSizeMap fixedSizeMap(final Map map) { - return new FixedSizeMap(map); + return new FixedSizeMap<>(map); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/map/FixedSizeSortedMap.java b/src/main/java/org/apache/commons/collections4/map/FixedSizeSortedMap.java index fc7f31a4d..ac6feeb9e 100644 --- a/src/main/java/org/apache/commons/collections4/map/FixedSizeSortedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/FixedSizeSortedMap.java @@ -72,7 +72,7 @@ public class FixedSizeSortedMap * @since 4.0 */ public static FixedSizeSortedMap fixedSizeSortedMap(final SortedMap map) { - return new FixedSizeSortedMap(map); + return new FixedSizeSortedMap<>(map); } //----------------------------------------------------------------------- @@ -158,17 +158,17 @@ public class FixedSizeSortedMap //----------------------------------------------------------------------- @Override public SortedMap subMap(final K fromKey, final K toKey) { - return new FixedSizeSortedMap(getSortedMap().subMap(fromKey, toKey)); + return new FixedSizeSortedMap<>(getSortedMap().subMap(fromKey, toKey)); } @Override public SortedMap headMap(final K toKey) { - return new FixedSizeSortedMap(getSortedMap().headMap(toKey)); + return new FixedSizeSortedMap<>(getSortedMap().headMap(toKey)); } @Override public SortedMap tailMap(final K fromKey) { - return new FixedSizeSortedMap(getSortedMap().tailMap(fromKey)); + return new FixedSizeSortedMap<>(getSortedMap().tailMap(fromKey)); } @Override diff --git a/src/main/java/org/apache/commons/collections4/map/Flat3Map.java b/src/main/java/org/apache/commons/collections4/map/Flat3Map.java index caaf73aef..62d91f960 100644 --- a/src/main/java/org/apache/commons/collections4/map/Flat3Map.java +++ b/src/main/java/org/apache/commons/collections4/map/Flat3Map.java @@ -432,7 +432,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl * @since 3.1 */ protected AbstractHashedMap createDelegateMap() { - return new HashedMap(); + return new HashedMap<>(); } /** @@ -623,7 +623,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl if (size == 0) { return EmptyMapIterator.emptyMapIterator(); } - return new FlatMapIterator(this); + return new FlatMapIterator<>(this); } /** @@ -748,7 +748,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl if (delegateMap != null) { return delegateMap.entrySet(); } - return new EntrySet(this); + return new EntrySet<>(this); } /** @@ -792,7 +792,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl if (parent.size() == 0) { return EmptyIterator.>emptyIterator(); } - return new EntrySetIterator(parent); + return new EntrySetIterator<>(parent); } } @@ -930,7 +930,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl if (!hasNext()) { throw new NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY); } - currentEntry = new FlatMapEntry(parent, ++nextIndex); + currentEntry = new FlatMapEntry<>(parent, ++nextIndex); return currentEntry; } @@ -972,7 +972,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl if (delegateMap != null) { return delegateMap.keySet(); } - return new KeySet(this); + return new KeySet<>(this); } /** @@ -1016,7 +1016,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl if (parent.size() == 0) { return EmptyIterator.emptyIterator(); } - return new KeySetIterator(parent); + return new KeySetIterator<>(parent); } } @@ -1048,7 +1048,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl if (delegateMap != null) { return delegateMap.values(); } - return new Values(this); + return new Values<>(this); } /** @@ -1085,7 +1085,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl if (parent.size() == 0) { return EmptyIterator.emptyIterator(); } - return new ValuesIterator(parent); + return new ValuesIterator<>(parent); } } diff --git a/src/main/java/org/apache/commons/collections4/map/LazyMap.java b/src/main/java/org/apache/commons/collections4/map/LazyMap.java index ba857bcae..e254f089a 100644 --- a/src/main/java/org/apache/commons/collections4/map/LazyMap.java +++ b/src/main/java/org/apache/commons/collections4/map/LazyMap.java @@ -79,7 +79,7 @@ public class LazyMap extends AbstractMapDecorator implements Seriali * @since 4.0 */ public static LazyMap lazyMap(final Map map, final Factory< ? extends V> factory) { - return new LazyMap(map, factory); + return new LazyMap<>(map, factory); } /** @@ -94,7 +94,7 @@ public class LazyMap extends AbstractMapDecorator implements Seriali * @since 4.0 */ public static LazyMap lazyMap(final Map map, final Transformer factory) { - return new LazyMap(map, factory); + return new LazyMap<>(map, factory); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/map/LazySortedMap.java b/src/main/java/org/apache/commons/collections4/map/LazySortedMap.java index dd536ecbf..ddaf9b682 100644 --- a/src/main/java/org/apache/commons/collections4/map/LazySortedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/LazySortedMap.java @@ -74,7 +74,7 @@ public class LazySortedMap extends LazyMap implements SortedMap { */ public static LazySortedMap lazySortedMap(final SortedMap map, final Factory factory) { - return new LazySortedMap(map, factory); + return new LazySortedMap<>(map, factory); } /** @@ -90,7 +90,7 @@ public class LazySortedMap extends LazyMap implements SortedMap { */ public static LazySortedMap lazySortedMap(final SortedMap map, final Transformer factory) { - return new LazySortedMap(map, factory); + return new LazySortedMap<>(map, factory); } //----------------------------------------------------------------------- @@ -145,19 +145,19 @@ public class LazySortedMap extends LazyMap implements SortedMap { @Override public SortedMap subMap(final K fromKey, final K toKey) { final SortedMap map = getSortedMap().subMap(fromKey, toKey); - return new LazySortedMap(map, factory); + return new LazySortedMap<>(map, factory); } @Override public SortedMap headMap(final K toKey) { final SortedMap map = getSortedMap().headMap(toKey); - return new LazySortedMap(map, factory); + return new LazySortedMap<>(map, factory); } @Override public SortedMap tailMap(final K fromKey) { final SortedMap map = getSortedMap().tailMap(fromKey); - return new LazySortedMap(map, factory); + return new LazySortedMap<>(map, factory); } } diff --git a/src/main/java/org/apache/commons/collections4/map/LinkedMap.java b/src/main/java/org/apache/commons/collections4/map/LinkedMap.java index 9ccf7f0e6..d025282de 100644 --- a/src/main/java/org/apache/commons/collections4/map/LinkedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/LinkedMap.java @@ -200,7 +200,7 @@ public class LinkedMap extends AbstractLinkedMap implements Serializ * @return The ordered list of keys. */ public List asList() { - return new LinkedMapList(this); + return new LinkedMapList<>(this); } /** diff --git a/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java b/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java index 867c1713b..4511e0185 100644 --- a/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java @@ -83,7 +83,7 @@ public class ListOrderedMap private static final long serialVersionUID = 2728177751851003750L; /** Internal list to hold the sequence of objects */ - private final List insertOrder = new ArrayList(); + private final List insertOrder = new ArrayList<>(); /** * Factory method to create an ordered map. @@ -98,7 +98,7 @@ public class ListOrderedMap * @since 4.0 */ public static ListOrderedMap listOrderedMap(final Map map) { - return new ListOrderedMap(map); + return new ListOrderedMap<>(map); } //----------------------------------------------------------------------- @@ -154,7 +154,7 @@ public class ListOrderedMap //----------------------------------------------------------------------- @Override public OrderedMapIterator mapIterator() { - return new ListOrderedMapIterator(this); + return new ListOrderedMapIterator<>(this); } /** @@ -292,7 +292,7 @@ public class ListOrderedMap */ @Override public Set keySet() { - return new KeySetView(this); + return new KeySetView<>(this); } /** @@ -322,7 +322,7 @@ public class ListOrderedMap */ @Override public Collection values() { - return new ValuesView(this); + return new ValuesView<>(this); } /** @@ -336,7 +336,7 @@ public class ListOrderedMap * @since 3.2 */ public List valueList() { - return new ValuesView(this); + return new ValuesView<>(this); } /** @@ -348,7 +348,7 @@ public class ListOrderedMap */ @Override public Set> entrySet() { - return new EntrySetView(this, this.insertOrder); + return new EntrySetView<>(this, this.insertOrder); } //----------------------------------------------------------------------- @@ -665,7 +665,7 @@ public class ListOrderedMap @Override public Iterator> iterator() { - return new ListOrderedIterator(parent, insertOrder); + return new ListOrderedIterator<>(parent, insertOrder); } } @@ -682,7 +682,7 @@ public class ListOrderedMap @Override public Map.Entry next() { last = getIterator().next(); - return new ListOrderedMapEntry(parent, last); + return new ListOrderedMapEntry<>(parent, last); } @Override diff --git a/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java b/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java index ab3f830a2..be4ccbf52 100644 --- a/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java +++ b/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java @@ -100,7 +100,7 @@ public class MultiKeyMap extends AbstractMapDecorator 0) { throw new IllegalArgumentException("Map must be empty"); } - return new MultiKeyMap(map); + return new MultiKeyMap<>(map); } //----------------------------------------------------------------------- @@ -185,7 +185,7 @@ public class MultiKeyMap extends AbstractMapDecorator(key1, key2), value); + decorated().addMapping(index, hashCode, new MultiKey<>(key1, key2), value); return null; } @@ -317,7 +317,7 @@ public class MultiKeyMap extends AbstractMapDecorator(key1, key2, key3), value); + decorated().addMapping(index, hashCode, new MultiKey<>(key1, key2, key3), value); return null; } @@ -459,7 +459,7 @@ public class MultiKeyMap extends AbstractMapDecorator(key1, key2, key3, key4), value); + decorated().addMapping(index, hashCode, new MultiKey<>(key1, key2, key3, key4), value); return null; } @@ -612,7 +612,7 @@ public class MultiKeyMap extends AbstractMapDecorator(key1, key2, key3, key4, key5), value); + decorated().addMapping(index, hashCode, new MultiKey<>(key1, key2, key3, key4, key5), value); return null; } diff --git a/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java b/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java index 3c690ab0f..58c2bf034 100644 --- a/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java +++ b/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java @@ -103,7 +103,7 @@ public class MultiValueMap extends AbstractMapDecorator impleme */ public static > MultiValueMap multiValueMap(final Map map, final Class collectionClass) { - return new MultiValueMap(map, new ReflectionFactory(collectionClass)); + return new MultiValueMap<>(map, new ReflectionFactory<>(collectionClass)); } /** @@ -120,7 +120,7 @@ public class MultiValueMap extends AbstractMapDecorator impleme */ public static > MultiValueMap multiValueMap(final Map map, final Factory collectionFactory) { - return new MultiValueMap(map, collectionFactory); + return new MultiValueMap<>(map, collectionFactory); } //----------------------------------------------------------------------- @@ -423,7 +423,7 @@ public class MultiValueMap extends AbstractMapDecorator impleme * @since 4.0 */ public Iterator> iterator() { - final Collection allKeys = new ArrayList(keySet()); + final Collection allKeys = new ArrayList<>(keySet()); final Iterator keyIterator = allKeys.iterator(); return new LazyIteratorChain>() { @@ -452,7 +452,7 @@ public class MultiValueMap extends AbstractMapDecorator impleme }; } }; - return new TransformIterator>(new ValuesIterator(key), transformer); + return new TransformIterator<>(new ValuesIterator(key), transformer); } }; } @@ -491,7 +491,7 @@ public class MultiValueMap extends AbstractMapDecorator impleme private class Values extends AbstractCollection { @Override public Iterator iterator() { - final IteratorChain chain = new IteratorChain(); + final IteratorChain chain = new IteratorChain<>(); for (final K k : keySet()) { chain.addIterator(new ValuesIterator(k)); } diff --git a/src/main/java/org/apache/commons/collections4/map/PassiveExpiringMap.java b/src/main/java/org/apache/commons/collections4/map/PassiveExpiringMap.java index 16ae3b89f..b7343d34e 100644 --- a/src/main/java/org/apache/commons/collections4/map/PassiveExpiringMap.java +++ b/src/main/java/org/apache/commons/collections4/map/PassiveExpiringMap.java @@ -200,7 +200,7 @@ public class PassiveExpiringMap } /** map used to manage expiration times for the actual map entries. */ - private final Map expirationMap = new HashMap(); + private final Map expirationMap = new HashMap<>(); /** the policy used to determine time-to-live values for map entries. */ private final ExpirationPolicy expiringPolicy; diff --git a/src/main/java/org/apache/commons/collections4/map/PredicatedMap.java b/src/main/java/org/apache/commons/collections4/map/PredicatedMap.java index d895fa756..948cd7323 100644 --- a/src/main/java/org/apache/commons/collections4/map/PredicatedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/PredicatedMap.java @@ -78,7 +78,7 @@ public class PredicatedMap public static PredicatedMap predicatedMap(final Map map, final Predicate keyPredicate, final Predicate valuePredicate) { - return new PredicatedMap(map, keyPredicate, valuePredicate); + return new PredicatedMap<>(map, keyPredicate, valuePredicate); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/map/PredicatedSortedMap.java b/src/main/java/org/apache/commons/collections4/map/PredicatedSortedMap.java index 11f1e4b70..935654ee7 100644 --- a/src/main/java/org/apache/commons/collections4/map/PredicatedSortedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/PredicatedSortedMap.java @@ -70,7 +70,7 @@ public class PredicatedSortedMap extends PredicatedMap implements So */ public static PredicatedSortedMap predicatedSortedMap(final SortedMap map, final Predicate keyPredicate, final Predicate valuePredicate) { - return new PredicatedSortedMap(map, keyPredicate, valuePredicate); + return new PredicatedSortedMap<>(map, keyPredicate, valuePredicate); } //----------------------------------------------------------------------- @@ -116,19 +116,19 @@ public class PredicatedSortedMap extends PredicatedMap implements So @Override public SortedMap subMap(final K fromKey, final K toKey) { final SortedMap map = getSortedMap().subMap(fromKey, toKey); - return new PredicatedSortedMap(map, keyPredicate, valuePredicate); + return new PredicatedSortedMap<>(map, keyPredicate, valuePredicate); } @Override public SortedMap headMap(final K toKey) { final SortedMap map = getSortedMap().headMap(toKey); - return new PredicatedSortedMap(map, keyPredicate, valuePredicate); + return new PredicatedSortedMap<>(map, keyPredicate, valuePredicate); } @Override public SortedMap tailMap(final K fromKey) { final SortedMap map = getSortedMap().tailMap(fromKey); - return new PredicatedSortedMap(map, keyPredicate, valuePredicate); + return new PredicatedSortedMap<>(map, keyPredicate, valuePredicate); } } diff --git a/src/main/java/org/apache/commons/collections4/map/SingletonMap.java b/src/main/java/org/apache/commons/collections4/map/SingletonMap.java index 342d4eb41..ff8373718 100644 --- a/src/main/java/org/apache/commons/collections4/map/SingletonMap.java +++ b/src/main/java/org/apache/commons/collections4/map/SingletonMap.java @@ -318,7 +318,7 @@ public class SingletonMap */ @Override public Set> entrySet() { - final Map.Entry entry = new TiedMapEntry(this, getKey()); + final Map.Entry entry = new TiedMapEntry<>(this, getKey()); return Collections.singleton(entry); } @@ -343,7 +343,7 @@ public class SingletonMap */ @Override public Collection values() { - return new SingletonValues(this); + return new SingletonValues<>(this); } /** @@ -351,7 +351,7 @@ public class SingletonMap */ @Override public OrderedMapIterator mapIterator() { - return new SingletonMapIterator(this); + return new SingletonMapIterator<>(this); } /** @@ -534,7 +534,7 @@ public class SingletonMap } @Override public Iterator iterator() { - return new SingletonIterator(parent.getValue(), false); + return new SingletonIterator<>(parent.getValue(), false); } } diff --git a/src/main/java/org/apache/commons/collections4/map/StaticBucketMap.java b/src/main/java/org/apache/commons/collections4/map/StaticBucketMap.java index 10bb1d7a1..a62197d8e 100644 --- a/src/main/java/org/apache/commons/collections4/map/StaticBucketMap.java +++ b/src/main/java/org/apache/commons/collections4/map/StaticBucketMap.java @@ -281,7 +281,7 @@ public final class StaticBucketMap extends AbstractIterableMap { Node n = buckets[hash]; if (n == null) { - n = new Node(); + n = new Node<>(); n.key = key; n.value = value; buckets[hash] = n; @@ -304,7 +304,7 @@ public final class StaticBucketMap extends AbstractIterableMap { // The key was not found in the current list of nodes, add it to the end // in a new node. - final Node newNode = new Node(); + final Node newNode = new Node<>(); newNode.key = key; newNode.value = value; n.next = newNode; @@ -504,7 +504,7 @@ public final class StaticBucketMap extends AbstractIterableMap { //----------------------------------------------------------------------- private class BaseIterator { - private final ArrayList> current = new ArrayList>(); + private final ArrayList> current = new ArrayList<>(); private int bucket; private Map.Entry last; diff --git a/src/main/java/org/apache/commons/collections4/map/TransformedMap.java b/src/main/java/org/apache/commons/collections4/map/TransformedMap.java index 5b57bc648..4a88259b4 100644 --- a/src/main/java/org/apache/commons/collections4/map/TransformedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/TransformedMap.java @@ -76,7 +76,7 @@ public class TransformedMap public static TransformedMap transformingMap(final Map map, final Transformer keyTransformer, final Transformer valueTransformer) { - return new TransformedMap(map, keyTransformer, valueTransformer); + return new TransformedMap<>(map, keyTransformer, valueTransformer); } /** @@ -99,7 +99,7 @@ public class TransformedMap public static TransformedMap transformedMap(final Map map, final Transformer keyTransformer, final Transformer valueTransformer) { - final TransformedMap decorated = new TransformedMap(map, keyTransformer, valueTransformer); + final TransformedMap decorated = new TransformedMap<>(map, keyTransformer, valueTransformer); if (map.size() > 0) { final Map transformed = decorated.transformMap(map); decorated.clear(); @@ -198,7 +198,7 @@ public class TransformedMap if (map.isEmpty()) { return (Map) map; } - final Map result = new LinkedMap(map.size()); + final Map result = new LinkedMap<>(map.size()); for (final Map.Entry entry : map.entrySet()) { result.put(transformKey(entry.getKey()), transformValue(entry.getValue())); diff --git a/src/main/java/org/apache/commons/collections4/map/TransformedSortedMap.java b/src/main/java/org/apache/commons/collections4/map/TransformedSortedMap.java index 56756118e..04273a365 100644 --- a/src/main/java/org/apache/commons/collections4/map/TransformedSortedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/TransformedSortedMap.java @@ -66,7 +66,7 @@ public class TransformedSortedMap public static TransformedSortedMap transformingSortedMap(final SortedMap map, final Transformer keyTransformer, final Transformer valueTransformer) { - return new TransformedSortedMap(map, keyTransformer, valueTransformer); + return new TransformedSortedMap<>(map, keyTransformer, valueTransformer); } /** @@ -91,7 +91,7 @@ public class TransformedSortedMap final Transformer valueTransformer) { final TransformedSortedMap decorated = - new TransformedSortedMap(map, keyTransformer, valueTransformer); + new TransformedSortedMap<>(map, keyTransformer, valueTransformer); if (map.size() > 0) { final Map transformed = decorated.transformMap(map); decorated.clear(); @@ -147,19 +147,19 @@ public class TransformedSortedMap @Override public SortedMap subMap(final K fromKey, final K toKey) { final SortedMap map = getSortedMap().subMap(fromKey, toKey); - return new TransformedSortedMap(map, keyTransformer, valueTransformer); + return new TransformedSortedMap<>(map, keyTransformer, valueTransformer); } @Override public SortedMap headMap(final K toKey) { final SortedMap map = getSortedMap().headMap(toKey); - return new TransformedSortedMap(map, keyTransformer, valueTransformer); + return new TransformedSortedMap<>(map, keyTransformer, valueTransformer); } @Override public SortedMap tailMap(final K fromKey) { final SortedMap map = getSortedMap().tailMap(fromKey); - return new TransformedSortedMap(map, keyTransformer, valueTransformer); + return new TransformedSortedMap<>(map, keyTransformer, valueTransformer); } } diff --git a/src/main/java/org/apache/commons/collections4/map/UnmodifiableEntrySet.java b/src/main/java/org/apache/commons/collections4/map/UnmodifiableEntrySet.java index 99683f62b..088f1f85a 100644 --- a/src/main/java/org/apache/commons/collections4/map/UnmodifiableEntrySet.java +++ b/src/main/java/org/apache/commons/collections4/map/UnmodifiableEntrySet.java @@ -55,7 +55,7 @@ public final class UnmodifiableEntrySet if (set instanceof Unmodifiable) { return set; } - return new UnmodifiableEntrySet(set); + return new UnmodifiableEntrySet<>(set); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/map/UnmodifiableMap.java b/src/main/java/org/apache/commons/collections4/map/UnmodifiableMap.java index c702363f6..6237b7896 100644 --- a/src/main/java/org/apache/commons/collections4/map/UnmodifiableMap.java +++ b/src/main/java/org/apache/commons/collections4/map/UnmodifiableMap.java @@ -65,7 +65,7 @@ public final class UnmodifiableMap final Map tmpMap = (Map) map; return tmpMap; } - return new UnmodifiableMap(map); + return new UnmodifiableMap<>(map); } //----------------------------------------------------------------------- @@ -134,7 +134,7 @@ public final class UnmodifiableMap final MapIterator it = ((IterableMap) map).mapIterator(); return UnmodifiableMapIterator.unmodifiableMapIterator(it); } - final MapIterator it = new EntrySetMapIterator(map); + final MapIterator it = new EntrySetMapIterator<>(map); return UnmodifiableMapIterator.unmodifiableMapIterator(it); } diff --git a/src/main/java/org/apache/commons/collections4/map/UnmodifiableOrderedMap.java b/src/main/java/org/apache/commons/collections4/map/UnmodifiableOrderedMap.java index 848961ca4..c180a23d4 100644 --- a/src/main/java/org/apache/commons/collections4/map/UnmodifiableOrderedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/UnmodifiableOrderedMap.java @@ -63,7 +63,7 @@ public final class UnmodifiableOrderedMap extends AbstractOrderedMapDecora final OrderedMap tmpMap = (OrderedMap) map; return tmpMap; } - return new UnmodifiableOrderedMap(map); + return new UnmodifiableOrderedMap<>(map); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/map/UnmodifiableSortedMap.java b/src/main/java/org/apache/commons/collections4/map/UnmodifiableSortedMap.java index 683aba836..78bfe8715 100644 --- a/src/main/java/org/apache/commons/collections4/map/UnmodifiableSortedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/UnmodifiableSortedMap.java @@ -63,7 +63,7 @@ public final class UnmodifiableSortedMap final SortedMap tmpMap = (SortedMap) map; return tmpMap; } - return new UnmodifiableSortedMap(map); + return new UnmodifiableSortedMap<>(map); } //----------------------------------------------------------------------- @@ -159,17 +159,17 @@ public final class UnmodifiableSortedMap @Override public SortedMap subMap(final K fromKey, final K toKey) { - return new UnmodifiableSortedMap(decorated().subMap(fromKey, toKey)); + return new UnmodifiableSortedMap<>(decorated().subMap(fromKey, toKey)); } @Override public SortedMap headMap(final K toKey) { - return new UnmodifiableSortedMap(decorated().headMap(toKey)); + return new UnmodifiableSortedMap<>(decorated().headMap(toKey)); } @Override public SortedMap tailMap(final K fromKey) { - return new UnmodifiableSortedMap(decorated().tailMap(fromKey)); + return new UnmodifiableSortedMap<>(decorated().tailMap(fromKey)); } } diff --git a/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java b/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java index dbb5cc242..f4c97fbec 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java @@ -619,7 +619,7 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap> iterator() { return new LazyIteratorChain>() { - final Collection keysCol = new ArrayList(getMap().keySet()); + final Collection keysCol = new ArrayList<>(getMap().keySet()); final Iterator keyIterator = keysCol.iterator(); @Override @@ -636,7 +636,7 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap>(new ValuesIterator(key), entryTransformer); + return new TransformIterator<>(new ValuesIterator(key), entryTransformer); } }; } @@ -725,7 +725,7 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap { @Override public Iterator iterator() { - final IteratorChain chain = new IteratorChain(); + final IteratorChain chain = new IteratorChain<>(); for (final K k : keySet()) { chain.addIterator(new ValuesIterator(k)); } @@ -896,7 +896,7 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap> next() { final Map.Entry> entry = super.next(); final K key = entry.getKey(); - return new UnmodifiableMapEntry>(key, wrappedCollection(key)); + return new UnmodifiableMapEntry<>(key, wrappedCollection(key)); } } } diff --git a/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java b/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java index 41f1581d4..dfaf13bef 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java @@ -114,7 +114,7 @@ public class ArrayListValuedHashMap extends AbstractListValuedMap // ----------------------------------------------------------------------- @Override protected ArrayList createCollection() { - return new ArrayList(initialListCapacity); + return new ArrayList<>(initialListCapacity); } // ----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/multimap/HashSetValuedHashMap.java b/src/main/java/org/apache/commons/collections4/multimap/HashSetValuedHashMap.java index c6fd845be..a1ad0a967 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/HashSetValuedHashMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/HashSetValuedHashMap.java @@ -113,7 +113,7 @@ public class HashSetValuedHashMap extends AbstractSetValuedMap // ----------------------------------------------------------------------- @Override protected HashSet createCollection() { - return new HashSet(initialSetCapacity); + return new HashSet<>(initialSetCapacity); } // ----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java b/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java index 93a4a8b38..acef611f9 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java @@ -66,7 +66,7 @@ public class TransformedMultiValuedMap extends AbstractMultiValuedMapDecor public static TransformedMultiValuedMap transformingMap(final MultiValuedMap map, final Transformer keyTransformer, final Transformer valueTransformer) { - return new TransformedMultiValuedMap(map, keyTransformer, valueTransformer); + return new TransformedMultiValuedMap<>(map, keyTransformer, valueTransformer); } /** @@ -89,9 +89,9 @@ public class TransformedMultiValuedMap extends AbstractMultiValuedMapDecor final Transformer keyTransformer, final Transformer valueTransformer) { final TransformedMultiValuedMap decorated = - new TransformedMultiValuedMap(map, keyTransformer, valueTransformer); + new TransformedMultiValuedMap<>(map, keyTransformer, valueTransformer); if (!map.isEmpty()) { - final MultiValuedMap mapCopy = new ArrayListValuedHashMap(map); + final MultiValuedMap mapCopy = new ArrayListValuedHashMap<>(map); decorated.clear(); decorated.putAll(mapCopy); } diff --git a/src/main/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMap.java b/src/main/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMap.java index d18e8e8b6..2370b1adb 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMap.java @@ -65,7 +65,7 @@ public final class UnmodifiableMultiValuedMap if (map instanceof Unmodifiable) { return (UnmodifiableMultiValuedMap) map; } - return new UnmodifiableMultiValuedMap(map); + return new UnmodifiableMultiValuedMap<>(map); } /** diff --git a/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java index 0336f28df..d0f22cf95 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java @@ -145,7 +145,7 @@ public abstract class AbstractMapMultiSet extends AbstractMultiSet { */ @Override public Iterator iterator() { - return new MapBasedMultiSetIterator(this); + return new MapBasedMultiSetIterator<>(this); } /** @@ -303,7 +303,7 @@ public abstract class AbstractMapMultiSet extends AbstractMultiSet { //----------------------------------------------------------------------- @Override protected Iterator createUniqueSetIterator() { - return new UniqueSetIterator(getMap().keySet().iterator(), this); + return new UniqueSetIterator<>(getMap().keySet().iterator(), this); } @Override @@ -313,7 +313,7 @@ public abstract class AbstractMapMultiSet extends AbstractMultiSet { @Override protected Iterator> createEntrySetIterator() { - return new EntrySetIterator(map.entrySet().iterator(), this); + return new EntrySetIterator<>(map.entrySet().iterator(), this); } //----------------------------------------------------------------------- @@ -395,7 +395,7 @@ public abstract class AbstractMapMultiSet extends AbstractMultiSet { @Override public Entry next() { - last = new MultiSetEntry(decorated.next()); + last = new MultiSetEntry<>(decorated.next()); canRemove = true; return last; } diff --git a/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java index 5e26869ae..22191af57 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java @@ -120,7 +120,7 @@ public abstract class AbstractMultiSet extends AbstractCollection implemen */ @Override public Iterator iterator() { - return new MultiSetIterator(this); + return new MultiSetIterator<>(this); } /** @@ -246,7 +246,7 @@ public abstract class AbstractMultiSet extends AbstractCollection implemen * @return a view of the set of unique elements */ protected Set createUniqueSet() { - return new UniqueSet(this); + return new UniqueSet<>(this); } /** @@ -284,7 +284,7 @@ public abstract class AbstractMultiSet extends AbstractCollection implemen * @return a view of the set of entries */ protected Set> createEntrySet() { - return new EntrySet(this); + return new EntrySet<>(this); } /** diff --git a/src/main/java/org/apache/commons/collections4/multiset/PredicatedMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/PredicatedMultiSet.java index 9ffce1b56..420677ae7 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/PredicatedMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/PredicatedMultiSet.java @@ -61,7 +61,7 @@ public class PredicatedMultiSet extends PredicatedCollection implements Mu */ public static PredicatedMultiSet predicatedMultiSet(final MultiSet multiset, final Predicate predicate) { - return new PredicatedMultiSet(multiset, predicate); + return new PredicatedMultiSet<>(multiset, predicate); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/multiset/SynchronizedMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/SynchronizedMultiSet.java index 68729ed02..33ca71045 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/SynchronizedMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/SynchronizedMultiSet.java @@ -45,7 +45,7 @@ public class SynchronizedMultiSet extends SynchronizedCollection implement * @throws NullPointerException if multiset is null */ public static SynchronizedMultiSet synchronizedMultiSet(final MultiSet multiset) { - return new SynchronizedMultiSet(multiset); + return new SynchronizedMultiSet<>(multiset); } //----------------------------------------------------------------------- @@ -131,7 +131,7 @@ public class SynchronizedMultiSet extends SynchronizedCollection implement public Set uniqueSet() { synchronized (lock) { final Set set = decorated().uniqueSet(); - return new SynchronizedSet(set, lock); + return new SynchronizedSet<>(set, lock); } } @@ -139,7 +139,7 @@ public class SynchronizedMultiSet extends SynchronizedCollection implement public Set> entrySet() { synchronized (lock) { final Set> set = decorated().entrySet(); - return new SynchronizedSet>(set, lock); + return new SynchronizedSet<>(set, lock); } } diff --git a/src/main/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSet.java index 43095eb3f..53985214b 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSet.java @@ -58,7 +58,7 @@ public final class UnmodifiableMultiSet final MultiSet tmpMultiSet = (MultiSet) multiset; return tmpMultiSet; } - return new UnmodifiableMultiSet(multiset); + return new UnmodifiableMultiSet<>(multiset); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/properties/SortedProperties.java b/src/main/java/org/apache/commons/collections4/properties/SortedProperties.java index a9c196cf0..e5c9f1922 100644 --- a/src/main/java/org/apache/commons/collections4/properties/SortedProperties.java +++ b/src/main/java/org/apache/commons/collections4/properties/SortedProperties.java @@ -41,7 +41,7 @@ public class SortedProperties extends Properties { @Override public synchronized Enumeration keys() { final Set keySet = keySet(); - final List keys = new ArrayList(keySet.size()); + final List keys = new ArrayList<>(keySet.size()); for (final Object key : keySet) { keys.add(key.toString()); } diff --git a/src/main/java/org/apache/commons/collections4/queue/PredicatedQueue.java b/src/main/java/org/apache/commons/collections4/queue/PredicatedQueue.java index 334edd331..507ab59e0 100644 --- a/src/main/java/org/apache/commons/collections4/queue/PredicatedQueue.java +++ b/src/main/java/org/apache/commons/collections4/queue/PredicatedQueue.java @@ -55,7 +55,7 @@ public class PredicatedQueue extends PredicatedCollection implements Queue */ public static PredicatedQueue predicatedQueue(final Queue Queue, final Predicate predicate) { - return new PredicatedQueue(Queue, predicate); + return new PredicatedQueue<>(Queue, predicate); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/queue/TransformedQueue.java b/src/main/java/org/apache/commons/collections4/queue/TransformedQueue.java index 0f321d744..b2ac4dfbe 100644 --- a/src/main/java/org/apache/commons/collections4/queue/TransformedQueue.java +++ b/src/main/java/org/apache/commons/collections4/queue/TransformedQueue.java @@ -52,7 +52,7 @@ public class TransformedQueue extends TransformedCollection implements Que */ public static TransformedQueue transformingQueue(final Queue queue, final Transformer transformer) { - return new TransformedQueue(queue, transformer); + return new TransformedQueue<>(queue, transformer); } /** @@ -73,7 +73,7 @@ public class TransformedQueue extends TransformedCollection implements Que public static TransformedQueue transformedQueue(final Queue queue, final Transformer transformer) { // throws IAE if queue or transformer is null - final TransformedQueue decorated = new TransformedQueue(queue, transformer); + final TransformedQueue decorated = new TransformedQueue<>(queue, transformer); if (queue.size() > 0) { @SuppressWarnings("unchecked") // queue is type final E[] values = (E[]) queue.toArray(); // NOPMD - false positive for generics diff --git a/src/main/java/org/apache/commons/collections4/queue/UnmodifiableQueue.java b/src/main/java/org/apache/commons/collections4/queue/UnmodifiableQueue.java index 05451c9bb..5c8384be4 100644 --- a/src/main/java/org/apache/commons/collections4/queue/UnmodifiableQueue.java +++ b/src/main/java/org/apache/commons/collections4/queue/UnmodifiableQueue.java @@ -57,7 +57,7 @@ public final class UnmodifiableQueue final Queue tmpQueue = (Queue) queue; return tmpQueue; } - return new UnmodifiableQueue(queue); + return new UnmodifiableQueue<>(queue); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/sequence/EditScript.java b/src/main/java/org/apache/commons/collections4/sequence/EditScript.java index b3e73138c..9e4bbe966 100644 --- a/src/main/java/org/apache/commons/collections4/sequence/EditScript.java +++ b/src/main/java/org/apache/commons/collections4/sequence/EditScript.java @@ -58,7 +58,7 @@ public class EditScript { * Simple constructor. Creates a new empty script. */ public EditScript() { - commands = new ArrayList>(); + commands = new ArrayList<>(); lcsLength = 0; modifications = 0; } diff --git a/src/main/java/org/apache/commons/collections4/sequence/ReplacementsFinder.java b/src/main/java/org/apache/commons/collections4/sequence/ReplacementsFinder.java index 35e562e65..d9e820115 100644 --- a/src/main/java/org/apache/commons/collections4/sequence/ReplacementsFinder.java +++ b/src/main/java/org/apache/commons/collections4/sequence/ReplacementsFinder.java @@ -63,8 +63,8 @@ public class ReplacementsFinder implements CommandVisitor { * @param handler handler to call when synchronized sequences are found */ public ReplacementsFinder(final ReplacementsHandler handler) { - pendingInsertions = new ArrayList(); - pendingDeletions = new ArrayList(); + pendingInsertions = new ArrayList<>(); + pendingDeletions = new ArrayList<>(); skipped = 0; this.handler = handler; } diff --git a/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java b/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java index 690a5e957..908faf885 100644 --- a/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java +++ b/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java @@ -126,7 +126,7 @@ public class SequencesComparator { * sequences */ public EditScript getScript() { - final EditScript script = new EditScript(); + final EditScript script = new EditScript<>(); buildScript(0, sequence1.size(), 0, sequence2.size(), script); return script; } @@ -262,15 +262,15 @@ public class SequencesComparator { int j = start2; while (i < end1 || j < end2) { if (i < end1 && j < end2 && equator.equate(sequence1.get(i), sequence2.get(j))) { - script.append(new KeepCommand(sequence1.get(i))); + script.append(new KeepCommand<>(sequence1.get(i))); ++i; ++j; } else { if (end1 - start1 > end2 - start2) { - script.append(new DeleteCommand(sequence1.get(i))); + script.append(new DeleteCommand<>(sequence1.get(i))); ++i; } else { - script.append(new InsertCommand(sequence2.get(j))); + script.append(new InsertCommand<>(sequence2.get(j))); ++j; } } @@ -282,7 +282,7 @@ public class SequencesComparator { start2, middle.getStart() - middle.getDiag(), script); for (int i = middle.getStart(); i < middle.getEnd(); ++i) { - script.append(new KeepCommand(sequence1.get(i))); + script.append(new KeepCommand<>(sequence1.get(i))); } buildScript(middle.getEnd(), end1, middle.getEnd() - middle.getDiag(), end2, diff --git a/src/main/java/org/apache/commons/collections4/set/CompositeSet.java b/src/main/java/org/apache/commons/collections4/set/CompositeSet.java index 22eccc17c..b71191835 100644 --- a/src/main/java/org/apache/commons/collections4/set/CompositeSet.java +++ b/src/main/java/org/apache/commons/collections4/set/CompositeSet.java @@ -55,7 +55,7 @@ public class CompositeSet implements Set, Serializable { private SetMutator mutator; /** Sets in the composite */ - private final List> all = new ArrayList>(); + private final List> all = new ArrayList<>(); /** * Create an empty CompositeSet. @@ -151,7 +151,7 @@ public class CompositeSet implements Set, Serializable { if (all.isEmpty()) { return EmptyIterator.emptyIterator(); } - final IteratorChain chain = new IteratorChain(); + final IteratorChain chain = new IteratorChain<>(); for (final Set item : all) { chain.addIterator(item.iterator()); } @@ -410,7 +410,7 @@ public class CompositeSet implements Set, Serializable { * The new collection is not backed by this composite. */ public Set toSet() { - return new HashSet(this); + return new HashSet<>(this); } /** diff --git a/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java b/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java index 41f631504..80fea7602 100644 --- a/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java @@ -84,7 +84,7 @@ public class ListOrderedSet if (set.size() > 0 || list.size() > 0) { throw new IllegalArgumentException("Set and List must be empty"); } - return new ListOrderedSet(set, list); + return new ListOrderedSet<>(set, list); } /** @@ -99,7 +99,7 @@ public class ListOrderedSet * @since 4.0 */ public static ListOrderedSet listOrderedSet(final Set set) { - return new ListOrderedSet(set); + return new ListOrderedSet<>(set); } /** @@ -121,9 +121,9 @@ public class ListOrderedSet throw new NullPointerException("List must not be null"); } CollectionUtils.filter(list, UniquePredicate.uniquePredicate()); - final Set set = new HashSet(list); + final Set set = new HashSet<>(list); - return new ListOrderedSet(set, list); + return new ListOrderedSet<>(set, list); } // ----------------------------------------------------------------------- @@ -135,7 +135,7 @@ public class ListOrderedSet */ public ListOrderedSet() { super(new HashSet()); - setOrder = new ArrayList(); + setOrder = new ArrayList<>(); } /** @@ -146,7 +146,7 @@ public class ListOrderedSet */ protected ListOrderedSet(final Set set) { super(set); - setOrder = new ArrayList(set); + setOrder = new ArrayList<>(set); } /** @@ -186,7 +186,7 @@ public class ListOrderedSet @Override public OrderedIterator iterator() { - return new OrderedSetIterator(setOrder.listIterator(), decorated()); + return new OrderedSetIterator<>(setOrder.listIterator(), decorated()); } @Override @@ -320,7 +320,7 @@ public class ListOrderedSet public boolean addAll(final int index, final Collection coll) { boolean changed = false; // collect all elements to be added for performance reasons - final List toAdd = new ArrayList(); + final List toAdd = new ArrayList<>(); for (final E e : coll) { if (contains(e)) { continue; diff --git a/src/main/java/org/apache/commons/collections4/set/MapBackedSet.java b/src/main/java/org/apache/commons/collections4/set/MapBackedSet.java index 0b6182c30..1b5c5499f 100644 --- a/src/main/java/org/apache/commons/collections4/set/MapBackedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/MapBackedSet.java @@ -72,7 +72,7 @@ public final class MapBackedSet implements Set, Serializable { * @since 4.0 */ public static MapBackedSet mapBackedSet(final Map map, final V dummyValue) { - return new MapBackedSet(map, dummyValue); + return new MapBackedSet<>(map, dummyValue); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/set/PredicatedNavigableSet.java b/src/main/java/org/apache/commons/collections4/set/PredicatedNavigableSet.java index 265c8c8b4..8fd2b3b7c 100644 --- a/src/main/java/org/apache/commons/collections4/set/PredicatedNavigableSet.java +++ b/src/main/java/org/apache/commons/collections4/set/PredicatedNavigableSet.java @@ -60,7 +60,7 @@ public class PredicatedNavigableSet extends PredicatedSortedSet implements */ public static PredicatedNavigableSet predicatedNavigableSet(final NavigableSet set, final Predicate predicate) { - return new PredicatedNavigableSet(set, predicate); + return new PredicatedNavigableSet<>(set, predicate); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/set/PredicatedSet.java b/src/main/java/org/apache/commons/collections4/set/PredicatedSet.java index 6ad3c8767..709eed18b 100644 --- a/src/main/java/org/apache/commons/collections4/set/PredicatedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/PredicatedSet.java @@ -57,7 +57,7 @@ public class PredicatedSet extends PredicatedCollection implements Set * @since 4.0 */ public static PredicatedSet predicatedSet(final Set set, final Predicate predicate) { - return new PredicatedSet(set, predicate); + return new PredicatedSet<>(set, predicate); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/set/PredicatedSortedSet.java b/src/main/java/org/apache/commons/collections4/set/PredicatedSortedSet.java index 631a451dc..d44c3f7e7 100644 --- a/src/main/java/org/apache/commons/collections4/set/PredicatedSortedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/PredicatedSortedSet.java @@ -62,7 +62,7 @@ public class PredicatedSortedSet extends PredicatedSet implements SortedSe */ public static PredicatedSortedSet predicatedSortedSet(final SortedSet set, final Predicate predicate) { - return new PredicatedSortedSet(set, predicate); + return new PredicatedSortedSet<>(set, predicate); } //----------------------------------------------------------------------- @@ -110,19 +110,19 @@ public class PredicatedSortedSet extends PredicatedSet implements SortedSe @Override public SortedSet subSet(final E fromElement, final E toElement) { final SortedSet sub = decorated().subSet(fromElement, toElement); - return new PredicatedSortedSet(sub, predicate); + return new PredicatedSortedSet<>(sub, predicate); } @Override public SortedSet headSet(final E toElement) { final SortedSet head = decorated().headSet(toElement); - return new PredicatedSortedSet(head, predicate); + return new PredicatedSortedSet<>(head, predicate); } @Override public SortedSet tailSet(final E fromElement) { final SortedSet tail = decorated().tailSet(fromElement); - return new PredicatedSortedSet(tail, predicate); + return new PredicatedSortedSet<>(tail, predicate); } } diff --git a/src/main/java/org/apache/commons/collections4/set/TransformedNavigableSet.java b/src/main/java/org/apache/commons/collections4/set/TransformedNavigableSet.java index 9d431dc4d..29c046f8f 100644 --- a/src/main/java/org/apache/commons/collections4/set/TransformedNavigableSet.java +++ b/src/main/java/org/apache/commons/collections4/set/TransformedNavigableSet.java @@ -52,7 +52,7 @@ public class TransformedNavigableSet extends TransformedSortedSet implemen */ public static TransformedNavigableSet transformingNavigableSet(final NavigableSet set, final Transformer transformer) { - return new TransformedNavigableSet(set, transformer); + return new TransformedNavigableSet<>(set, transformer); } /** @@ -72,7 +72,7 @@ public class TransformedNavigableSet extends TransformedSortedSet implemen public static TransformedNavigableSet transformedNavigableSet(final NavigableSet set, final Transformer transformer) { - final TransformedNavigableSet decorated = new TransformedNavigableSet(set, transformer); + final TransformedNavigableSet decorated = new TransformedNavigableSet<>(set, transformer); if (set.size() > 0) { @SuppressWarnings("unchecked") // set is type E final E[] values = (E[]) set.toArray(); // NOPMD - false positive for generics diff --git a/src/main/java/org/apache/commons/collections4/set/TransformedSet.java b/src/main/java/org/apache/commons/collections4/set/TransformedSet.java index f0603d05c..ad9c37587 100644 --- a/src/main/java/org/apache/commons/collections4/set/TransformedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/TransformedSet.java @@ -55,7 +55,7 @@ public class TransformedSet extends TransformedCollection implements Set TransformedSet transformingSet(final Set set, final Transformer transformer) { - return new TransformedSet(set, transformer); + return new TransformedSet<>(set, transformer); } /** @@ -74,7 +74,7 @@ public class TransformedSet extends TransformedCollection implements Set Set transformedSet(final Set set, final Transformer transformer) { - final TransformedSet decorated = new TransformedSet(set, transformer); + final TransformedSet decorated = new TransformedSet<>(set, transformer); if (set.size() > 0) { @SuppressWarnings("unchecked") // set is type E final E[] values = (E[]) set.toArray(); // NOPMD - false positive for generics diff --git a/src/main/java/org/apache/commons/collections4/set/TransformedSortedSet.java b/src/main/java/org/apache/commons/collections4/set/TransformedSortedSet.java index 05d8fddc5..aaa9a4a73 100644 --- a/src/main/java/org/apache/commons/collections4/set/TransformedSortedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/TransformedSortedSet.java @@ -55,7 +55,7 @@ public class TransformedSortedSet extends TransformedSet implements Sorted */ public static TransformedSortedSet transformingSortedSet(final SortedSet set, final Transformer transformer) { - return new TransformedSortedSet(set, transformer); + return new TransformedSortedSet<>(set, transformer); } /** @@ -76,7 +76,7 @@ public class TransformedSortedSet extends TransformedSet implements Sorted public static TransformedSortedSet transformedSortedSet(final SortedSet set, final Transformer transformer) { - final TransformedSortedSet decorated = new TransformedSortedSet(set, transformer); + final TransformedSortedSet decorated = new TransformedSortedSet<>(set, transformer); if (set.size() > 0) { @SuppressWarnings("unchecked") // set is type E final E[] values = (E[]) set.toArray(); // NOPMD - false positive for generics @@ -132,19 +132,19 @@ public class TransformedSortedSet extends TransformedSet implements Sorted @Override public SortedSet subSet(final E fromElement, final E toElement) { final SortedSet set = getSortedSet().subSet(fromElement, toElement); - return new TransformedSortedSet(set, transformer); + return new TransformedSortedSet<>(set, transformer); } @Override public SortedSet headSet(final E toElement) { final SortedSet set = getSortedSet().headSet(toElement); - return new TransformedSortedSet(set, transformer); + return new TransformedSortedSet<>(set, transformer); } @Override public SortedSet tailSet(final E fromElement) { final SortedSet set = getSortedSet().tailSet(fromElement); - return new TransformedSortedSet(set, transformer); + return new TransformedSortedSet<>(set, transformer); } } diff --git a/src/main/java/org/apache/commons/collections4/set/UnmodifiableNavigableSet.java b/src/main/java/org/apache/commons/collections4/set/UnmodifiableNavigableSet.java index ec96f3353..3cf0ca8d2 100644 --- a/src/main/java/org/apache/commons/collections4/set/UnmodifiableNavigableSet.java +++ b/src/main/java/org/apache/commons/collections4/set/UnmodifiableNavigableSet.java @@ -54,7 +54,7 @@ public final class UnmodifiableNavigableSet if (set instanceof Unmodifiable) { return set; } - return new UnmodifiableNavigableSet(set); + return new UnmodifiableNavigableSet<>(set); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/set/UnmodifiableSet.java b/src/main/java/org/apache/commons/collections4/set/UnmodifiableSet.java index 40287e53f..38378043a 100644 --- a/src/main/java/org/apache/commons/collections4/set/UnmodifiableSet.java +++ b/src/main/java/org/apache/commons/collections4/set/UnmodifiableSet.java @@ -55,7 +55,7 @@ public final class UnmodifiableSet final Set tmpSet = (Set) set; return tmpSet; } - return new UnmodifiableSet(set); + return new UnmodifiableSet<>(set); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/set/UnmodifiableSortedSet.java b/src/main/java/org/apache/commons/collections4/set/UnmodifiableSortedSet.java index 26f6d8f3e..81d669cdc 100644 --- a/src/main/java/org/apache/commons/collections4/set/UnmodifiableSortedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/UnmodifiableSortedSet.java @@ -56,7 +56,7 @@ public final class UnmodifiableSortedSet if (set instanceof Unmodifiable) { return set; } - return new UnmodifiableSortedSet(set); + return new UnmodifiableSortedSet<>(set); } //----------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/collections4/splitmap/AbstractIterableGetMapDecorator.java b/src/main/java/org/apache/commons/collections4/splitmap/AbstractIterableGetMapDecorator.java index 22ebfc5a6..8aa11ddc0 100644 --- a/src/main/java/org/apache/commons/collections4/splitmap/AbstractIterableGetMapDecorator.java +++ b/src/main/java/org/apache/commons/collections4/splitmap/AbstractIterableGetMapDecorator.java @@ -115,7 +115,7 @@ public class AbstractIterableGetMapDecorator implements IterableGet */ @Override public MapIterator mapIterator() { - return new EntrySetToMapIteratorAdapter(entrySet()); + return new EntrySetToMapIteratorAdapter<>(entrySet()); } @Override diff --git a/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java b/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java index 35e749186..38f779a2d 100644 --- a/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java +++ b/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java @@ -88,7 +88,7 @@ public class TransformedSplitMap extends AbstractIterableGetMapDecor public static TransformedSplitMap transformingMap(final Map map, final Transformer keyTransformer, final Transformer valueTransformer) { - return new TransformedSplitMap(map, keyTransformer, valueTransformer); + return new TransformedSplitMap<>(map, keyTransformer, valueTransformer); } //----------------------------------------------------------------------- @@ -180,7 +180,7 @@ public class TransformedSplitMap extends AbstractIterableGetMapDecor if (map.isEmpty()) { return (Map) map; } - final Map result = new LinkedMap(map.size()); + final Map result = new LinkedMap<>(map.size()); for (final Map.Entry entry : map.entrySet()) { result.put(transformKey(entry.getKey()), transformValue(entry.getValue())); diff --git a/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java b/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java index bd11f75b7..3dd8d99a0 100644 --- a/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java +++ b/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java @@ -46,7 +46,7 @@ abstract class AbstractPatriciaTrie extends AbstractBitwiseTrie { private static final long serialVersionUID = 5155253417231339498L; /** The root node of the {@link Trie}. */ - private transient TrieEntry root = new TrieEntry(null, null, -1); + private transient TrieEntry root = new TrieEntry<>(null, null, -1); /** * Each of these fields are initialized to contain an instance of the @@ -158,7 +158,7 @@ abstract class AbstractPatriciaTrie extends AbstractBitwiseTrie { if (!KeyAnalyzer.isOutOfBoundsIndex(bitIndex)) { if (KeyAnalyzer.isValidBitIndex(bitIndex)) { // in 99.999...9% the case /* NEW KEY+VALUE TUPLE */ - final TrieEntry t = new TrieEntry(key, value, bitIndex); + final TrieEntry t = new TrieEntry<>(key, value, bitIndex); addEntry(t, lengthInBits); incrementSize(); return null; @@ -281,7 +281,7 @@ abstract class AbstractPatriciaTrie extends AbstractBitwiseTrie { */ public Map.Entry select(final K key) { final int lengthInBits = lengthInBits(key); - final Reference> reference = new Reference>(); + final Reference> reference = new Reference<>(); if (!selectR(root.left, -1, key, lengthInBits, reference)) { return reference.get(); } @@ -910,7 +910,7 @@ abstract class AbstractPatriciaTrie extends AbstractBitwiseTrie { final int bitIndex = bitIndex(key, found.key); if (KeyAnalyzer.isValidBitIndex(bitIndex)) { - final TrieEntry added = new TrieEntry(key, null, bitIndex); + final TrieEntry added = new TrieEntry<>(key, null, bitIndex); addEntry(added, lengthInBits); incrementSize(); // must increment because remove will decrement final TrieEntry ceil = nextEntry(added); @@ -972,7 +972,7 @@ abstract class AbstractPatriciaTrie extends AbstractBitwiseTrie { final int bitIndex = bitIndex(key, found.key); if (KeyAnalyzer.isValidBitIndex(bitIndex)) { - final TrieEntry added = new TrieEntry(key, null, bitIndex); + final TrieEntry added = new TrieEntry<>(key, null, bitIndex); addEntry(added, lengthInBits); incrementSize(); // must increment because remove will decrement final TrieEntry ceil = nextEntry(added); @@ -1027,7 +1027,7 @@ abstract class AbstractPatriciaTrie extends AbstractBitwiseTrie { final int bitIndex = bitIndex(key, found.key); if (KeyAnalyzer.isValidBitIndex(bitIndex)) { - final TrieEntry added = new TrieEntry(key, null, bitIndex); + final TrieEntry added = new TrieEntry<>(key, null, bitIndex); addEntry(added, lengthInBits); incrementSize(); // must increment because remove will decrement final TrieEntry prior = previousEntry(added); @@ -1068,7 +1068,7 @@ abstract class AbstractPatriciaTrie extends AbstractBitwiseTrie { final int bitIndex = bitIndex(key, found.key); if (KeyAnalyzer.isValidBitIndex(bitIndex)) { - final TrieEntry added = new TrieEntry(key, null, bitIndex); + final TrieEntry added = new TrieEntry<>(key, null, bitIndex); addEntry(added, lengthInBits); incrementSize(); // must increment because remove will decrement final TrieEntry floor = previousEntry(added); @@ -2427,7 +2427,7 @@ abstract class AbstractPatriciaTrie extends AbstractBitwiseTrie { @SuppressWarnings("unchecked") // This will fail at runtime if the stream is incorrect private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException{ stream.defaultReadObject(); - root = new TrieEntry(null, null, -1); + root = new TrieEntry<>(null, null, -1); int size = stream.readInt(); for(int i = 0; i < size; i++){ K k = (K) stream.readObject(); diff --git a/src/main/java/org/apache/commons/collections4/trie/UnmodifiableTrie.java b/src/main/java/org/apache/commons/collections4/trie/UnmodifiableTrie.java index 596abf67e..e550e3b26 100644 --- a/src/main/java/org/apache/commons/collections4/trie/UnmodifiableTrie.java +++ b/src/main/java/org/apache/commons/collections4/trie/UnmodifiableTrie.java @@ -57,7 +57,7 @@ public class UnmodifiableTrie implements Trie, Serializable, Unmodif final Trie tmpTrie = (Trie) trie; return tmpTrie; } - return new UnmodifiableTrie(trie); + return new UnmodifiableTrie<>(trie); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/collections4/AbstractLinkedListTest.java b/src/test/java/org/apache/commons/collections4/AbstractLinkedListTest.java index 0a1455e50..a51536e8b 100644 --- a/src/test/java/org/apache/commons/collections4/AbstractLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections4/AbstractLinkedListTest.java @@ -207,7 +207,7 @@ public abstract class AbstractLinkedListTest extends AbstractListTest { */ @Override public Collection makeConfirmedCollection() { - return new LinkedList(); + return new LinkedList<>(); } /** @@ -215,7 +215,7 @@ public abstract class AbstractLinkedListTest extends AbstractListTest { */ @Override public Collection makeConfirmedFullCollection() { - final List list = new LinkedList(); + final List list = new LinkedList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } diff --git a/src/test/java/org/apache/commons/collections4/ArrayStackTest.java b/src/test/java/org/apache/commons/collections4/ArrayStackTest.java index 6df55e382..f5db98f98 100644 --- a/src/test/java/org/apache/commons/collections4/ArrayStackTest.java +++ b/src/test/java/org/apache/commons/collections4/ArrayStackTest.java @@ -38,7 +38,7 @@ public class ArrayStackTest extends AbstractArrayListTest { @Override public ArrayStack makeObject() { - return new ArrayStack(); + return new ArrayStack<>(); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/collections4/BagUtilsTest.java b/src/test/java/org/apache/commons/collections4/BagUtilsTest.java index a7f36aedb..04187b493 100644 --- a/src/test/java/org/apache/commons/collections4/BagUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/BagUtilsTest.java @@ -45,7 +45,7 @@ public class BagUtilsTest { @Test public void testSynchronizedBag() { - Bag bag = BagUtils.synchronizedBag(new HashBag()); + Bag bag = BagUtils.synchronizedBag(new HashBag<>()); assertTrue("Returned object should be a SynchronizedBag.", bag instanceof SynchronizedBag); try { @@ -58,7 +58,7 @@ public class BagUtilsTest { @Test public void testUnmodifiableBag() { - Bag bag = BagUtils.unmodifiableBag(new HashBag()); + Bag bag = BagUtils.unmodifiableBag(new HashBag<>()); assertTrue("Returned object should be an UnmodifiableBag.", bag instanceof UnmodifiableBag); try { @@ -73,7 +73,7 @@ public class BagUtilsTest { @Test public void testPredicatedBag() { - Bag bag = BagUtils.predicatedBag(new HashBag(), truePredicate); + Bag bag = BagUtils.predicatedBag(new HashBag<>(), truePredicate); assertTrue("Returned object should be a PredicatedBag.", bag instanceof PredicatedBag); try { @@ -83,7 +83,7 @@ public class BagUtilsTest { // expected } try { - BagUtils.predicatedBag(new HashBag(), null); + BagUtils.predicatedBag(new HashBag<>(), null); fail("Expecting NullPointerException for null predicate."); } catch (final NullPointerException ex) { // expected @@ -92,7 +92,7 @@ public class BagUtilsTest { @Test public void testTransformedBag() { - Bag bag = BagUtils.transformingBag(new HashBag(), nopTransformer); + Bag bag = BagUtils.transformingBag(new HashBag<>(), nopTransformer); assertTrue("Returned object should be an TransformedBag.", bag instanceof TransformedBag); try { @@ -102,7 +102,7 @@ public class BagUtilsTest { // expected } try { - BagUtils.transformingBag(new HashBag(), null); + BagUtils.transformingBag(new HashBag<>(), null); fail("Expecting NullPointerException for null transformer."); } catch (final NullPointerException ex) { // expected @@ -111,7 +111,7 @@ public class BagUtilsTest { @Test public void testSynchronizedSortedBag() { - Bag bag = BagUtils.synchronizedSortedBag(new TreeBag()); + Bag bag = BagUtils.synchronizedSortedBag(new TreeBag<>()); assertTrue("Returned object should be a SynchronizedSortedBag.", bag instanceof SynchronizedSortedBag); try { @@ -124,7 +124,7 @@ public class BagUtilsTest { @Test public void testUnmodifiableSortedBag() { - SortedBag bag = BagUtils.unmodifiableSortedBag(new TreeBag()); + SortedBag bag = BagUtils.unmodifiableSortedBag(new TreeBag<>()); assertTrue("Returned object should be an UnmodifiableSortedBag.", bag instanceof UnmodifiableSortedBag); try { @@ -139,7 +139,7 @@ public class BagUtilsTest { @Test public void testPredicatedSortedBag() { - Bag bag = BagUtils.predicatedSortedBag(new TreeBag(), truePredicate); + Bag bag = BagUtils.predicatedSortedBag(new TreeBag<>(), truePredicate); assertTrue("Returned object should be a PredicatedSortedBag.", bag instanceof PredicatedSortedBag); try { @@ -149,7 +149,7 @@ public class BagUtilsTest { // expected } try { - BagUtils.predicatedSortedBag(new TreeBag(), null); + BagUtils.predicatedSortedBag(new TreeBag<>(), null); fail("Expecting NullPointerException for null predicate."); } catch (final NullPointerException ex) { // expected @@ -158,7 +158,7 @@ public class BagUtilsTest { @Test public void testTransformedSortedBag() { - Bag bag = BagUtils.transformingSortedBag(new TreeBag(), nopTransformer); + Bag bag = BagUtils.transformingSortedBag(new TreeBag<>(), nopTransformer); assertTrue("Returned object should be an TransformedSortedBag", bag instanceof TransformedSortedBag); try { @@ -168,7 +168,7 @@ public class BagUtilsTest { // expected } try { - BagUtils.transformingSortedBag(new TreeBag(), null); + BagUtils.transformingSortedBag(new TreeBag<>(), null); fail("Expecting NullPointerException for null transformer."); } catch (final NullPointerException ex) { // expected diff --git a/src/test/java/org/apache/commons/collections4/BulkTest.java b/src/test/java/org/apache/commons/collections4/BulkTest.java index e21c5e920..38c5fd49a 100644 --- a/src/test/java/org/apache/commons/collections4/BulkTest.java +++ b/src/test/java/org/apache/commons/collections4/BulkTest.java @@ -314,7 +314,7 @@ class BulkTestSuiteMaker { result.setName(prefix); final BulkTest bulk = makeFirstTestCase(startingClass); - ignored = new ArrayList(); + ignored = new ArrayList<>(); final String[] s = bulk.ignoredTests(); if (s != null) { ignored.addAll(Arrays.asList(s)); diff --git a/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java b/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java index 7307e7cd4..7f66bd2de 100644 --- a/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java @@ -113,11 +113,11 @@ public class ClosureUtilsTest { @Test public void testForClosure() { - final MockClosure cmd = new MockClosure(); + final MockClosure cmd = new MockClosure<>(); ClosureUtils.forClosure(5, cmd).execute(null); assertEquals(5, cmd.count); - assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(0, new MockClosure())); - assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(-1, new MockClosure())); + assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(0, new MockClosure<>())); + assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(-1, new MockClosure<>())); assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(1, null)); assertSame(NOPClosure.INSTANCE, ClosureUtils.forClosure(3, null)); assertSame(cmd, ClosureUtils.forClosure(1, cmd)); @@ -128,11 +128,11 @@ public class ClosureUtilsTest { @Test public void testWhileClosure() { - MockClosure cmd = new MockClosure(); + MockClosure cmd = new MockClosure<>(); ClosureUtils.whileClosure(FalsePredicate.falsePredicate(), cmd).execute(null); assertEquals(0, cmd.count); - cmd = new MockClosure(); + cmd = new MockClosure<>(); ClosureUtils.whileClosure(PredicateUtils.uniquePredicate(), cmd).execute(null); assertEquals(1, cmd.count); @@ -155,11 +155,11 @@ public class ClosureUtilsTest { @Test public void testDoWhileClosure() { - MockClosure cmd = new MockClosure(); + MockClosure cmd = new MockClosure<>(); ClosureUtils.doWhileClosure(cmd, FalsePredicate.falsePredicate()).execute(null); assertEquals(1, cmd.count); - cmd = new MockClosure(); + cmd = new MockClosure<>(); ClosureUtils.doWhileClosure(cmd, PredicateUtils.uniquePredicate()).execute(null); assertEquals(2, cmd.count); @@ -175,21 +175,21 @@ public class ClosureUtilsTest { @Test @SuppressWarnings("unchecked") public void testChainedClosure() { - MockClosure a = new MockClosure(); - MockClosure b = new MockClosure(); + MockClosure a = new MockClosure<>(); + MockClosure b = new MockClosure<>(); ClosureUtils.chainedClosure(a, b).execute(null); assertEquals(1, a.count); assertEquals(1, b.count); - a = new MockClosure(); - b = new MockClosure(); + a = new MockClosure<>(); + b = new MockClosure<>(); ClosureUtils.chainedClosure(new Closure[] {a, b, a}).execute(null); assertEquals(2, a.count); assertEquals(1, b.count); - a = new MockClosure(); - b = new MockClosure(); - Collection> coll = new ArrayList>(); + a = new MockClosure<>(); + b = new MockClosure<>(); + Collection> coll = new ArrayList<>(); coll.add(b); coll.add(a); coll.add(b); @@ -217,7 +217,7 @@ public class ClosureUtilsTest { fail(); } catch (final NullPointerException ex) {} try { - coll = new ArrayList>(); + coll = new ArrayList<>(); coll.add(null); coll.add(null); ClosureUtils.chainedClosure(coll); @@ -230,23 +230,23 @@ public class ClosureUtilsTest { @Test public void testIfClosure() { - MockClosure a = new MockClosure(); + MockClosure a = new MockClosure<>(); MockClosure b = null; ClosureUtils.ifClosure(TruePredicate.truePredicate(), a).execute(null); assertEquals(1, a.count); - a = new MockClosure(); + a = new MockClosure<>(); ClosureUtils.ifClosure(FalsePredicate.falsePredicate(), a).execute(null); assertEquals(0, a.count); - a = new MockClosure(); - b = new MockClosure(); + a = new MockClosure<>(); + b = new MockClosure<>(); ClosureUtils.ifClosure(TruePredicate.truePredicate(), a, b).execute(null); assertEquals(1, a.count); assertEquals(0, b.count); - a = new MockClosure(); - b = new MockClosure(); + a = new MockClosure<>(); + b = new MockClosure<>(); ClosureUtils.ifClosure(FalsePredicate.falsePredicate(), a, b).execute(null); assertEquals(0, a.count); assertEquals(1, b.count); @@ -258,8 +258,8 @@ public class ClosureUtilsTest { @Test @SuppressWarnings("unchecked") public void testSwitchClosure() { - final MockClosure a = new MockClosure(); - final MockClosure b = new MockClosure(); + final MockClosure a = new MockClosure<>(); + final MockClosure b = new MockClosure<>(); ClosureUtils.switchClosure( new Predicate[] { EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE") }, new Closure[] { a, b }).execute("WELL"); @@ -276,7 +276,7 @@ public class ClosureUtilsTest { a.reset(); b.reset(); - final MockClosure c = new MockClosure(); + final MockClosure c = new MockClosure<>(); ClosureUtils.switchClosure( new Predicate[] { EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE") }, new Closure[] { a, b }, c).execute("WELL"); @@ -286,7 +286,7 @@ public class ClosureUtilsTest { a.reset(); b.reset(); - final Map, Closure> map = new HashMap, Closure>(); + final Map, Closure> map = new HashMap<>(); map.put(EqualPredicate.equalPredicate("HELLO"), a); map.put(EqualPredicate.equalPredicate("THERE"), b); ClosureUtils.switchClosure(map).execute(null); @@ -349,9 +349,9 @@ public class ClosureUtilsTest { @Test public void testSwitchMapClosure() { - final MockClosure a = new MockClosure(); - final MockClosure b = new MockClosure(); - final Map> map = new HashMap>(); + final MockClosure a = new MockClosure<>(); + final MockClosure b = new MockClosure<>(); + final Map> map = new HashMap<>(); map.put("HELLO", a); map.put("THERE", b); ClosureUtils.switchMapClosure(map).execute(null); @@ -370,7 +370,7 @@ public class ClosureUtilsTest { a.reset(); b.reset(); map.clear(); - final MockClosure c = new MockClosure(); + final MockClosure c = new MockClosure<>(); map.put("HELLO", a); map.put("THERE", b); map.put(null, c); @@ -392,7 +392,7 @@ public class ClosureUtilsTest { @Test public void testTransformerClosure() { - final MockTransformer mock = new MockTransformer(); + final MockTransformer mock = new MockTransformer<>(); final Closure closure = ClosureUtils.asClosure(mock); closure.execute(null); assertEquals(1, mock.count); diff --git a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java index 0765dca8f..b6c0171f5 100644 --- a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java @@ -114,11 +114,11 @@ public class CollectionUtilsTest extends MockTestCase { private Iterable iterableB2 = null; - private final Collection emptyCollection = new ArrayList(1); + private final Collection emptyCollection = new ArrayList<>(1); @Before public void setUp() { - collectionA = new ArrayList(); + collectionA = new ArrayList<>(); collectionA.add(1); collectionA.add(2); collectionA.add(2); @@ -129,7 +129,7 @@ public class CollectionUtilsTest extends MockTestCase { collectionA.add(4); collectionA.add(4); collectionA.add(4); - collectionB = new LinkedList(); + collectionB = new LinkedList<>(); collectionB.add(5L); collectionB.add(4L); collectionB.add(4L); @@ -141,7 +141,7 @@ public class CollectionUtilsTest extends MockTestCase { collectionB.add(2L); collectionB.add(2L); - collectionC = new ArrayList(); + collectionC = new ArrayList<>(); for (final Long l : collectionB) { collectionC.add(l.intValue()); } @@ -155,7 +155,7 @@ public class CollectionUtilsTest extends MockTestCase { iterableA2 = collectionA2; iterableB2 = collectionB2; - collectionD = new ArrayList(); + collectionD = new ArrayList<>(); collectionD.add(1); collectionD.add(3); collectionD.add(3); @@ -165,7 +165,7 @@ public class CollectionUtilsTest extends MockTestCase { collectionD.add(7); collectionD.add(10); - collectionE = new ArrayList(); + collectionE = new ArrayList<>(); collectionE.add(2); collectionE.add(4); collectionE.add(4); @@ -213,7 +213,7 @@ public class CollectionUtilsTest extends MockTestCase { assertEquals(0, CollectionUtils.cardinality(2L, iterableA2)); assertEquals(0, CollectionUtils.cardinality(2, iterableB2)); - final Set set = new HashSet(); + final Set set = new HashSet<>(); set.add("A"); set.add("C"); set.add("E"); @@ -224,7 +224,7 @@ public class CollectionUtilsTest extends MockTestCase { assertEquals(0, CollectionUtils.cardinality("D", set)); assertEquals(1, CollectionUtils.cardinality("E", set)); - final Bag bag = new HashBag(); + final Bag bag = new HashBag<>(); bag.add("A", 3); bag.add("C"); bag.add("E"); @@ -239,7 +239,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test @Deprecated public void cardinalityOfNull() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertEquals(0, CollectionUtils.cardinality(null, list)); { final Map freq = CollectionUtils.getCardinalityMap(list); @@ -285,17 +285,17 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void containsAll() { - final Collection empty = new ArrayList(0); - final Collection one = new ArrayList(1); + final Collection empty = new ArrayList<>(0); + final Collection one = new ArrayList<>(1); one.add("1"); - final Collection two = new ArrayList(1); + final Collection two = new ArrayList<>(1); two.add("2"); - final Collection three = new ArrayList(1); + final Collection three = new ArrayList<>(1); three.add("3"); - final Collection odds = new ArrayList(2); + final Collection odds = new ArrayList<>(2); odds.add("1"); odds.add("3"); - final Collection multiples = new ArrayList(3); + final Collection multiples = new ArrayList<>(3); multiples.add("1"); multiples.add("3"); multiples.add("1"); @@ -321,14 +321,14 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void containsAny() { - final Collection empty = new ArrayList(0); - final Collection one = new ArrayList(1); + final Collection empty = new ArrayList<>(0); + final Collection one = new ArrayList<>(1); one.add("1"); - final Collection two = new ArrayList(1); + final Collection two = new ArrayList<>(1); two.add("2"); - final Collection three = new ArrayList(1); + final Collection three = new ArrayList<>(1); three.add("3"); - final Collection odds = new ArrayList(2); + final Collection odds = new ArrayList<>(2); odds.add("1"); odds.add("3"); @@ -473,7 +473,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testIsSubCollection2() { - final Collection c = new ArrayList(); + final Collection c = new ArrayList<>(); assertTrue(CollectionUtils.isSubCollection(c, collectionA)); assertTrue(!CollectionUtils.isSubCollection(collectionA, c)); c.add(1); @@ -525,7 +525,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testIsEqualCollectionReturnsFalse() { - final List b = new ArrayList(collectionA); + final List b = new ArrayList<>(collectionA); // remove an extra '2', and add a 5. This will increase the size of the cardinality b.remove(1); b.add(5); @@ -535,8 +535,8 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testIsEqualCollection2() { - final Collection a = new ArrayList(); - final Collection b = new ArrayList(); + final Collection a = new ArrayList<>(); + final Collection b = new ArrayList<>(); assertTrue(CollectionUtils.isEqualCollection(a, b)); assertTrue(CollectionUtils.isEqualCollection(b, a)); a.add("1"); @@ -596,8 +596,8 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testIsProperSubCollection() { - final Collection a = new ArrayList(); - final Collection b = new ArrayList(); + final Collection a = new ArrayList<>(); + final Collection b = new ArrayList<>(); assertTrue(!CollectionUtils.isProperSubCollection(a, b)); b.add("1"); assertTrue(CollectionUtils.isProperSubCollection(a, b)); @@ -633,7 +633,7 @@ public class CollectionUtilsTest extends MockTestCase { @Deprecated public void forAllDoCollection() { final Closure> testClosure = ClosureUtils.invokerClosure("clear"); - final Collection> col = new ArrayList>(); + final Collection> col = new ArrayList<>(); col.add(collectionA); col.add(collectionC); Closure> resultClosure = CollectionUtils.forAllDo(col, testClosure); @@ -653,7 +653,7 @@ public class CollectionUtilsTest extends MockTestCase { @Deprecated public void forAllDoIterator() { final Closure> testClosure = ClosureUtils.invokerClosure("clear"); - final Collection> col = new ArrayList>(); + final Collection> col = new ArrayList<>(); col.add(collectionA); col.add(collectionC); Closure> resultClosure = CollectionUtils.forAllDo(col.iterator(), testClosure); @@ -673,7 +673,7 @@ public class CollectionUtilsTest extends MockTestCase { @Deprecated public void forAllDoFailure() { final Closure testClosure = ClosureUtils.invokerClosure("clear"); - final Collection col = new ArrayList(); + final Collection col = new ArrayList<>(); col.add("x"); CollectionUtils.forAllDo(col, testClosure); } @@ -682,7 +682,7 @@ public class CollectionUtilsTest extends MockTestCase { @Deprecated public void forAllButLastDoCollection() { final Closure> testClosure = ClosureUtils.invokerClosure("clear"); - final Collection> col = new ArrayList>(); + final Collection> col = new ArrayList<>(); col.add(collectionA); col.add(collectionB); List lastElement = CollectionUtils.forAllButLastDo(col, testClosure); @@ -726,7 +726,7 @@ public class CollectionUtilsTest extends MockTestCase { @Deprecated public void forAllButLastDoIterator() { final Closure> testClosure = ClosureUtils.invokerClosure("clear"); - final Collection> col = new ArrayList>(); + final Collection> col = new ArrayList<>(); col.add(collectionA); col.add(collectionB); List lastElement = CollectionUtils.forAllButLastDo(col.iterator(), testClosure); @@ -740,11 +740,11 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void getFromMap() { // Unordered map, entries exist - final Map expected = new HashMap(); + final Map expected = new HashMap<>(); expected.put("zeroKey", "zero"); expected.put("oneKey", "one"); - final Map found = new HashMap(); + final Map found = new HashMap<>(); Map.Entry entry = CollectionUtils.get(expected, 0); found.put(entry.getKey(), entry.getValue()); entry = CollectionUtils.get(expected, 1); @@ -766,7 +766,7 @@ public class CollectionUtilsTest extends MockTestCase { } // Sorted map, entries exist, should respect order - final SortedMap map = new TreeMap(); + final SortedMap map = new TreeMap<>(); map.put("zeroKey", "zero"); map.put("oneKey", "one"); Map.Entry test = CollectionUtils.get(map, 1); @@ -792,7 +792,7 @@ public class CollectionUtilsTest extends MockTestCase { assertEquals("zero", string); assertEquals("one", CollectionUtils.get(list, 1)); // list, non-existent entry -- IndexOutOfBoundsException - CollectionUtils.get(new ArrayList(), 2); + CollectionUtils.get(new ArrayList<>(), 2); } @Test @@ -818,7 +818,7 @@ public class CollectionUtilsTest extends MockTestCase { @Deprecated public void getFromEnumeration() throws Exception { // Enumeration, entry exists - final Vector vector = new Vector(); + final Vector vector = new Vector<>(); vector.addElement("zero"); vector.addElement("one"); Enumeration en = vector.elements(); @@ -840,7 +840,7 @@ public class CollectionUtilsTest extends MockTestCase { @Deprecated public void getFromIterable() throws Exception { // Collection, entry exists - final Bag bag = new HashBag(); + final Bag bag = new HashBag<>(); bag.add("element", 1); assertEquals("element", CollectionUtils.get(bag, 0)); @@ -888,7 +888,7 @@ public class CollectionUtilsTest extends MockTestCase { public void testSize_List() { List list = null; assertEquals(0, CollectionUtils.size(list)); - list = new ArrayList(); + list = new ArrayList<>(); assertEquals(0, CollectionUtils.size(list)); list.add("a"); assertEquals(1, CollectionUtils.size(list)); @@ -898,7 +898,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testSize_Map() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); assertEquals(0, CollectionUtils.size(map)); map.put("1", "a"); assertEquals(1, CollectionUtils.size(map)); @@ -934,7 +934,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testSize_Enumeration() { - final Vector list = new Vector(); + final Vector list = new Vector<>(); assertEquals(0, CollectionUtils.size(list.elements())); list.add("a"); assertEquals(1, CollectionUtils.size(list.elements())); @@ -944,7 +944,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testSize_Iterator() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertEquals(0, CollectionUtils.size(list.iterator())); list.add("a"); assertEquals(1, CollectionUtils.size(list.iterator())); @@ -965,7 +965,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testSizeIsEmpty_List() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertEquals(true, CollectionUtils.sizeIsEmpty(list)); list.add("a"); assertEquals(false, CollectionUtils.sizeIsEmpty(list)); @@ -973,7 +973,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testSizeIsEmpty_Map() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); assertEquals(true, CollectionUtils.sizeIsEmpty(map)); map.put("1", "a"); assertEquals(false, CollectionUtils.sizeIsEmpty(map)); @@ -1007,7 +1007,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testSizeIsEmpty_Enumeration() { - final Vector list = new Vector(); + final Vector list = new Vector<>(); assertEquals(true, CollectionUtils.sizeIsEmpty(list.elements())); list.add("a"); assertEquals(false, CollectionUtils.sizeIsEmpty(list.elements())); @@ -1018,7 +1018,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testSizeIsEmpty_Iterator() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertEquals(true, CollectionUtils.sizeIsEmpty(list.iterator())); list.add("a"); assertEquals(false, CollectionUtils.sizeIsEmpty(list.iterator())); @@ -1039,13 +1039,13 @@ public class CollectionUtilsTest extends MockTestCase { // ----------------------------------------------------------------------- @Test public void testIsEmptyWithEmptyCollection() { - final Collection coll = new ArrayList(); + final Collection coll = new ArrayList<>(); assertEquals(true, CollectionUtils.isEmpty(coll)); } @Test public void testIsEmptyWithNonEmptyCollection() { - final Collection coll = new ArrayList(); + final Collection coll = new ArrayList<>(); coll.add("item"); assertEquals(false, CollectionUtils.isEmpty(coll)); } @@ -1058,13 +1058,13 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testIsNotEmptyWithEmptyCollection() { - final Collection coll = new ArrayList(); + final Collection coll = new ArrayList<>(); assertEquals(false, CollectionUtils.isNotEmpty(coll)); } @Test public void testIsNotEmptyWithNonEmptyCollection() { - final Collection coll = new ArrayList(); + final Collection coll = new ArrayList<>(); coll.add("item"); assertEquals(true, CollectionUtils.isNotEmpty(coll)); } @@ -1086,7 +1086,7 @@ public class CollectionUtilsTest extends MockTestCase { //Up to here @Test public void filter() { - final List ints = new ArrayList(); + final List ints = new ArrayList<>(); ints.add(1); ints.add(2); ints.add(3); @@ -1110,7 +1110,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void filterInverse() { - final List ints = new ArrayList(); + final List ints = new ArrayList<>(); ints.add(1); ints.add(2); ints.add(3); @@ -1146,7 +1146,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test @Deprecated public void exists() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertFalse(CollectionUtils.exists(null, null)); assertFalse(CollectionUtils.exists(list, null)); assertFalse(CollectionUtils.exists(null, EQUALS_TWO)); @@ -1162,7 +1162,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void select() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(1); list.add(2); list.add(3); @@ -1179,14 +1179,14 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void selectWithOutputCollections() { - List input = new ArrayList(); + List input = new ArrayList<>(); input.add(1); input.add(2); input.add(3); input.add(4); - List output = new ArrayList(); - List rejected = new ArrayList(); + List output = new ArrayList<>(); + List rejected = new ArrayList<>(); CollectionUtils.select(input, EQUALS_TWO, output, rejected); @@ -1207,7 +1207,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void selectRejected() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(1L); list.add(2L); list.add(3L); @@ -1273,7 +1273,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void transform1() { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(1L); list.add(2L); list.add(3L); @@ -1283,7 +1283,7 @@ public class CollectionUtilsTest extends MockTestCase { assertEquals(2, list.get(1)); assertEquals(3, list.get(2)); - list = new ArrayList(); + list = new ArrayList<>(); list.add(1L); list.add(2L); list.add(3L); @@ -1297,7 +1297,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void transform2() { - final Set set = new HashSet(); + final Set set = new HashSet<>(); set.add(1L); set.add(2L); set.add(3L); @@ -1314,7 +1314,7 @@ public class CollectionUtilsTest extends MockTestCase { // ----------------------------------------------------------------------- @Test public void addIgnoreNull() { - final Set set = new HashSet(); + final Set set = new HashSet<>(); set.add("1"); set.add("2"); set.add("3"); @@ -1349,7 +1349,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void isFull() { - final Set set = new HashSet(); + final Set set = new HashSet<>(); set.add("1"); set.add("2"); set.add("3"); @@ -1360,7 +1360,7 @@ public class CollectionUtilsTest extends MockTestCase { } assertFalse(CollectionUtils.isFull(set)); - final CircularFifoQueue buf = new CircularFifoQueue(set); + final CircularFifoQueue buf = new CircularFifoQueue<>(set); assertEquals(false, CollectionUtils.isFull(buf)); buf.remove("2"); assertFalse(CollectionUtils.isFull(buf)); @@ -1376,7 +1376,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void maxSize() { - final Set set = new HashSet(); + final Set set = new HashSet<>(); set.add("1"); set.add("2"); set.add("3"); @@ -1387,7 +1387,7 @@ public class CollectionUtilsTest extends MockTestCase { } assertEquals(-1, CollectionUtils.maxSize(set)); - final Queue buf = new CircularFifoQueue(set); + final Queue buf = new CircularFifoQueue<>(set); assertEquals(3, CollectionUtils.maxSize(buf)); buf.remove("2"); assertEquals(3, CollectionUtils.maxSize(buf)); @@ -1409,8 +1409,8 @@ public class CollectionUtilsTest extends MockTestCase { assertTrue(elta != eltb); // Let cola and colb be collections... - final Collection cola = new ArrayList(); - final Collection colb = new ArrayList(); + final Collection cola = new ArrayList<>(); + final Collection colb = new ArrayList<>(); // ...which contain elta and eltb, // respectively. @@ -1440,11 +1440,11 @@ public class CollectionUtilsTest extends MockTestCase { //Up to here @Test public void testRetainAll() { - final List base = new ArrayList(); + final List base = new ArrayList<>(); base.add("A"); base.add("B"); base.add("C"); - final List sub = new ArrayList(); + final List sub = new ArrayList<>(); sub.add("A"); sub.add("C"); sub.add("X"); @@ -1472,11 +1472,11 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testRemoveAll() { - final List base = new ArrayList(); + final List base = new ArrayList<>(); base.add("A"); base.add("B"); base.add("C"); - final List sub = new ArrayList(); + final List sub = new ArrayList<>(); sub.add("A"); sub.add("C"); sub.add("X"); @@ -1506,10 +1506,10 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testTransformedCollection() { final Transformer transformer = TransformerUtils.nopTransformer(); - Collection collection = CollectionUtils.transformingCollection(new ArrayList(), transformer); + Collection collection = CollectionUtils.transformingCollection(new ArrayList<>(), transformer); assertTrue("returned object should be a TransformedCollection", collection instanceof TransformedCollection); try { - CollectionUtils.transformingCollection(new ArrayList(), null); + CollectionUtils.transformingCollection(new ArrayList<>(), null); fail("Expecting NullPointerException for null transformer."); } catch (final NullPointerException ex) { // expected @@ -1524,7 +1524,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testTransformedCollection_2() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add("1"); list.add("2"); list.add("3"); @@ -1537,7 +1537,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test @Deprecated public void testSynchronizedCollection() { - Collection col = CollectionUtils.synchronizedCollection(new ArrayList()); + Collection col = CollectionUtils.synchronizedCollection(new ArrayList<>()); assertTrue("Returned object should be a SynchronizedCollection.", col instanceof SynchronizedCollection); try { CollectionUtils.synchronizedCollection(null); @@ -1550,7 +1550,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test @Deprecated public void testUnmodifiableCollection() { - Collection col = CollectionUtils.unmodifiableCollection(new ArrayList()); + Collection col = CollectionUtils.unmodifiableCollection(new ArrayList<>()); assertTrue("Returned object should be a UnmodifiableCollection.", col instanceof UnmodifiableCollection); try { CollectionUtils.unmodifiableCollection(null); @@ -1569,7 +1569,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void emptyIfNull() { assertTrue(CollectionUtils.emptyIfNull(null).isEmpty()); - final Collection collection = new ArrayList(); + final Collection collection = new ArrayList<>(); assertSame(collection, CollectionUtils.emptyIfNull(collection)); } @@ -1617,7 +1617,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void addAllForEnumeration() { - final Hashtable h = new Hashtable(); + final Hashtable h = new Hashtable<>(); h.put(5, 5); final Enumeration enumeration = h.keys(); CollectionUtils.addAll(collectionA, enumeration); @@ -1664,7 +1664,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void getEnumeration() { - final Vector vectorA = new Vector(collectionA); + final Vector vectorA = new Vector<>(collectionA); final Enumeration e = vectorA.elements(); assertEquals(Integer.valueOf(2), CollectionUtils.get(e, 2)); assertTrue(e.hasMoreElements()); @@ -1690,7 +1690,7 @@ public class CollectionUtilsTest extends MockTestCase { fail("expected NullPointerException from extractSingleton(null)"); } catch (final NullPointerException e) { } - coll = new ArrayList(); + coll = new ArrayList<>(); try { CollectionUtils.extractSingleton(coll); fail("expected IllegalArgumentException from extractSingleton(empty)"); @@ -1736,7 +1736,7 @@ public class CollectionUtilsTest extends MockTestCase { List result2 = CollectionUtils.collate(collectionE, collectionD); assertEquals("Merge two lists 1", result1, result2); - List combinedList = new ArrayList(); + List combinedList = new ArrayList<>(); combinedList.addAll(collectionD); combinedList.addAll(collectionE); Collections.sort(combinedList); @@ -1765,10 +1765,10 @@ public class CollectionUtilsTest extends MockTestCase { List result2 = CollectionUtils.collate(collectionE, collectionD, false); assertEquals("Merge two lists 1 - ignore duplicates", result1, result2); - Set combinedSet = new HashSet(); + Set combinedSet = new HashSet<>(); combinedSet.addAll(collectionD); combinedSet.addAll(collectionE); - List combinedList = new ArrayList(combinedSet); + List combinedList = new ArrayList<>(combinedSet); Collections.sort(combinedList); assertEquals("Merge two lists 2 - ignore duplicates", combinedList, result2); @@ -1821,12 +1821,12 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testRemoveAllWithEquator() { - final List base = new ArrayList(); + final List base = new ArrayList<>(); base.add("AC"); base.add("BB"); base.add("CA"); - final List remove = new ArrayList(); + final List remove = new ArrayList<>(); remove.add("AA"); remove.add("CX"); remove.add("XZ"); @@ -1873,12 +1873,12 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testRetainAllWithEquator() { - final List base = new ArrayList(); + final List base = new ArrayList<>(); base.add("AC"); base.add("BB"); base.add("CA"); - final List retain = new ArrayList(); + final List retain = new ArrayList<>(); retain.add("AA"); retain.add("CX"); retain.add("XZ"); diff --git a/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java b/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java index 28a938a35..bfb74e7c1 100644 --- a/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/EnumerationUtilsTest.java @@ -40,12 +40,12 @@ public class EnumerationUtilsTest { @Test public void testToListWithStringTokenizer() { - final List expectedList1 = new ArrayList(); + final List expectedList1 = new ArrayList<>(); final StringTokenizer st = new StringTokenizer(TO_LIST_FIXTURE); while (st.hasMoreTokens()) { expectedList1.add(st.nextToken()); } - final List expectedList2 = new ArrayList(); + final List expectedList2 = new ArrayList<>(); expectedList2.add("this"); expectedList2.add("is"); expectedList2.add("a"); @@ -58,7 +58,7 @@ public class EnumerationUtilsTest { @Test public void testToListWithHashtable() { - final Hashtable expected = new Hashtable(); + final Hashtable expected = new Hashtable<>(); expected.put("one", Integer.valueOf(1)); expected.put("two", Integer.valueOf(2)); expected.put("three", Integer.valueOf(3)); @@ -68,7 +68,7 @@ public class EnumerationUtilsTest { assertTrue(actualEltList.contains(Integer.valueOf(1))); assertTrue(actualEltList.contains(Integer.valueOf(2))); assertTrue(actualEltList.contains(Integer.valueOf(3))); - final List expectedEltList = new ArrayList(); + final List expectedEltList = new ArrayList<>(); expectedEltList.add(Integer.valueOf(1)); expectedEltList.add(Integer.valueOf(2)); expectedEltList.add(Integer.valueOf(3)); @@ -80,7 +80,7 @@ public class EnumerationUtilsTest { assertTrue(actualKeyList.contains("one")); assertTrue(actualKeyList.contains("two")); assertTrue(actualKeyList.contains("three")); - final List expectedKeyList = new ArrayList(); + final List expectedKeyList = new ArrayList<>(); expectedKeyList.add("one"); expectedKeyList.add("two"); expectedKeyList.add("three"); @@ -90,7 +90,7 @@ public class EnumerationUtilsTest { @Test public void getFromEnumeration() throws Exception { // Enumeration, entry exists - final Vector vector = new Vector(); + final Vector vector = new Vector<>(); vector.addElement("zero"); vector.addElement("one"); Enumeration en = vector.elements(); diff --git a/src/test/java/org/apache/commons/collections4/FluentIterableTest.java b/src/test/java/org/apache/commons/collections4/FluentIterableTest.java index 80a866529..0c363f503 100644 --- a/src/test/java/org/apache/commons/collections4/FluentIterableTest.java +++ b/src/test/java/org/apache/commons/collections4/FluentIterableTest.java @@ -72,7 +72,7 @@ public class FluentIterableTest { @Before public void setUp() { - Collection collectionA = new ArrayList(); + Collection collectionA = new ArrayList<>(); collectionA.add(1); collectionA.add(2); collectionA.add(2); @@ -85,7 +85,7 @@ public class FluentIterableTest { collectionA.add(4); iterableA = collectionA; - Collection collectionB = new LinkedList(); + Collection collectionB = new LinkedList<>(); collectionB.add(5L); collectionB.add(4L); collectionB.add(4L); @@ -164,7 +164,7 @@ public class FluentIterableTest { @Test public void collate() { List result = FluentIterable.of(iterableOdd).collate(iterableEven).toList(); - List combinedList = new ArrayList(); + List combinedList = new ArrayList<>(); CollectionUtils.addAll(combinedList, iterableOdd); CollectionUtils.addAll(combinedList, iterableEven); Collections.sort(combinedList); @@ -186,7 +186,7 @@ public class FluentIterableTest { .collate(iterableEven, ComparatorUtils.naturalComparator()) .toList(); - List combinedList = new ArrayList(); + List combinedList = new ArrayList<>(); CollectionUtils.addAll(combinedList, iterableOdd); CollectionUtils.addAll(combinedList, iterableEven); Collections.sort(combinedList); @@ -370,7 +370,7 @@ public class FluentIterableTest { @Test public void zip() { List result = FluentIterable.of(iterableOdd).zip(iterableEven).toList(); - List combinedList = new ArrayList(); + List combinedList = new ArrayList<>(); CollectionUtils.addAll(combinedList, iterableOdd); CollectionUtils.addAll(combinedList, iterableEven); Collections.sort(combinedList); @@ -449,7 +449,7 @@ public class FluentIterableTest { @Test public void eval() { - List listNumbers = new ArrayList(); + List listNumbers = new ArrayList<>(); listNumbers.addAll(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); FluentIterable iterable = FluentIterable.of(listNumbers).filter(EVEN); FluentIterable materialized = iterable.eval(); @@ -472,20 +472,20 @@ public class FluentIterableTest { @Test public void copyInto() { - List result = new ArrayList(); + List result = new ArrayList<>(); FluentIterable.of(iterableA).copyInto(result); List expected = IterableUtils.toList(iterableA); assertEquals(expected.size(), result.size()); assertEquals(expected, result); - result = new ArrayList(); + result = new ArrayList<>(); result.add(10); result.add(9); result.add(8); FluentIterable.of(iterableA).copyInto(result); - expected = new ArrayList(); + expected = new ArrayList<>(); expected.addAll(Arrays.asList(10, 9, 8)); expected.addAll(IterableUtils.toList(iterableA)); assertEquals(expected.size(), result.size()); diff --git a/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java b/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java index 769b34b73..c7245ada7 100644 --- a/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java @@ -63,7 +63,7 @@ public class IterableUtilsTest { @Before public void setUp() { - Collection collectionA = new ArrayList(); + Collection collectionA = new ArrayList<>(); collectionA.add(1); collectionA.add(2); collectionA.add(2); @@ -76,7 +76,7 @@ public class IterableUtilsTest { collectionA.add(4); iterableA = collectionA; - Collection collectionB = new LinkedList(); + Collection collectionB = new LinkedList<>(); collectionB.add(5L); collectionB.add(4L); collectionB.add(4L); @@ -109,14 +109,14 @@ public class IterableUtilsTest { // ----------------------------------------------------------------------- @Test public void forEach() { - final List listA = new ArrayList(); + final List listA = new ArrayList<>(); listA.add(1); - final List listB = new ArrayList(); + final List listB = new ArrayList<>(); listB.add(2); final Closure> testClosure = ClosureUtils.invokerClosure("clear"); - final Collection> col = new ArrayList>(); + final Collection> col = new ArrayList<>(); col.add(listA); col.add(listB); IterableUtils.forEach(col, testClosure); @@ -138,21 +138,21 @@ public class IterableUtilsTest { @Test(expected = FunctorException.class) public void forEachFailure() { final Closure testClosure = ClosureUtils.invokerClosure("clear"); - final Collection col = new ArrayList(); + final Collection col = new ArrayList<>(); col.add("x"); IterableUtils.forEach(col, testClosure); } @Test public void forEachButLast() { - final List listA = new ArrayList(); + final List listA = new ArrayList<>(); listA.add(1); - final List listB = new ArrayList(); + final List listB = new ArrayList<>(); listB.add(2); final Closure> testClosure = ClosureUtils.invokerClosure("clear"); - final Collection> col = new ArrayList>(); + final Collection> col = new ArrayList<>(); col.add(listA); col.add(listB); List last = IterableUtils.forEachButLast(col, testClosure); @@ -177,7 +177,7 @@ public class IterableUtilsTest { @Test public void containsWithEquator() { - final List base = new ArrayList(); + final List base = new ArrayList<>(); base.add("AC"); base.add("BB"); base.add("CA"); @@ -234,7 +234,7 @@ public class IterableUtilsTest { assertEquals(0, IterableUtils.frequency(iterableIntAsNumber, 2L)); assertEquals(0, IterableUtils.frequency(iterableLongAsNumber, 2)); - final Set set = new HashSet(); + final Set set = new HashSet<>(); set.add("A"); set.add("C"); set.add("E"); @@ -245,7 +245,7 @@ public class IterableUtilsTest { assertEquals(0, IterableUtils.frequency(set, "D")); assertEquals(1, IterableUtils.frequency(set, "E")); - final Bag bag = new HashBag(); + final Bag bag = new HashBag<>(); bag.add("A", 3); bag.add("C"); bag.add("E"); @@ -259,7 +259,7 @@ public class IterableUtilsTest { @Test public void frequencyOfNull() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertEquals(0, IterableUtils.frequency(list, null)); list.add("A"); assertEquals(0, IterableUtils.frequency(list, null)); @@ -331,7 +331,7 @@ public class IterableUtilsTest { @Test public void matchesAny() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); try { assertFalse(IterableUtils.matchesAny(null, null)); @@ -397,7 +397,7 @@ public class IterableUtilsTest { @Test(expected = IndexOutOfBoundsException.class) public void getFromIterable() throws Exception { // Collection, entry exists - final Bag bag = new HashBag(); + final Bag bag = new HashBag<>(); bag.add("element", 1); assertEquals("element", IterableUtils.get(bag, 0)); @@ -408,7 +408,7 @@ public class IterableUtilsTest { @SuppressWarnings("unchecked") @Test public void partition() { - List input = new ArrayList(); + List input = new ArrayList<>(); input.add(1); input.add(2); input.add(3); @@ -446,7 +446,7 @@ public class IterableUtilsTest { @SuppressWarnings("unchecked") @Test public void partitionMultiplePredicates() { - List input = new ArrayList(); + List input = new ArrayList<>(); input.add(1); input.add(2); input.add(3); diff --git a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java index e9b5105f4..a1c88b2d4 100644 --- a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java @@ -71,11 +71,11 @@ public class IteratorUtilsTest { private Iterable iterableA = null; - private final Collection emptyCollection = new ArrayList(1); + private final Collection emptyCollection = new ArrayList<>(1); @Before public void setUp() { - collectionA = new ArrayList(); + collectionA = new ArrayList<>(); collectionA.add(1); collectionA.add(2); collectionA.add(2); @@ -95,7 +95,7 @@ public class IteratorUtilsTest { @Test public void testAsIterable() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(Integer.valueOf(0)); list.add(Integer.valueOf(1)); list.add(Integer.valueOf(2)); @@ -126,7 +126,7 @@ public class IteratorUtilsTest { @Test public void testAsMultipleIterable() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(Integer.valueOf(0)); list.add(Integer.valueOf(1)); list.add(Integer.valueOf(2)); @@ -163,7 +163,7 @@ public class IteratorUtilsTest { @Test public void testToList() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(Integer.valueOf(1)); list.add("Two"); list.add(null); @@ -173,7 +173,7 @@ public class IteratorUtilsTest { @Test public void testToArray() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(Integer.valueOf(1)); list.add("Two"); list.add(null); @@ -183,7 +183,7 @@ public class IteratorUtilsTest { @Test public void testToArray2() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add("One"); list.add("Two"); list.add(null); @@ -480,7 +480,7 @@ public class IteratorUtilsTest { * Gets an immutable Iterator operating on the elements ["a", "b", "c", "d"]. */ private Iterator getImmutableIterator() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); @@ -492,7 +492,7 @@ public class IteratorUtilsTest { * Gets an immutable ListIterator operating on the elements ["a", "b", "c", "d"]. */ private ListIterator getImmutableListIterator() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); @@ -952,7 +952,7 @@ public class IteratorUtilsTest { List result = IteratorUtils.toList(it); assertEquals(12, result.size()); - List combinedList = new ArrayList(); + List combinedList = new ArrayList<>(); combinedList.addAll(collectionOdd); combinedList.addAll(collectionEven); Collections.sort(combinedList); @@ -980,14 +980,14 @@ public class IteratorUtilsTest { // ----------------------------------------------------------------------- @Test public void forEach() { - final List listA = new ArrayList(); + final List listA = new ArrayList<>(); listA.add(1); - final List listB = new ArrayList(); + final List listB = new ArrayList<>(); listB.add(2); final Closure> testClosure = ClosureUtils.invokerClosure("clear"); - final Collection> col = new ArrayList>(); + final Collection> col = new ArrayList<>(); col.add(listA); col.add(listB); IteratorUtils.forEach(col.iterator(), testClosure); @@ -1008,14 +1008,14 @@ public class IteratorUtilsTest { @Test public void forEachButLast() { - final List listA = new ArrayList(); + final List listA = new ArrayList<>(); listA.add(1); - final List listB = new ArrayList(); + final List listB = new ArrayList<>(); listB.add(2); final Closure> testClosure = ClosureUtils.invokerClosure("clear"); - final Collection> col = new ArrayList>(); + final Collection> col = new ArrayList<>(); col.add(listA); col.add(listB); List last = IteratorUtils.forEachButLast(col.iterator(), testClosure); diff --git a/src/test/java/org/apache/commons/collections4/ListUtilsTest.java b/src/test/java/org/apache/commons/collections4/ListUtilsTest.java index 12c7cf5ae..f8184ed64 100644 --- a/src/test/java/org/apache/commons/collections4/ListUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/ListUtilsTest.java @@ -50,7 +50,7 @@ public class ListUtilsTest { @Before public void setUp() { fullArray = new String[]{a, b, c, d, e}; - fullList = new ArrayList(Arrays.asList(fullArray)); + fullList = new ArrayList<>(Arrays.asList(fullArray)); } /** @@ -77,7 +77,7 @@ public class ListUtilsTest { @Test public void testIntersectNonEmptySubset() { // create a copy - final List other = new ArrayList(fullList); + final List other = new ArrayList<>(fullList); // remove a few items assertNotNull(other.remove(0)); @@ -110,8 +110,8 @@ public class ListUtilsTest { */ @Test public void testIntersectionOrderInsensitivity() { - final List one = new ArrayList(); - final List two = new ArrayList(); + final List one = new ArrayList<>(); + final List two = new ArrayList<>(); one.add("a"); one.add("b"); two.add("a"); @@ -129,10 +129,10 @@ public class ListUtilsTest { return o instanceof String; } }; - List list = ListUtils.predicatedList(new ArrayList(), predicate); + List list = ListUtils.predicatedList(new ArrayList<>(), predicate); assertTrue("returned object should be a PredicatedList", list instanceof PredicatedList); try { - ListUtils.predicatedList(new ArrayList(), null); + ListUtils.predicatedList(new ArrayList<>(), null); fail("Expecting IllegalArgumentException for null predicate."); } catch (final NullPointerException ex) { // expected @@ -169,7 +169,7 @@ public class ListUtilsTest { public void testEmptyIfNull() { assertTrue(ListUtils.emptyIfNull(null).isEmpty()); - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertSame(list, ListUtils.emptyIfNull(list)); } @@ -177,7 +177,7 @@ public class ListUtilsTest { public void testDefaultIfNull() { assertTrue(ListUtils.defaultIfNull(null, Collections.emptyList()).isEmpty()); - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertSame(list, ListUtils.defaultIfNull(list, Collections.emptyList())); } @@ -185,8 +185,8 @@ public class ListUtilsTest { public void testEquals() { final Collection data = Arrays.asList("a", "b", "c"); - final List a = new ArrayList( data ); - final List b = new ArrayList( data ); + final List a = new ArrayList<>( data ); + final List b = new ArrayList<>( data ); assertEquals(true, a.equals(b)); assertEquals(true, ListUtils.isEqualList(a, b)); @@ -201,8 +201,8 @@ public class ListUtilsTest { public void testHashCode() { final Collection data = Arrays.asList("a", "b", "c"); - final List a = new ArrayList(data); - final List b = new ArrayList(data); + final List a = new ArrayList<>(data); + final List b = new ArrayList<>(data); assertEquals(true, a.hashCode() == b.hashCode()); assertEquals(true, a.hashCode() == ListUtils.hashCodeForList(a)); @@ -215,7 +215,7 @@ public class ListUtilsTest { @Test public void testRetainAll() { - final List sub = new ArrayList(); + final List sub = new ArrayList<>(); sub.add(a); sub.add(b); sub.add(x); @@ -235,7 +235,7 @@ public class ListUtilsTest { @Test public void testRemoveAll() { - final List sub = new ArrayList(); + final List sub = new ArrayList<>(); sub.add(a); sub.add(b); sub.add(x); @@ -253,19 +253,19 @@ public class ListUtilsTest { @Test public void testSubtract() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(a); list.add(b); list.add(a); list.add(x); - final List sub = new ArrayList(); + final List sub = new ArrayList<>(); sub.add(a); final List result = ListUtils.subtract(list, sub); assertTrue(result.size() == 3); - final List expected = new ArrayList(); + final List expected = new ArrayList<>(); expected.add(b); expected.add(a); expected.add(x); @@ -280,19 +280,19 @@ public class ListUtilsTest { @Test public void testSubtractNullElement() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(a); list.add(null); list.add(null); list.add(x); - final List sub = new ArrayList(); + final List sub = new ArrayList<>(); sub.add(null); final List result = ListUtils.subtract(list, sub); assertTrue(result.size() == 3); - final List expected = new ArrayList(); + final List expected = new ArrayList<>(); expected.add(a); expected.add(null); expected.add(x); @@ -400,7 +400,7 @@ public class ListUtilsTest { @Test @SuppressWarnings("boxing") // OK in test code public void testPartition() { - final List strings = new ArrayList(); + final List strings = new ArrayList<>(); for (int i = 0; i <= 6; i++) { strings.add(i); } @@ -438,7 +438,7 @@ public class ListUtilsTest { @Test @SuppressWarnings("boxing") // OK in test code public void testSelect() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(1); list.add(2); list.add(3); @@ -456,7 +456,7 @@ public class ListUtilsTest { @Test @SuppressWarnings("boxing") // OK in test code public void testSelectRejected() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(1L); list.add(2L); list.add(3L); diff --git a/src/test/java/org/apache/commons/collections4/MapPerformance.java b/src/test/java/org/apache/commons/collections4/MapPerformance.java index 4b79cc39d..7b955aa81 100644 --- a/src/test/java/org/apache/commons/collections4/MapPerformance.java +++ b/src/test/java/org/apache/commons/collections4/MapPerformance.java @@ -41,13 +41,13 @@ public class MapPerformance { } private static void testAll() { - final Map dummyMap = new DummyMap(); - final Map hashMap = new HashMap(); + final Map dummyMap = new DummyMap<>(); + final Map hashMap = new HashMap<>(); // hashMap.put("Alpha", "A"); // hashMap.put("Beta", "B"); // hashMap.put("Gamma", "C"); // hashMap.put("Delta", "D"); - final Map flatMap = new Flat3Map(hashMap); + final Map flatMap = new Flat3Map<>(hashMap); System.out.println(flatMap); // Map unmodHashMap = Collections.unmodifiableMap(new HashMap(hashMap)); // Map fastHashMap = new FastHashMap(hashMap); diff --git a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java index f2ef8f88b..5e84fa001 100644 --- a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java @@ -65,7 +65,7 @@ public class MapUtilsTest { @Test public void testPredicatedMap() { final Predicate p = getPredicate(); - Map map = MapUtils.predicatedMap(new HashMap(), p, p); + Map map = MapUtils.predicatedMap(new HashMap<>(), p, p); assertTrue("returned object should be a PredicatedMap", map instanceof PredicatedMap); try { MapUtils.predicatedMap(null, p, p); @@ -78,10 +78,10 @@ public class MapUtilsTest { @Test public void testLazyMapFactory() { final Factory factory = FactoryUtils.constantFactory(Integer.valueOf(5)); - Map map = MapUtils.lazyMap(new HashMap(), factory); + Map map = MapUtils.lazyMap(new HashMap<>(), factory); assertTrue(map instanceof LazyMap); try { - map = MapUtils.lazyMap(new HashMap(), (Factory) null); + map = MapUtils.lazyMap(new HashMap<>(), (Factory) null); fail("Expecting NullPointerException for null factory"); } catch (final NullPointerException e) { // expected @@ -93,10 +93,10 @@ public class MapUtilsTest { // expected } final Transformer transformer = TransformerUtils.asTransformer(factory); - map = MapUtils.lazyMap(new HashMap(), transformer); + map = MapUtils.lazyMap(new HashMap<>(), transformer); assertTrue(map instanceof LazyMap); try { - map = MapUtils.lazyMap(new HashMap(), (Transformer) null); + map = MapUtils.lazyMap(new HashMap<>(), (Transformer) null); fail("Expecting NullPointerException for null transformer"); } catch (final NullPointerException e) { // expected @@ -111,7 +111,7 @@ public class MapUtilsTest { @Test public void testLazyMapTransformer() { - final Map map = MapUtils.lazyMap(new HashMap(), new Transformer() { + final Map map = MapUtils.lazyMap(new HashMap<>(), new Transformer() { @Override public Object transform(final Object mapKey) { if (mapKey instanceof String) { @@ -133,20 +133,20 @@ public class MapUtilsTest { @Test public void testInvertMap() { - final Map in = new HashMap(5, 1); + final Map in = new HashMap<>(5, 1); in.put("1", "A"); in.put("2", "B"); in.put("3", "C"); in.put("4", "D"); in.put("5", "E"); - final Set inKeySet = new HashSet(in.keySet()); - final Set inValSet = new HashSet(in.values()); + final Set inKeySet = new HashSet<>(in.keySet()); + final Set inValSet = new HashSet<>(in.values()); final Map out = MapUtils.invertMap(in); - final Set outKeySet = new HashSet(out.keySet()); - final Set outValSet = new HashSet(out.values()); + final Set outKeySet = new HashSet<>(out.keySet()); + final Set outValSet = new HashSet<>(out.values()); assertTrue( inKeySet.equals( outValSet )); assertTrue( inValSet.equals( outKeySet )); @@ -243,9 +243,9 @@ public class MapUtilsTest { // map entry test = MapUtils.putAll(new HashMap(), new Object[] { - new DefaultMapEntry("RED", "#FF0000"), - new DefaultMapEntry("GREEN", "#00FF00"), - new DefaultMapEntry("BLUE", "#0000FF") + new DefaultMapEntry<>("RED", "#FF0000"), + new DefaultMapEntry<>("GREEN", "#00FF00"), + new DefaultMapEntry<>("BLUE", "#0000FF") }); assertEquals(true, test.containsKey("RED")); assertEquals("#FF0000", test.get("RED")); @@ -257,9 +257,9 @@ public class MapUtilsTest { // key value test = MapUtils.putAll(new HashMap(), new Object[] { - new DefaultKeyValue("RED", "#FF0000"), - new DefaultKeyValue("GREEN", "#00FF00"), - new DefaultKeyValue("BLUE", "#0000FF") + new DefaultKeyValue<>("RED", "#FF0000"), + new DefaultKeyValue<>("GREEN", "#00FF00"), + new DefaultKeyValue<>("BLUE", "#0000FF") }); assertEquals(true, test.containsKey("RED")); assertEquals("#FF0000", test.get("RED")); @@ -272,7 +272,7 @@ public class MapUtilsTest { @Test public void testConvertResourceBundle() { - final Map in = new HashMap( 5 , 1 ); + final Map in = new HashMap<>( 5 , 1 ); in.put("1", "A"); in.put("2", "B"); in.put("3", "C"); @@ -303,11 +303,11 @@ public class MapUtilsTest { @Test public void testDebugAndVerbosePrintCasting() { - final Map inner = new HashMap(2, 1); + final Map inner = new HashMap<>(2, 1); inner.put(2, "B"); inner.put(3, "C"); - final Map outer = new HashMap(2, 1); + final Map outer = new HashMap<>(2, 1); outer.put(0, inner); outer.put(1, "A"); @@ -348,7 +348,7 @@ public class MapUtilsTest { final String INDENT = " "; - final Map map = new TreeMap(); // treeMap guarantees order across JDKs for test + final Map map = new TreeMap<>(); // treeMap guarantees order across JDKs for test map.put(2, "B"); map.put(3, "C"); map.put(4, null); @@ -372,7 +372,7 @@ public class MapUtilsTest { final String INDENT = " "; - final Map map = new TreeMap(); // treeMap guarantees order across JDKs for test + final Map map = new TreeMap<>(); // treeMap guarantees order across JDKs for test map.put(2, "B"); map.put(3, "C"); map.put(4, null); @@ -418,7 +418,7 @@ public class MapUtilsTest { @Test public void testVerbosePrintNullStream() { try { - MapUtils.verbosePrint(null, "Map", new HashMap()); + MapUtils.verbosePrint(null, "Map", new HashMap<>()); fail("Should generate NullPointerException"); } catch (final NullPointerException expected) { } @@ -427,7 +427,7 @@ public class MapUtilsTest { @Test public void testDebugPrintNullStream() { try { - MapUtils.debugPrint(null, "Map", new HashMap()); + MapUtils.debugPrint(null, "Map", new HashMap<>()); fail("Should generate NullPointerException"); } catch (final NullPointerException expected) { } @@ -440,7 +440,7 @@ public class MapUtilsTest { final String INDENT = " "; - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put(null, "A"); outPrint.println("{"); @@ -460,7 +460,7 @@ public class MapUtilsTest { final String INDENT = " "; - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put(null, "A"); outPrint.println("{"); @@ -480,7 +480,7 @@ public class MapUtilsTest { final String INDENT = " "; - final Map> map = new HashMap>(); + final Map> map = new HashMap<>(); map.put(null, map); outPrint.println("{"); @@ -500,7 +500,7 @@ public class MapUtilsTest { final String INDENT = " "; - final Map> map = new HashMap>(); + final Map> map = new HashMap<>(); map.put(null, map); outPrint.println("{"); @@ -520,8 +520,8 @@ public class MapUtilsTest { final String INDENT = " "; - final Map map = new HashMap(); - final Map map2= new HashMap(); + final Map map = new HashMap<>(); + final Map map2= new HashMap<>(); map.put(null, map2); map2.put("2", "B"); @@ -545,8 +545,8 @@ public class MapUtilsTest { final String INDENT = " "; - final Map map = new HashMap(); - final Map map2= new HashMap(); + final Map map = new HashMap<>(); + final Map map2= new HashMap<>(); map.put(null, map2); map2.put("2", "B"); @@ -586,11 +586,11 @@ public class MapUtilsTest { out.reset(); - final Map inner = new TreeMap(); // treeMap guarantees order across JDKs for test + final Map inner = new TreeMap<>(); // treeMap guarantees order across JDKs for test inner.put(2, "B"); inner.put(3, "C"); - final Map outer = new TreeMap(); + final Map outer = new TreeMap<>(); outer.put(1, inner); outer.put(0, "A"); outer.put(7, outer); @@ -622,11 +622,11 @@ public class MapUtilsTest { out.reset(); - final Map inner = new TreeMap(); // treeMap guarantees order across JDKs for test + final Map inner = new TreeMap<>(); // treeMap guarantees order across JDKs for test inner.put(2, "B"); inner.put(3, "C"); - final Map outer = new TreeMap(); + final Map outer = new TreeMap<>(); outer.put(1, inner); outer.put(0, "A"); outer.put(7, outer); @@ -643,9 +643,9 @@ public class MapUtilsTest { final String LABEL = "Print Map"; final String INDENT = " "; - final Map grandfather = new TreeMap();// treeMap guarantees order across JDKs for test - final Map father = new TreeMap(); - final Map son = new TreeMap(); + final Map grandfather = new TreeMap<>();// treeMap guarantees order across JDKs for test + final Map father = new TreeMap<>(); + final Map son = new TreeMap<>(); grandfather.put(0, "A"); grandfather.put(1, father); @@ -690,9 +690,9 @@ public class MapUtilsTest { final String LABEL = "Print Map"; final String INDENT = " "; - final Map grandfather = new TreeMap();// treeMap guarantees order across JDKs for test - final Map father = new TreeMap(); - final Map son = new TreeMap(); + final Map grandfather = new TreeMap<>();// treeMap guarantees order across JDKs for test + final Map father = new TreeMap<>(); + final Map son = new TreeMap<>(); grandfather.put(0, "A"); grandfather.put(1, father); @@ -735,19 +735,19 @@ public class MapUtilsTest { public void testEmptyIfNull() { assertTrue(MapUtils.emptyIfNull(null).isEmpty()); - final Map map = new HashMap(); + final Map map = new HashMap<>(); assertSame(map, MapUtils.emptyIfNull(map)); } @Test public void testIsEmptyWithEmptyMap() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); assertEquals(true, MapUtils.isEmpty(map)); } @Test public void testIsEmptyWithNonEmptyMap() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put("item", "value"); assertEquals(false, MapUtils.isEmpty(map)); } @@ -760,13 +760,13 @@ public class MapUtilsTest { @Test public void testIsNotEmptyWithEmptyMap() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); assertEquals(false, MapUtils.isNotEmpty(map)); } @Test public void testIsNotEmptyWithNonEmptyMap() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put("item", "value"); assertEquals(true, MapUtils.isNotEmpty(map)); } @@ -780,7 +780,7 @@ public class MapUtilsTest { @Test public void testPopulateMap() { // Setup Test Data - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add("1"); list.add("3"); list.add("5"); @@ -790,7 +790,7 @@ public class MapUtilsTest { list.add("6"); // Now test key transform population - Map map = new HashMap(); + Map map = new HashMap<>(); MapUtils.populateMap(map, list, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); assertEquals(list.size(), map.size()); @@ -802,7 +802,7 @@ public class MapUtilsTest { } // Now test both Key-Value transform population - map = new HashMap(); + map = new HashMap<>(); MapUtils.populateMap(map, list, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); assertEquals(list.size(), map.size()); @@ -836,7 +836,7 @@ public class MapUtilsTest { @Test public void testPopulateMultiMap() { // Setup Test Data - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(new X(1, "x1")); list.add(new X(2, "x2")); list.add(new X(2, "x3")); @@ -866,14 +866,14 @@ public class MapUtilsTest { fail("Should throw NullPointerException"); } catch (final NullPointerException e) { } - final HashMap map = new HashMap(); + final HashMap map = new HashMap<>(); map.put("foo", "foov"); map.put("bar", "barv"); map.put("baz", "bazv"); final IterableMap iMap = MapUtils.iterableMap(map); assertEquals(map, iMap); assertNotSame(map, iMap); - final HashedMap hMap = new HashedMap(map); + final HashedMap hMap = new HashedMap<>(map); assertSame(hMap, MapUtils.iterableMap(hMap)); } @@ -884,7 +884,7 @@ public class MapUtilsTest { fail("Should throw NullPointerException"); } catch (final NullPointerException e) { } - final TreeMap map = new TreeMap(); + final TreeMap map = new TreeMap<>(); map.put("foo", "foov"); map.put("bar", "barv"); map.put("baz", "bazv"); @@ -896,7 +896,7 @@ public class MapUtilsTest { @Test public void testSize0() { - assertEquals(0, MapUtils.size(new HashMap())); + assertEquals(0, MapUtils.size(new HashMap<>())); } @Test @@ -906,7 +906,7 @@ public class MapUtilsTest { @Test public void testSize() { - final HashMap map = new HashMap(); + final HashMap map = new HashMap<>(); map.put("A", "1"); map.put("B", "2"); assertEquals(2, MapUtils.size(map)); diff --git a/src/test/java/org/apache/commons/collections4/MockTestCase.java b/src/test/java/org/apache/commons/collections4/MockTestCase.java index ff290ffda..40dc0c309 100644 --- a/src/test/java/org/apache/commons/collections4/MockTestCase.java +++ b/src/test/java/org/apache/commons/collections4/MockTestCase.java @@ -29,7 +29,7 @@ import org.easymock.IExpectationSetters; * that call the respective methods on all created mock objects. */ public abstract class MockTestCase { - private final List mockObjects = new ArrayList(); + private final List mockObjects = new ArrayList<>(); @SuppressWarnings("unchecked") protected T createMock(final Class name) { diff --git a/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java b/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java index 3ce5d9f00..3765e2560 100644 --- a/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java @@ -64,20 +64,20 @@ public class MultiMapUtilsTest { public void testEmptyIfNull() { assertTrue(MultiMapUtils.emptyIfNull(null).isEmpty()); - final MultiValuedMap map = new ArrayListValuedHashMap(); + final MultiValuedMap map = new ArrayListValuedHashMap<>(); map.put("item", "value"); assertFalse(MultiMapUtils.emptyIfNull(map).isEmpty()); } @Test public void testIsEmptyWithEmptyMap() { - final MultiValuedMap map = new ArrayListValuedHashMap(); + final MultiValuedMap map = new ArrayListValuedHashMap<>(); assertEquals(true, MultiMapUtils.isEmpty(map)); } @Test public void testIsEmptyWithNonEmptyMap() { - final MultiValuedMap map = new ArrayListValuedHashMap(); + final MultiValuedMap map = new ArrayListValuedHashMap<>(); map.put("item", "value"); assertEquals(false, MultiMapUtils.isEmpty(map)); } @@ -93,7 +93,7 @@ public class MultiMapUtilsTest { assertNull(MultiMapUtils.getCollection(null, "key1")); String values[] = { "v1", "v2", "v3" }; - final MultiValuedMap map = new ArrayListValuedHashMap(); + final MultiValuedMap map = new ArrayListValuedHashMap<>(); for (String val : values) { map.put("key1", val); } @@ -109,7 +109,7 @@ public class MultiMapUtilsTest { assertNull(MultiMapUtils.getValuesAsList(null, "key1")); String values[] = { "v1", "v2", "v3" }; - final MultiValuedMap map = new ArrayListValuedHashMap(); + final MultiValuedMap map = new ArrayListValuedHashMap<>(); for (String val : values) { map.put("key1", val); } @@ -126,7 +126,7 @@ public class MultiMapUtilsTest { assertNull(MultiMapUtils.getValuesAsList(null, "key1")); String values[] = { "v1", "v2", "v3" }; - final MultiValuedMap map = new ArrayListValuedHashMap(); + final MultiValuedMap map = new ArrayListValuedHashMap<>(); for (String val : values) { map.put("key1", val); map.put("key1", val); @@ -144,7 +144,7 @@ public class MultiMapUtilsTest { assertNull(MultiMapUtils.getValuesAsBag(null, "key1")); String values[] = { "v1", "v2", "v3" }; - final MultiValuedMap map = new ArrayListValuedHashMap(); + final MultiValuedMap map = new ArrayListValuedHashMap<>(); for (String val : values) { map.put("key1", val); map.put("key1", val); diff --git a/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java b/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java index 73a0c8169..bff6f2329 100644 --- a/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java @@ -166,7 +166,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), TruePredicate.truePredicate()}).evaluate(null)); assertEquals(false, AllPredicate.allPredicate(new Predicate[] { FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate()}).evaluate(null)); - final Collection> coll = new ArrayList>(); + final Collection> coll = new ArrayList<>(); coll.add(TruePredicate.truePredicate()); coll.add(TruePredicate.truePredicate()); coll.add(TruePredicate.truePredicate()); @@ -225,7 +225,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { @Test(expected=NullPointerException.class) public void testAllPredicateEx6() { - final Collection> coll = new ArrayList>(); + final Collection> coll = new ArrayList<>(); coll.add(null); coll.add(null); AllPredicate.allPredicate(coll); @@ -263,7 +263,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), TruePredicate.truePredicate()}).evaluate(null)); assertEquals(false, PredicateUtils.anyPredicate(new Predicate[] { FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate()}).evaluate(null)); - final Collection> coll = new ArrayList>(); + final Collection> coll = new ArrayList<>(); coll.add(TruePredicate.truePredicate()); coll.add(TruePredicate.truePredicate()); coll.add(TruePredicate.truePredicate()); @@ -322,7 +322,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { @Test(expected=NullPointerException.class) public void testAnyPredicateEx6() { - final Collection> coll = new ArrayList>(); + final Collection> coll = new ArrayList<>(); coll.add(null); coll.add(null); PredicateUtils.anyPredicate(coll); @@ -363,7 +363,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), TruePredicate.truePredicate()}).evaluate(null)); assertEquals(false, PredicateUtils.onePredicate(new Predicate[] { FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate()}).evaluate(null)); - final Collection> coll = new ArrayList>(); + final Collection> coll = new ArrayList<>(); coll.add(TruePredicate.truePredicate()); coll.add(TruePredicate.truePredicate()); coll.add(TruePredicate.truePredicate()); @@ -423,7 +423,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { @Test(expected=NullPointerException.class) public void testOnePredicateEx6() { - final Collection> coll = new ArrayList>(); + final Collection> coll = new ArrayList<>(); coll.add(null); coll.add(null); PredicateUtils.onePredicate(coll); @@ -460,7 +460,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), TruePredicate.truePredicate() }).evaluate(null)); assertEquals(true, PredicateUtils.nonePredicate(new Predicate[] { FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate() }).evaluate(null)); - final Collection> coll = new ArrayList>(); + final Collection> coll = new ArrayList<>(); coll.add(TruePredicate.truePredicate()); coll.add(TruePredicate.truePredicate()); coll.add(TruePredicate.truePredicate()); @@ -519,7 +519,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { @Test(expected=NullPointerException.class) public void testNonePredicateEx6() { - final Collection> coll = new ArrayList>(); + final Collection> coll = new ArrayList<>(); coll.add(null); coll.add(null); PredicateUtils.nonePredicate(coll); @@ -575,7 +575,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { @Test public void testInvokerPredicate() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertEquals(true, PredicateUtils.invokerPredicate("isEmpty").evaluate(list)); list.add(new Object()); assertEquals(false, PredicateUtils.invokerPredicate("isEmpty").evaluate(list)); @@ -601,7 +601,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { @Test public void testInvokerPredicate2() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertEquals(false, PredicateUtils.invokerPredicate( "contains", new Class[] {Object.class}, new Object[] {cString}).evaluate(list)); list.add(cString); @@ -678,7 +678,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest { TransformerUtils.nopTransformer(), TruePredicate.truePredicate()).evaluate(new Object())); - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put(Boolean.TRUE, "Hello"); final Transformer t = TransformerUtils.mapTransformer(map); final Predicate p = EqualPredicate.equalPredicate("Hello"); diff --git a/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java b/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java index 10bfaef7a..882295fc8 100644 --- a/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java @@ -41,7 +41,7 @@ public class QueueUtilsTest { @Test public void testUnmodifiableQueue() { - Queue queue = QueueUtils.unmodifiableQueue(new LinkedList()); + Queue queue = QueueUtils.unmodifiableQueue(new LinkedList<>()); assertTrue("Returned object should be an UnmodifiableQueue.", queue instanceof UnmodifiableQueue); try { QueueUtils.unmodifiableQueue(null); @@ -55,7 +55,7 @@ public class QueueUtilsTest { @Test public void testPredicatedQueue() { - Queue queue = QueueUtils.predicatedQueue(new LinkedList(), truePredicate); + Queue queue = QueueUtils.predicatedQueue(new LinkedList<>(), truePredicate); assertTrue("Returned object should be a PredicatedQueue.", queue instanceof PredicatedQueue); try { QueueUtils.predicatedQueue(null, truePredicate); @@ -64,7 +64,7 @@ public class QueueUtilsTest { // expected } try { - QueueUtils.predicatedQueue(new LinkedList(), null); + QueueUtils.predicatedQueue(new LinkedList<>(), null); fail("Expecting NullPointerException for null predicate."); } catch (final NullPointerException ex) { // expected @@ -73,7 +73,7 @@ public class QueueUtilsTest { @Test public void testTransformedQueue() { - Queue queue = QueueUtils.transformingQueue(new LinkedList(), nopTransformer); + Queue queue = QueueUtils.transformingQueue(new LinkedList<>(), nopTransformer); assertTrue("Returned object should be an TransformedQueue.", queue instanceof TransformedQueue); try { QueueUtils.transformingQueue(null, nopTransformer); @@ -82,7 +82,7 @@ public class QueueUtilsTest { // expected } try { - QueueUtils.transformingQueue(new LinkedList(), null); + QueueUtils.transformingQueue(new LinkedList<>(), null); fail("Expecting NullPointerException for null transformer."); } catch (final NullPointerException ex) { // expected diff --git a/src/test/java/org/apache/commons/collections4/SetUtilsTest.java b/src/test/java/org/apache/commons/collections4/SetUtilsTest.java index a5a2f321a..11fa9fafc 100644 --- a/src/test/java/org/apache/commons/collections4/SetUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/SetUtilsTest.java @@ -44,14 +44,14 @@ public class SetUtilsTest { @Before public void setUp() { - setA = new HashSet(); + setA = new HashSet<>(); setA.add(1); setA.add(2); setA.add(3); setA.add(4); setA.add(5); - setB = new HashSet(); + setB = new HashSet<>(); setB.add(3); setB.add(4); setB.add(5); @@ -69,10 +69,10 @@ public class SetUtilsTest { return o instanceof String; } }; - Set set = SetUtils.predicatedSet(new HashSet(), predicate); + Set set = SetUtils.predicatedSet(new HashSet<>(), predicate); assertTrue("returned object should be a PredicatedSet", set instanceof PredicatedSet); try { - SetUtils.predicatedSet(new HashSet(), null); + SetUtils.predicatedSet(new HashSet<>(), null); fail("Expecting NullPointerException for null predicate."); } catch (final NullPointerException ex) { // expected @@ -89,7 +89,7 @@ public class SetUtilsTest { public void testEmptyIfNull() { assertTrue(SetUtils.emptyIfNull(null).isEmpty()); - final Set set = new HashSet(); + final Set set = new HashSet<>(); assertSame(set, SetUtils.emptyIfNull(set)); } @@ -97,8 +97,8 @@ public class SetUtilsTest { public void testEquals() { final Collection data = Arrays.asList("a", "b", "c"); - final Set a = new HashSet(data); - final Set b = new HashSet(data); + final Set a = new HashSet<>(data); + final Set b = new HashSet<>(data); assertEquals(true, a.equals(b)); assertEquals(true, SetUtils.isEqualSet(a, b)); @@ -113,8 +113,8 @@ public class SetUtilsTest { public void testHashCode() { final Collection data = Arrays.asList("a", "b", "c"); - final Set a = new HashSet(data); - final Set b = new HashSet(data); + final Set a = new HashSet<>(data); + final Set b = new HashSet<>(data); assertEquals(true, a.hashCode() == b.hashCode()); assertEquals(true, a.hashCode() == SetUtils.hashCodeForSet(a)); diff --git a/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java b/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java index 17cc8c612..01f580f1f 100644 --- a/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java @@ -51,7 +51,7 @@ public class SplitMapUtilsTest { @Before public void setUp() throws Exception { - backingMap = new HashMap(); + backingMap = new HashMap<>(); transformedMap = TransformedSplitMap.transformingMap(backingMap, NOPTransformer. nopTransformer(), stringToInt); for (int i = 0; i < 10; i++) { @@ -101,7 +101,7 @@ public class SplitMapUtilsTest { } }); - final HashMap m = new HashMap(); + final HashMap m = new HashMap<>(); m.put("foo", 100); m.put("bar", 200); m.put("baz", 300); @@ -128,7 +128,7 @@ public class SplitMapUtilsTest { @Test public void testAlreadyReadableMap() { - final HashedMap hashedMap = new HashedMap(); + final HashedMap hashedMap = new HashedMap<>(); assertSame(hashedMap, SplitMapUtils.readableMap(hashedMap)); } @@ -203,7 +203,7 @@ public class SplitMapUtilsTest { assertEquals(++sz, backingMap.size()); // putall - final Map more = new HashMap(); + final Map more = new HashMap<>(); more.put("foo", "77"); more.put("bar", "88"); more.put("baz", "99"); @@ -218,7 +218,7 @@ public class SplitMapUtilsTest { @Test public void testAlreadyWritableMap() { - final HashedMap hashedMap = new HashedMap(); + final HashedMap hashedMap = new HashedMap<>(); assertSame(hashedMap, SplitMapUtils.writableMap(hashedMap)); } diff --git a/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java b/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java index 372b363f5..9098ec6d2 100644 --- a/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java @@ -129,7 +129,7 @@ public class TransformerUtilsTest { @Test @SuppressWarnings("boxing") // OK in test code public void testMapTransformer() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put(null, 0); map.put(cObject, 1); map.put(cString, 2); @@ -203,7 +203,7 @@ public class TransformerUtilsTest { assertEquals("A", TransformerUtils.chainedTransformer(b, a).transform(null)); assertEquals("B", TransformerUtils.chainedTransformer(a, b).transform(null)); assertEquals("A", TransformerUtils.chainedTransformer(new Transformer[] { b, a }).transform(null)); - Collection> coll = new ArrayList>(); + Collection> coll = new ArrayList<>(); coll.add(b); coll.add(a); assertEquals("A", TransformerUtils.chainedTransformer(coll).transform(null)); @@ -228,7 +228,7 @@ public class TransformerUtilsTest { fail(); } catch (final NullPointerException ex) {} try { - coll = new ArrayList>(); + coll = new ArrayList<>(); coll.add(null); coll.add(null); TransformerUtils.chainedTransformer(coll); @@ -308,7 +308,7 @@ public class TransformerUtilsTest { new Predicate[] { EqualPredicate.equalPredicate("HELLO"), EqualPredicate.equalPredicate("THERE") }, new Transformer[] { a, b }, c).transform("WELL")); - Map, Transformer> map = new HashMap, Transformer>(); + Map, Transformer> map = new HashMap<>(); map.put(EqualPredicate.equalPredicate("HELLO"), a); map.put(EqualPredicate.equalPredicate("THERE"), b); assertEquals(null, TransformerUtils.switchTransformer(map).transform("WELL")); @@ -319,7 +319,7 @@ public class TransformerUtilsTest { assertEquals(ConstantTransformer.NULL_INSTANCE, TransformerUtils.switchTransformer(new Predicate[0], new Transformer[0])); assertEquals(ConstantTransformer.NULL_INSTANCE, TransformerUtils.switchTransformer(new HashMap, Transformer>())); - map = new HashMap, Transformer>(); + map = new HashMap<>(); map.put(null, null); assertEquals(ConstantTransformer.NULL_INSTANCE, TransformerUtils.switchTransformer(map)); @@ -356,7 +356,7 @@ public class TransformerUtilsTest { final Transformer b = TransformerUtils.constantTransformer("B"); final Transformer c = TransformerUtils.constantTransformer("C"); - Map> map = new HashMap>(); + Map> map = new HashMap<>(); map.put("HELLO", a); map.put("THERE", b); assertEquals(null, TransformerUtils.switchMapTransformer(map).transform("WELL")); @@ -366,7 +366,7 @@ public class TransformerUtilsTest { assertEquals("C", TransformerUtils.switchMapTransformer(map).transform("WELL")); assertSame(ConstantTransformer.NULL_INSTANCE, TransformerUtils.switchMapTransformer(new HashMap>())); - map = new HashMap>(); + map = new HashMap<>(); map.put(null, null); assertSame(ConstantTransformer.NULL_INSTANCE, TransformerUtils.switchMapTransformer(map)); @@ -381,7 +381,7 @@ public class TransformerUtilsTest { @Test public void testInvokerTransformer() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertEquals(Integer.valueOf(0), TransformerUtils.invokerTransformer("size").transform(list)); list.add(new Object()); assertEquals(Integer.valueOf(1), TransformerUtils.invokerTransformer("size").transform(list)); @@ -402,7 +402,7 @@ public class TransformerUtilsTest { @Test public void testInvokerTransformer2() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); assertEquals(Boolean.FALSE, TransformerUtils.invokerTransformer("contains", new Class[] { Object.class }, new Object[] { cString }).transform(list)); list.add(cString); diff --git a/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java b/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java index 71c78075b..9a5b138b8 100644 --- a/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java @@ -33,7 +33,7 @@ public class TrieUtilsTest { @Test public void testUnmodifiableTrie() { - Trie trie = TrieUtils.unmodifiableTrie(new PatriciaTrie()); + Trie trie = TrieUtils.unmodifiableTrie(new PatriciaTrie<>()); assertTrue("Returned object should be an UnmodifiableTrie.", trie instanceof UnmodifiableTrie); try { diff --git a/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java b/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java index ed5700ddc..2190827a2 100644 --- a/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/AbstractBagTest.java @@ -77,7 +77,7 @@ public abstract class AbstractBagTest extends AbstractCollectionTest { */ @Override public Collection makeConfirmedCollection() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); return list; } @@ -206,7 +206,7 @@ public abstract class AbstractBagTest extends AbstractCollectionTest { bag.add((T) "B"); bag.add((T) "C"); assertEquals("Should have count of 4", 4, bag.size()); - final List delete = new ArrayList(); + final List delete = new ArrayList<>(); delete.add("A"); delete.add("B"); bag.removeAll(delete); @@ -247,15 +247,15 @@ public abstract class AbstractBagTest extends AbstractCollectionTest { } final Bag bag = makeObject(); - final List known = new ArrayList(); - final List known1A = new ArrayList(); + final List known = new ArrayList<>(); + final List known1A = new ArrayList<>(); known1A.add("A"); - final List known2A = new ArrayList(); + final List known2A = new ArrayList<>(); known2A.add("A"); known2A.add("A"); - final List known1B = new ArrayList(); + final List known1B = new ArrayList<>(); known1B.add("B"); - final List known1A1B = new ArrayList(); + final List known1A1B = new ArrayList<>(); known1A1B.add("A"); known1A1B.add("B"); @@ -332,7 +332,7 @@ public abstract class AbstractBagTest extends AbstractCollectionTest { bag.add((T) "B"); bag.add((T) "B"); bag.add((T) "C"); - final List retains = new ArrayList(); + final List retains = new ArrayList<>(); retains.add("B"); retains.add("C"); bag.retainAll(retains); @@ -547,7 +547,7 @@ public abstract class AbstractBagTest extends AbstractCollectionTest { } final Bag bag = makeObject(); - final Bag bag2 = new HashBag(); + final Bag bag2 = new HashBag<>(); assertEquals(true, bag.equals(bag2)); bag.add((T) "A"); assertEquals(false, bag.equals(bag2)); @@ -658,14 +658,14 @@ public abstract class AbstractBagTest extends AbstractCollectionTest { public void resetEmpty() { AbstractBagTest.this.resetEmpty(); TestBagUniqueSet.this.setCollection(AbstractBagTest.this.getCollection().uniqueSet()); - TestBagUniqueSet.this.setConfirmed(new HashSet(AbstractBagTest.this.getConfirmed())); + TestBagUniqueSet.this.setConfirmed(new HashSet<>(AbstractBagTest.this.getConfirmed())); } @Override public void resetFull() { AbstractBagTest.this.resetFull(); TestBagUniqueSet.this.setCollection(AbstractBagTest.this.getCollection().uniqueSet()); - TestBagUniqueSet.this.setConfirmed(new HashSet(AbstractBagTest.this.getConfirmed())); + TestBagUniqueSet.this.setConfirmed(new HashSet<>(AbstractBagTest.this.getConfirmed())); } @Override diff --git a/src/test/java/org/apache/commons/collections4/bag/AbstractSortedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/AbstractSortedBagTest.java index b68829a4c..1c0ae5cbe 100644 --- a/src/test/java/org/apache/commons/collections4/bag/AbstractSortedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/AbstractSortedBagTest.java @@ -97,7 +97,7 @@ public abstract class AbstractSortedBagTest extends AbstractBagTest { */ @Override public SortedBag makeConfirmedCollection() { - return new TreeBag(); + return new TreeBag<>(); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/collections4/bag/CollectionBagTest.java b/src/test/java/org/apache/commons/collections4/bag/CollectionBagTest.java index 1c31ef535..dae6e2e0f 100644 --- a/src/test/java/org/apache/commons/collections4/bag/CollectionBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/CollectionBagTest.java @@ -59,7 +59,7 @@ public class CollectionBagTest extends AbstractCollectionTest { */ @Override public Collection makeConfirmedCollection() { - return new ArrayList(); + return new ArrayList<>(); } /** diff --git a/src/test/java/org/apache/commons/collections4/bag/CollectionSortedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/CollectionSortedBagTest.java index 4ea98fed4..1e60cf4ed 100644 --- a/src/test/java/org/apache/commons/collections4/bag/CollectionSortedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/CollectionSortedBagTest.java @@ -69,7 +69,7 @@ public class CollectionSortedBagTest extends AbstractCollectionTest { */ @Override public Collection makeConfirmedCollection() { - return new ArrayList(); + return new ArrayList<>(); } /** diff --git a/src/test/java/org/apache/commons/collections4/bag/HashBagTest.java b/src/test/java/org/apache/commons/collections4/bag/HashBagTest.java index 57831e3af..087819df1 100644 --- a/src/test/java/org/apache/commons/collections4/bag/HashBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/HashBagTest.java @@ -41,7 +41,7 @@ public class HashBagTest extends AbstractBagTest { @Override public Bag makeObject() { - return new HashBag(); + return new HashBag<>(); } @Override diff --git a/src/test/java/org/apache/commons/collections4/bag/PredicatedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/PredicatedBagTest.java index fe30f263c..79adbee13 100644 --- a/src/test/java/org/apache/commons/collections4/bag/PredicatedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/PredicatedBagTest.java @@ -104,7 +104,7 @@ public class PredicatedBagTest extends AbstractBagTest { @SuppressWarnings("unchecked") public void testIllegalDecorate() { - final HashBag elements = new HashBag(); + final HashBag elements = new HashBag<>(); elements.add("one"); elements.add("two"); elements.add(Integer.valueOf(3)); diff --git a/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java index 84f337540..8b6f19358 100644 --- a/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/TransformedBagTest.java @@ -69,7 +69,7 @@ public class TransformedBagTest extends AbstractBagTest { @SuppressWarnings("unchecked") public void testTransformedBag_decorateTransform() { - final Bag originalBag = new HashBag(); + final Bag originalBag = new HashBag<>(); final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; for (final Object el : els) { originalBag.add((T) el); diff --git a/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java index a2a19478d..88040a7fe 100644 --- a/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java @@ -65,7 +65,7 @@ public class TransformedSortedBagTest extends AbstractSortedBagTest { } public void testTransformedBag_decorateTransform() { - final Bag originalBag = new TreeBag(); + final Bag originalBag = new TreeBag<>(); final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; for (final Object el : els) { originalBag.add(el); diff --git a/src/test/java/org/apache/commons/collections4/bag/TreeBagTest.java b/src/test/java/org/apache/commons/collections4/bag/TreeBagTest.java index ff64bed0d..64fc40309 100644 --- a/src/test/java/org/apache/commons/collections4/bag/TreeBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/TreeBagTest.java @@ -44,7 +44,7 @@ public class TreeBagTest extends AbstractSortedBagTest { @Override public SortedBag makeObject() { - return new TreeBag(); + return new TreeBag<>(); } @SuppressWarnings("unchecked") @@ -58,7 +58,7 @@ public class TreeBagTest extends AbstractSortedBagTest { } public void testCollections265() { - final Bag bag = new TreeBag(); + final Bag bag = new TreeBag<>(); try { bag.add(new Object()); fail("IllegalArgumentException expected"); @@ -68,7 +68,7 @@ public class TreeBagTest extends AbstractSortedBagTest { } public void testCollections555() { - final Bag bag = new TreeBag(); + final Bag bag = new TreeBag<>(); try { bag.add(null); fail("NullPointerException expected"); @@ -76,7 +76,7 @@ public class TreeBagTest extends AbstractSortedBagTest { // expected; } - final Bag bag2 = new TreeBag(new Comparator() { + final Bag bag2 = new TreeBag<>(new Comparator() { @Override public int compare(String o1, String o2) { return o1.compareTo(o2); diff --git a/src/test/java/org/apache/commons/collections4/bag/UnmodifiableBagTest.java b/src/test/java/org/apache/commons/collections4/bag/UnmodifiableBagTest.java index 3a19a780d..e5cb175c5 100644 --- a/src/test/java/org/apache/commons/collections4/bag/UnmodifiableBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/UnmodifiableBagTest.java @@ -50,7 +50,7 @@ public class UnmodifiableBagTest extends AbstractBagTest { @Override public Bag makeFullCollection() { - final Bag bag = new HashBag(); + final Bag bag = new HashBag<>(); bag.addAll(Arrays.asList(getFullElements())); return UnmodifiableBag.unmodifiableBag(bag); } diff --git a/src/test/java/org/apache/commons/collections4/bag/UnmodifiableSortedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/UnmodifiableSortedBagTest.java index 2d5227da8..4332ada39 100644 --- a/src/test/java/org/apache/commons/collections4/bag/UnmodifiableSortedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/UnmodifiableSortedBagTest.java @@ -50,7 +50,7 @@ public class UnmodifiableSortedBagTest extends AbstractSortedBagTest { @Override public SortedBag makeFullCollection() { - final SortedBag bag = new TreeBag(); + final SortedBag bag = new TreeBag<>(); bag.addAll(Arrays.asList(getFullElements())); return UnmodifiableSortedBag.unmodifiableSortedBag(bag); } diff --git a/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java index c7065dfb3..e7d3a879d 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractBidiMapTest.java @@ -127,8 +127,8 @@ public abstract class AbstractBidiMapTest extends AbstractIterableMapTest< public void verifyInverse() { assertEquals(map.size(), ((BidiMap) map).inverseBidiMap().size()); - final Map map1 = new HashMap(map); - final Map map2 = new HashMap(((BidiMap) map).inverseBidiMap()); + final Map map1 = new HashMap<>(map); + final Map map2 = new HashMap<>(((BidiMap) map).inverseBidiMap()); final Set keys1 = map1.keySet(); final Set keys2 = map2.keySet(); final Collection values1 = map1.values(); @@ -319,7 +319,7 @@ public abstract class AbstractBidiMapTest extends AbstractIterableMapTest< } private void removeByEntrySet(final BidiMap map, final Object key, final Object value) { - final Map temp = new HashMap(); + final Map temp = new HashMap<>(); temp.put(key, value); map.entrySet().remove(temp.entrySet().iterator().next()); diff --git a/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapDecoratorTest.java b/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapDecoratorTest.java index b236e7f42..3fd0d2f2a 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapDecoratorTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapDecoratorTest.java @@ -38,12 +38,12 @@ public class AbstractOrderedBidiMapDecoratorTest */ @Override public OrderedBidiMap makeObject() { - return new TestOrderedBidiMap(); + return new TestOrderedBidiMap<>(); } @Override public SortedMap makeConfirmedMap() { - return new TreeMap(); + return new TreeMap<>(); } @Override @@ -79,7 +79,7 @@ public class AbstractOrderedBidiMapDecoratorTest @Override public OrderedBidiMap inverseBidiMap() { if (inverse == null) { - inverse = new TestOrderedBidiMap(decorated().inverseBidiMap()); + inverse = new TestOrderedBidiMap<>(decorated().inverseBidiMap()); inverse.inverse = this; } return inverse; diff --git a/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java index 6d0f2f6ee..0bcb20913 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractOrderedBidiMapTest.java @@ -123,7 +123,7 @@ public abstract class AbstractOrderedBidiMapTest extends AbstractBidiMapTe resetFull(); bidi = getMap(); - final List list = new ArrayList(confirmed.keySet()); + final List list = new ArrayList<>(confirmed.keySet()); Collections.reverse(list); final Iterator it = list.iterator(); K confirmedLast = it.next(); diff --git a/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java index 385b8c1f9..a6d125c8e 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/AbstractSortedBidiMapTest.java @@ -39,8 +39,8 @@ import org.apache.commons.collections4.map.AbstractSortedMapTest; public abstract class AbstractSortedBidiMapTest, V extends Comparable> extends AbstractOrderedBidiMapTest { protected List sortedKeys; - protected List sortedValues = new ArrayList(); - protected SortedSet sortedNewValues = new TreeSet(); + protected List sortedValues = new ArrayList<>(); + protected SortedSet sortedNewValues = new TreeSet<>(); public AbstractSortedBidiMapTest(final String testName) { super(testName); @@ -48,7 +48,7 @@ public abstract class AbstractSortedBidiMapTest, V exten Collections.sort(sortedKeys); sortedKeys = Collections.unmodifiableList(sortedKeys); - final Map map = new TreeMap(); + final Map map = new TreeMap<>(); addSampleMappings(map); sortedValues.addAll(map.values()); @@ -100,7 +100,7 @@ public abstract class AbstractSortedBidiMapTest, V exten @Override public SortedMap makeConfirmedMap() { - return new TreeMap(); + return new TreeMap<>(); } //----------------------------------------------------------------------- @@ -646,15 +646,15 @@ public abstract class AbstractSortedBidiMapTest, V exten //----------------------------------------------------------------------- public BulkTest bulkTestHeadMap() { - return new AbstractSortedMapTest.TestHeadMap(this); + return new AbstractSortedMapTest.TestHeadMap<>(this); } public BulkTest bulkTestTailMap() { - return new AbstractSortedMapTest.TestTailMap(this); + return new AbstractSortedMapTest.TestTailMap<>(this); } public BulkTest bulkTestSubMap() { - return new AbstractSortedMapTest.TestSubMap(this); + return new AbstractSortedMapTest.TestSubMap<>(this); } } diff --git a/src/test/java/org/apache/commons/collections4/bidimap/DualHashBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/DualHashBidiMapTest.java index 567204985..a95097cfb 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/DualHashBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/DualHashBidiMapTest.java @@ -40,7 +40,7 @@ public class DualHashBidiMapTest extends AbstractBidiMapTest { */ @Override public DualHashBidiMap makeObject() { - return new DualHashBidiMap(); + return new DualHashBidiMap<>(); } /** diff --git a/src/test/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMapTest.java index d0a01384e..564fc1de3 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMapTest.java @@ -40,7 +40,7 @@ public class DualLinkedHashBidiMapTest extends AbstractBidiMapTest { */ @Override public DualLinkedHashBidiMap makeObject() { - return new DualLinkedHashBidiMap(); + return new DualLinkedHashBidiMap<>(); } @Override diff --git a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java index 9dcc4b8a0..014d3cbaf 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java @@ -52,14 +52,14 @@ public class DualTreeBidiMap2Test, V extends Comparable< @Override public DualTreeBidiMap makeObject() { - return new DualTreeBidiMap( - new ReverseComparator(ComparableComparator. comparableComparator()), - new ReverseComparator(ComparableComparator. comparableComparator())); + return new DualTreeBidiMap<>( + new ReverseComparator<>(ComparableComparator. comparableComparator()), + new ReverseComparator<>(ComparableComparator. comparableComparator())); } @Override public TreeMap makeConfirmedMap() { - return new TreeMap(new ReverseComparator(ComparableComparator.comparableComparator())); + return new TreeMap<>(new ReverseComparator<>(ComparableComparator.comparableComparator())); } public void testComparator() { @@ -70,7 +70,7 @@ public class DualTreeBidiMap2Test, V extends Comparable< } public void testComparator2() { - final DualTreeBidiMap dtbm = new DualTreeBidiMap( + final DualTreeBidiMap dtbm = new DualTreeBidiMap<>( String.CASE_INSENSITIVE_ORDER, null); dtbm.put("two", 0); dtbm.put("one", 1); @@ -107,7 +107,7 @@ public class DualTreeBidiMap2Test, V extends Comparable< } public void testCollections364() throws Exception { - final DualTreeBidiMap original = new DualTreeBidiMap( + final DualTreeBidiMap original = new DualTreeBidiMap<>( String.CASE_INSENSITIVE_ORDER, new IntegerComparator()); final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final ObjectOutputStream out = new ObjectOutputStream(buffer); @@ -130,7 +130,7 @@ public class DualTreeBidiMap2Test, V extends Comparable< // Sort by the comparator used in the makeEmptyBidiMap() method List newSortedKeys = getAsList(getSampleKeys()); - Collections.sort(newSortedKeys, new ReverseComparator(ComparableComparator.comparableComparator())); + Collections.sort(newSortedKeys, new ReverseComparator<>(ComparableComparator.comparableComparator())); newSortedKeys = Collections.unmodifiableList(newSortedKeys); final Iterator mapIter = sm.keySet().iterator(); diff --git a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMapTest.java index 510162850..4098db64a 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMapTest.java @@ -40,7 +40,7 @@ public class DualTreeBidiMapTest, V extends Comparable makeObject() { - return new DualTreeBidiMap(); + return new DualTreeBidiMap<>(); } /** diff --git a/src/test/java/org/apache/commons/collections4/bidimap/TreeBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/TreeBidiMapTest.java index 6d3594bc2..55daf8474 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/TreeBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/TreeBidiMapTest.java @@ -39,12 +39,12 @@ public class TreeBidiMapTest, V extends Comparable> e @Override public BidiMap makeObject() { - return new TreeBidiMap(); + return new TreeBidiMap<>(); } @Override public TreeMap makeConfirmedMap() { - return new TreeMap(); + return new TreeMap<>(); } /** diff --git a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMapTest.java index 3eb0eaed8..c1f85e68a 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableBidiMapTest.java @@ -47,14 +47,14 @@ public class UnmodifiableBidiMapTest extends AbstractBidiMapTest { @Override public BidiMap makeFullMap() { - final BidiMap bidi = new DualHashBidiMap(); + final BidiMap bidi = new DualHashBidiMap<>(); addSampleMappings(bidi); return UnmodifiableBidiMap.unmodifiableBidiMap(bidi); } @Override public Map makeConfirmedMap() { - return new HashMap(); + return new HashMap<>(); } /** diff --git a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMapTest.java index a2aa1eaf1..501ed5aff 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableOrderedBidiMapTest.java @@ -47,14 +47,14 @@ public class UnmodifiableOrderedBidiMapTest, V extends C @Override public OrderedBidiMap makeFullMap() { - final OrderedBidiMap bidi = new TreeBidiMap(); + final OrderedBidiMap bidi = new TreeBidiMap<>(); addSampleMappings(bidi); return UnmodifiableOrderedBidiMap.unmodifiableOrderedBidiMap(bidi); } @Override public Map makeConfirmedMap() { - return new TreeMap(); + return new TreeMap<>(); } /** diff --git a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMapTest.java b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMapTest.java index 8a1b88f43..651e9d4b4 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMapTest.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/UnmodifiableSortedBidiMapTest.java @@ -48,14 +48,14 @@ public class UnmodifiableSortedBidiMapTest, V extends Co @Override public SortedBidiMap makeFullMap() { - final SortedBidiMap bidi = new DualTreeBidiMap(); + final SortedBidiMap bidi = new DualTreeBidiMap<>(); addSampleMappings(bidi); return UnmodifiableSortedBidiMap.unmodifiableSortedBidiMap(bidi); } @Override public SortedMap makeConfirmedMap() { - return new TreeMap(); + return new TreeMap<>(); } @Override diff --git a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java index ab1e10332..e2dff1b19 100644 --- a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java @@ -372,7 +372,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { * Creates a new Map Entry that is independent of the first and the map. */ public Map.Entry cloneMapEntry(final Map.Entry entry) { - final HashMap map = new HashMap(); + final HashMap map = new HashMap<>(); map.put(entry.getKey(), entry.getValue()); return map.entrySet().iterator().next(); } @@ -391,7 +391,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public E[] getFullElements() { if (isNullSupported()) { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); list.addAll(Arrays.asList(getFullNonNullElements())); list.add(4, null); return (E[]) list.toArray(); @@ -683,7 +683,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { */ public void testCollectionContainsAll() { resetEmpty(); - Collection col = new HashSet(); + Collection col = new HashSet<>(); assertTrue("Every Collection should contain all elements of an " + "empty Collection.", getCollection().containsAll(col)); col.addAll(Arrays.asList(getOtherElements())); @@ -713,7 +713,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { // make sure calls to "containsAll" don't change anything verify(); - col = new ArrayList(); + col = new ArrayList<>(); col.addAll(Arrays.asList(getFullElements())); col.addAll(Arrays.asList(getFullElements())); assertTrue("Full collection should containAll duplicate full elements", @@ -763,7 +763,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { } assertTrue("Iterator should be finished", !it1.hasNext()); - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); it1 = getCollection().iterator(); for (int i = 0; i < getCollection().size(); i++) { final E next = it1.next(); @@ -912,7 +912,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { verify(); assertTrue("Empty collection removeAll should return false for nonempty input", - !getCollection().removeAll(new ArrayList(getCollection()))); + !getCollection().removeAll(new ArrayList<>(getCollection()))); verify(); resetFull(); @@ -925,8 +925,8 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { verify(); assertTrue("Full collection removeAll should return true for full elements", - getCollection().removeAll(new HashSet(getCollection()))); - getConfirmed().removeAll(new HashSet(getConfirmed())); + getCollection().removeAll(new HashSet<>(getCollection()))); + getConfirmed().removeAll(new HashSet<>(getConfirmed())); verify(); resetFull(); @@ -998,7 +998,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { } resetFull(); - final HashSet set = new HashSet(elements); + final HashSet set = new HashSet<>(elements); size = getCollection().size(); assertTrue("Collection shouldn't change from retainAll without " + "duplicate elements", !getCollection().retainAll(set)); @@ -1099,7 +1099,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { // Figure out if they're all the same class // TODO: It'd be nicer to detect a common superclass - final HashSet> classes = new HashSet>(); + final HashSet> classes = new HashSet<>(); for (final Object element : array) { classes.add(element == null ? null : element.getClass()); } diff --git a/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java index 4632057e1..fc4f5d40b 100644 --- a/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java @@ -55,12 +55,12 @@ public class CompositeCollectionTest extends AbstractCollectionTest { */ @Override public Collection makeObject() { - return new CompositeCollection(); + return new CompositeCollection<>(); } @Override public Collection makeConfirmedCollection() { - return new HashSet(); + return new HashSet<>(); } @Override @@ -74,10 +74,10 @@ public class CompositeCollectionTest extends AbstractCollectionTest { */ @Override public Collection makeFullCollection() { - final CompositeCollection compositeCollection = new CompositeCollection(); + final CompositeCollection compositeCollection = new CompositeCollection<>(); final E[] elements = getFullElements(); for (final E element : elements) { - final Collection summand = new HashSet(); + final Collection summand = new HashSet<>(); summand.add(element); compositeCollection.addComposited(summand); } @@ -89,7 +89,7 @@ public class CompositeCollectionTest extends AbstractCollectionTest { */ @Override public Collection makeConfirmedFullCollection() { - final Collection collection = new HashSet(); + final Collection collection = new HashSet<>(); collection.addAll(Arrays.asList(getFullElements())); return collection; } @@ -117,9 +117,9 @@ public class CompositeCollectionTest extends AbstractCollectionTest { protected Collection two; protected void setUpTest() { - c = new CompositeCollection(); - one = new HashSet(); - two = new HashSet(); + c = new CompositeCollection<>(); + one = new HashSet<>(); + two = new HashSet<>(); } @SuppressWarnings("serial") @@ -158,7 +158,7 @@ public class CompositeCollectionTest extends AbstractCollectionTest { @SuppressWarnings("unchecked") public void testSize() { setUpTest(); - final HashSet set = new HashSet(); + final HashSet set = new HashSet<>(); set.add((E) "a"); set.add((E) "b"); c.addComposited(set); @@ -168,11 +168,11 @@ public class CompositeCollectionTest extends AbstractCollectionTest { @SuppressWarnings("unchecked") public void testMultipleCollectionsSize() { setUpTest(); - final HashSet set = new HashSet(); + final HashSet set = new HashSet<>(); set.add((E) "a"); set.add((E) "b"); c.addComposited(set); - final HashSet other = new HashSet(); + final HashSet other = new HashSet<>(); other.add((E) "c"); c.addComposited(other); assertEquals(set.size() + other.size(), c.size()); @@ -182,7 +182,7 @@ public class CompositeCollectionTest extends AbstractCollectionTest { public void testIsEmpty() { setUpTest(); assertTrue(c.isEmpty()); - final HashSet empty = new HashSet(); + final HashSet empty = new HashSet<>(); c.addComposited(empty); assertTrue(c.isEmpty()); empty.add((E) "a"); @@ -332,7 +332,7 @@ public class CompositeCollectionTest extends AbstractCollectionTest { one.add((E) "1"); two.add((E) "2"); c.addComposited(one, two); - final Collection toCollection = new HashSet(); + final Collection toCollection = new HashSet<>(); toCollection.addAll(c); assertTrue(toCollection.containsAll(c)); assertEquals(c.size(), toCollection.size()); @@ -358,7 +358,7 @@ public class CompositeCollectionTest extends AbstractCollectionTest { two.add((E) "2"); two.add((E) "1"); // need separate list to remove, as otherwise one clears itself - final Collection removing = new ArrayList(one); + final Collection removing = new ArrayList<>(one); c.addComposited(one, two); c.removeAll(removing); assertTrue(!c.contains("1")); diff --git a/src/test/java/org/apache/commons/collections4/collection/IndexedCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/IndexedCollectionTest.java index f49d4a4cc..7015a3844 100644 --- a/src/test/java/org/apache/commons/collections4/collection/IndexedCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/IndexedCollectionTest.java @@ -66,7 +66,7 @@ public class IndexedCollectionTest extends AbstractCollectionTest { @Override public Collection makeConfirmedCollection() { - return new ArrayList(); + return new ArrayList<>(); } @Override @@ -81,14 +81,14 @@ public class IndexedCollectionTest extends AbstractCollectionTest { @Override public Collection makeFullCollection() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return decorateCollection(list); } @Override public Collection makeConfirmedFullCollection() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } @@ -148,7 +148,7 @@ public class IndexedCollectionTest extends AbstractCollectionTest { } public void testReindexUpdatesIndexWhenDecoratedCollectionIsModifiedSeparately() throws Exception { - final Collection original = new ArrayList(); + final Collection original = new ArrayList<>(); final IndexedCollection indexed = decorateUniqueCollection(original); original.add("1"); diff --git a/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionTest.java index ae1adcd6a..3c0cd581e 100644 --- a/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionTest.java @@ -52,7 +52,7 @@ public class PredicatedCollectionTest extends AbstractCollectionTest { @Override public Collection makeConfirmedCollection() { - return new ArrayList(); + return new ArrayList<>(); } @Override @@ -63,14 +63,14 @@ public class PredicatedCollectionTest extends AbstractCollectionTest { @Override public Collection makeFullCollection() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return decorateCollection(list, truePredicate); } @Override public Collection makeConfirmedFullCollection() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } @@ -105,7 +105,7 @@ public class PredicatedCollectionTest extends AbstractCollectionTest { @SuppressWarnings("unchecked") public void testIllegalAddAll() { final Collection c = makeTestCollection(); - final List elements = new ArrayList(); + final List elements = new ArrayList<>(); elements.add((E) "one"); elements.add((E) "two"); elements.add((E) Integer.valueOf(3)); diff --git a/src/test/java/org/apache/commons/collections4/collection/SynchronizedCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/SynchronizedCollectionTest.java index af7eeac4d..583b98858 100644 --- a/src/test/java/org/apache/commons/collections4/collection/SynchronizedCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/SynchronizedCollectionTest.java @@ -41,12 +41,12 @@ public class SynchronizedCollectionTest extends AbstractCollectionTest { @Override public Collection makeConfirmedCollection() { - return new ArrayList(); + return new ArrayList<>(); } @Override public Collection makeConfirmedFullCollection() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } diff --git a/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java index 9a3cac4c9..8e6fecdac 100644 --- a/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/TransformedCollectionTest.java @@ -51,24 +51,24 @@ public class TransformedCollectionTest extends AbstractCollectionTest { //----------------------------------------------------------------------- @Override public Collection makeConfirmedCollection() { - return new ArrayList(); + return new ArrayList<>(); } @Override public Collection makeConfirmedFullCollection() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } @Override public Collection makeObject() { - return TransformedCollection.transformingCollection(new ArrayList(), NOOP_TRANSFORMER); + return TransformedCollection.transformingCollection(new ArrayList<>(), NOOP_TRANSFORMER); } @Override public Collection makeFullCollection() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return TransformedCollection.transformingCollection(list, NOOP_TRANSFORMER); } @@ -86,7 +86,7 @@ public class TransformedCollectionTest extends AbstractCollectionTest { //----------------------------------------------------------------------- public void testTransformedCollection() { - final Collection coll = TransformedCollection.transformingCollection(new ArrayList(), STRING_TO_INTEGER_TRANSFORMER); + final Collection coll = TransformedCollection.transformingCollection(new ArrayList<>(), STRING_TO_INTEGER_TRANSFORMER); assertEquals(0, coll.size()); final Object[] elements = getFullElements(); for (int i = 0; i < elements.length; i++) { @@ -100,7 +100,7 @@ public class TransformedCollectionTest extends AbstractCollectionTest { } public void testTransformedCollection_decorateTransform() { - final Collection originalCollection = new ArrayList(); + final Collection originalCollection = new ArrayList<>(); final Object[] elements = getFullElements(); Collections.addAll(originalCollection, elements); final Collection collection = TransformedCollection.transformedCollection(originalCollection, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); diff --git a/src/test/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollectionTest.java index 081fccce8..d754d12a8 100644 --- a/src/test/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/UnmodifiableBoundedCollectionTest.java @@ -46,18 +46,18 @@ public class UnmodifiableBoundedCollectionTest extends AbstractCollectionTest @Override public BoundedCollection makeFullCollection() { final E[] allElements = getFullElements(); - final BoundedCollection coll = FixedSizeList.fixedSizeList(new ArrayList(Arrays.asList(allElements))); + final BoundedCollection coll = FixedSizeList.fixedSizeList(new ArrayList<>(Arrays.asList(allElements))); return UnmodifiableBoundedCollection.unmodifiableBoundedCollection(coll); } @Override public Collection makeConfirmedCollection() { - return new ArrayList(); + return new ArrayList<>(); } @Override public Collection makeConfirmedFullCollection() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } diff --git a/src/test/java/org/apache/commons/collections4/collection/UnmodifiableCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/UnmodifiableCollectionTest.java index d5e874599..9afcc57a3 100644 --- a/src/test/java/org/apache/commons/collections4/collection/UnmodifiableCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/UnmodifiableCollectionTest.java @@ -44,19 +44,19 @@ public class UnmodifiableCollectionTest extends AbstractCollectionTest { @Override public Collection makeFullCollection() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return UnmodifiableCollection.unmodifiableCollection(list); } @Override public Collection makeConfirmedCollection() { - return new ArrayList(); + return new ArrayList<>(); } @Override public Collection makeConfirmedFullCollection() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } diff --git a/src/test/java/org/apache/commons/collections4/comparators/AbstractComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/AbstractComparatorTest.java index 448067d3e..41ce429ff 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/AbstractComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/AbstractComparatorTest.java @@ -106,10 +106,10 @@ public abstract class AbstractComparatorTest extends AbstractObjectTest { */ @Test public void testEmptyListSort() { - final List list = new LinkedList(); + final List list = new LinkedList<>(); sortObjects(list, makeObject()); - final List list2 = new LinkedList(); + final List list2 = new LinkedList<>(); assertTrue("Comparator cannot sort empty lists", list2.equals(list)); } diff --git a/src/test/java/org/apache/commons/collections4/comparators/AbstractNullComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/AbstractNullComparatorTest.java index db6681fbc..f3614403d 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/AbstractNullComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/AbstractNullComparatorTest.java @@ -52,12 +52,12 @@ public abstract class AbstractNullComparatorTest extends AbstractComparatorTest< @Override public Comparator makeObject() { - return new NullComparator(); + return new NullComparator<>(); } @Override public List getComparableObjectsOrdered() { - final List list = new LinkedList(); + final List list = new LinkedList<>(); list.add(Integer.valueOf(1)); list.add(Integer.valueOf(2)); list.add(Integer.valueOf(3)); @@ -94,12 +94,12 @@ public abstract class AbstractNullComparatorTest extends AbstractComparatorTest< @Override public Comparator makeObject() { - return new NullComparator(false); + return new NullComparator<>(false); } @Override public List getComparableObjectsOrdered() { - final List list = new LinkedList(); + final List list = new LinkedList<>(); list.add(null); list.add(Integer.valueOf(1)); list.add(Integer.valueOf(2)); diff --git a/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java index 060d335c8..4044e088a 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/BooleanComparatorTest.java @@ -47,7 +47,7 @@ public class BooleanComparatorTest extends AbstractComparatorTest { @Override public List getComparableObjectsOrdered() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(new Boolean(false)); list.add(Boolean.FALSE); list.add(new Boolean(false)); diff --git a/src/test/java/org/apache/commons/collections4/comparators/ComparableComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/ComparableComparatorTest.java index bfd8b9c31..c0fed719b 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/ComparableComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/ComparableComparatorTest.java @@ -35,12 +35,12 @@ public class ComparableComparatorTest extends AbstractComparatorTest { @Override public Comparator makeObject() { - return new ComparableComparator(); + return new ComparableComparator<>(); } @Override public List getComparableObjectsOrdered() { - final List list = new LinkedList(); + final List list = new LinkedList<>(); list.add(1); list.add(2); list.add(3); diff --git a/src/test/java/org/apache/commons/collections4/comparators/ComparatorChainTest.java b/src/test/java/org/apache/commons/collections4/comparators/ComparatorChainTest.java index bf44d7d3f..b135e55e8 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/ComparatorChainTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/ComparatorChainTest.java @@ -36,7 +36,7 @@ public class ComparatorChainTest extends AbstractComparatorTest makeObject() { - final ComparatorChain chain = new ComparatorChain(new ColumnComparator(0)); + final ComparatorChain chain = new ComparatorChain<>(new ColumnComparator(0)); chain.addComparator(new ColumnComparator(1), true); // reverse the second column chain.addComparator(new ColumnComparator(2), false); return chain; @@ -53,7 +53,7 @@ public class ComparatorChainTest extends AbstractComparatorTest chain = new ComparatorChain(); + final ComparatorChain chain = new ComparatorChain<>(); final Integer i1 = Integer.valueOf(4); final Integer i2 = Integer.valueOf(6); chain.addComparator(new ComparableComparator()); @@ -64,7 +64,7 @@ public class ComparatorChainTest extends AbstractComparatorTest chain = new ComparatorChain(); + final ComparatorChain chain = new ComparatorChain<>(); final Integer i1 = Integer.valueOf(4); final Integer i2 = Integer.valueOf(6); try { @@ -76,9 +76,9 @@ public class ComparatorChainTest extends AbstractComparatorTest> list = new LinkedList>(); + final List> list = new LinkedList<>(); list.add(new ComparableComparator()); - final ComparatorChain chain = new ComparatorChain(list); + final ComparatorChain chain = new ComparatorChain<>(list); final Integer i1 = Integer.valueOf(4); final Integer i2 = Integer.valueOf(6); @@ -88,8 +88,8 @@ public class ComparatorChainTest extends AbstractComparatorTest> list = new LinkedList>(); - final ComparatorChain chain = new ComparatorChain(list); + final List> list = new LinkedList<>(); + final ComparatorChain chain = new ComparatorChain<>(list); final Integer i1 = Integer.valueOf(4); final Integer i2 = Integer.valueOf(6); try { @@ -103,7 +103,7 @@ public class ComparatorChainTest extends AbstractComparatorTest chain = new ComparatorChain(); + final ComparatorChain chain = new ComparatorChain<>(); chain.addComparator(new Comparator() { @Override public int compare(final Integer a, final Integer b) { @@ -125,7 +125,7 @@ public class ComparatorChainTest extends AbstractComparatorTest getComparableObjectsOrdered() { - final List list = new LinkedList(); + final List list = new LinkedList<>(); // this is the correct order assuming a // "0th forward, 1st reverse, 2nd forward" sort list.add(new PseudoRow(1, 2, 3)); diff --git a/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java index 992e276ed..e8da9d95c 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/FixedOrderComparatorTest.java @@ -61,7 +61,7 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest { @Override public Comparator makeObject() { - final FixedOrderComparator comparator = new FixedOrderComparator(topCities); + final FixedOrderComparator comparator = new FixedOrderComparator<>(topCities); return comparator; } @@ -88,7 +88,7 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest { */ @Test public void testConstructorPlusAdd() { - final FixedOrderComparator comparator = new FixedOrderComparator(); + final FixedOrderComparator comparator = new FixedOrderComparator<>(); for (final String topCitie : topCities) { comparator.add(topCitie); } @@ -103,7 +103,7 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest { public void testArrayConstructor() { final String[] keys = topCities.clone(); final String[] topCitiesForTest = topCities.clone(); - final FixedOrderComparator comparator = new FixedOrderComparator(topCitiesForTest); + final FixedOrderComparator comparator = new FixedOrderComparator<>(topCitiesForTest); assertComparatorYieldsOrder(keys, comparator); // test that changing input after constructor has no effect topCitiesForTest[0] = "Brighton"; @@ -116,8 +116,8 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest { @Test public void testListConstructor() { final String[] keys = topCities.clone(); - final List topCitiesForTest = new LinkedList(Arrays.asList(topCities)); - final FixedOrderComparator comparator = new FixedOrderComparator(topCitiesForTest); + final List topCitiesForTest = new LinkedList<>(Arrays.asList(topCities)); + final FixedOrderComparator comparator = new FixedOrderComparator<>(topCitiesForTest); assertComparatorYieldsOrder(keys, comparator); // test that changing input after constructor has no effect topCitiesForTest.set(0, "Brighton"); @@ -129,7 +129,7 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest { */ @Test public void testAddAsEqual() { - final FixedOrderComparator comparator = new FixedOrderComparator(topCities); + final FixedOrderComparator comparator = new FixedOrderComparator<>(topCities); comparator.addAsEqual("New York", "Minneapolis"); assertEquals(0, comparator.compare("New York", "Minneapolis")); assertEquals(-1, comparator.compare("Tokyo", "Minneapolis")); @@ -141,7 +141,7 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest { */ @Test public void testLock() { - final FixedOrderComparator comparator = new FixedOrderComparator(topCities); + final FixedOrderComparator comparator = new FixedOrderComparator<>(topCities); assertEquals(false, comparator.isLocked()); comparator.compare("New York", "Tokyo"); assertEquals(true, comparator.isLocked()); @@ -162,7 +162,7 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest { @Test public void testUnknownObjectBehavior() { - FixedOrderComparator comparator = new FixedOrderComparator(topCities); + FixedOrderComparator comparator = new FixedOrderComparator<>(topCities); try { comparator.compare("New York", "Minneapolis"); fail("Should have thrown a IllegalArgumentException"); @@ -177,10 +177,10 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest { } assertEquals(FixedOrderComparator.UnknownObjectBehavior.EXCEPTION, comparator.getUnknownObjectBehavior()); - comparator = new FixedOrderComparator(topCities); + comparator = new FixedOrderComparator<>(topCities); comparator.setUnknownObjectBehavior(FixedOrderComparator.UnknownObjectBehavior.BEFORE); assertEquals(FixedOrderComparator.UnknownObjectBehavior.BEFORE, comparator.getUnknownObjectBehavior()); - LinkedList keys = new LinkedList(Arrays.asList(topCities)); + LinkedList keys = new LinkedList<>(Arrays.asList(topCities)); keys.addFirst("Minneapolis"); assertComparatorYieldsOrder(keys.toArray(new String[0]), comparator); @@ -188,9 +188,9 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest { assertEquals( 1, comparator.compare("New York", "Minneapolis")); assertEquals( 0, comparator.compare("Minneapolis", "St Paul")); - comparator = new FixedOrderComparator(topCities); + comparator = new FixedOrderComparator<>(topCities); comparator.setUnknownObjectBehavior(FixedOrderComparator.UnknownObjectBehavior.AFTER); - keys = new LinkedList(Arrays.asList(topCities)); + keys = new LinkedList<>(Arrays.asList(topCities)); keys.add("Minneapolis"); assertComparatorYieldsOrder(keys.toArray(new String[0]), comparator); diff --git a/src/test/java/org/apache/commons/collections4/comparators/ReverseComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/ReverseComparatorTest.java index 13cb78629..601252b0f 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/ReverseComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/ReverseComparatorTest.java @@ -50,7 +50,7 @@ public class ReverseComparatorTest extends AbstractComparatorTest { */ @Override public Comparator makeObject() { - return new ReverseComparator(Collections.reverseOrder()); + return new ReverseComparator<>(Collections.reverseOrder()); } @Override @@ -64,7 +64,7 @@ public class ReverseComparatorTest extends AbstractComparatorTest { @Override public List getComparableObjectsOrdered() { - final List list = new LinkedList(); + final List list = new LinkedList<>(); list.add(Integer.valueOf(1)); list.add(Integer.valueOf(2)); list.add(Integer.valueOf(3)); @@ -81,7 +81,7 @@ public class ReverseComparatorTest extends AbstractComparatorTest { @Override @Test public void testSerializeDeserializeThenCompare() throws Exception { - final Comparator comp = new ReverseComparator(new ComparableComparator()); + final Comparator comp = new ReverseComparator<>(new ComparableComparator()); final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final ObjectOutputStream out = new ObjectOutputStream(buffer); diff --git a/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java index 788bde414..232d38d55 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java @@ -45,14 +45,14 @@ public class TransformingComparatorTest extends AbstractComparatorTest @Override public Comparator makeObject() { - final Comparator decorated = new ComparableComparator(); + final Comparator decorated = new ComparableComparator<>(); return ComparatorUtils.transformedComparator(decorated, TransformerUtils.stringValueTransformer()); } @Override @SuppressWarnings("boxing") // OK in test code public List getComparableObjectsOrdered() { - final List list = new LinkedList(); + final List list = new LinkedList<>(); list.add(1); list.add(2); list.add(3); @@ -63,8 +63,8 @@ public class TransformingComparatorTest extends AbstractComparatorTest public void testEquals() { Transformer t1 = TransformerUtils.nopTransformer(); - TransformingComparator comp1 = new TransformingComparator(t1); - TransformingComparator comp2 = new TransformingComparator(t1, comp1); + TransformingComparator comp1 = new TransformingComparator<>(t1); + TransformingComparator comp2 = new TransformingComparator<>(t1, comp1); // Checks the contract: equals-hashcode on comp1 and comp2 assertTrue("Contract failed: equals-hashcode", diff --git a/src/test/java/org/apache/commons/collections4/functors/AbstractCompositePredicateTest.java b/src/test/java/org/apache/commons/collections4/functors/AbstractCompositePredicateTest.java index 432ea7f30..30bc0b630 100644 --- a/src/test/java/org/apache/commons/collections4/functors/AbstractCompositePredicateTest.java +++ b/src/test/java/org/apache/commons/collections4/functors/AbstractCompositePredicateTest.java @@ -69,7 +69,7 @@ public abstract class AbstractCompositePredicateTest extends AbstractMockPred * @return a predicate to test. */ protected final Predicate getPredicateInstance(final Boolean... mockReturnValues) { - final List> predicates = new ArrayList>(); + final List> predicates = new ArrayList<>(); for (final Boolean returnValue : mockReturnValues) { predicates.add(createMockPredicate(returnValue)); } @@ -137,7 +137,7 @@ public abstract class AbstractCompositePredicateTest extends AbstractMockPred */ @Test(expected = NullPointerException.class) public final void nullElementsInCollectionToGetInstance() { - final Collection> coll = new ArrayList>(); + final Collection> coll = new ArrayList<>(); coll.add(null); coll.add(null); getPredicateInstance(coll); diff --git a/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java b/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java index 6eb721657..832aa81dc 100644 --- a/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java +++ b/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java @@ -59,7 +59,7 @@ public abstract class AbstractMockPredicateTest { @Before public final void createVerifyList() { - mockPredicatesToVerify = new ArrayList>(); + mockPredicatesToVerify = new ArrayList<>(); } /** diff --git a/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java index 2123d603d..7380f9d96 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/AbstractListIteratorTest.java @@ -122,7 +122,7 @@ public abstract class AbstractListIteratorTest extends AbstractIteratorTest list = new ArrayList(); + final ArrayList list = new ArrayList<>(); final ListIterator it = makeObject(); while (it.hasNext()) { list.add(it.next()); diff --git a/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java index e938856dc..f095867a7 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/AbstractMapIteratorTest.java @@ -167,7 +167,7 @@ public abstract class AbstractMapIteratorTest extends AbstractIteratorTest assertEquals(true, it.hasNext()); assertEquals(true, it.hasNext()); - final Set set = new HashSet(); + final Set set = new HashSet<>(); while (it.hasNext()) { // getKey final K key = it.next(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java index e80e2e7ed..4d1e82812 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/AbstractOrderedMapIteratorTest.java @@ -92,7 +92,7 @@ public abstract class AbstractOrderedMapIteratorTest extends AbstractMapIt assertEquals(true, it.hasNext()); assertEquals(false, it.hasPrevious()); - final Set set = new HashSet(); + final Set set = new HashSet<>(); while (it.hasNext()) { // getKey final K key = it.next(); @@ -143,12 +143,12 @@ public abstract class AbstractOrderedMapIteratorTest extends AbstractMapIt final OrderedMapIterator it = makeObject(); final Map map = getMap(); - assertEquals("keySet() not consistent", new ArrayList(map.keySet()), new ArrayList(map.keySet())); + assertEquals("keySet() not consistent", new ArrayList<>(map.keySet()), new ArrayList<>(map.keySet())); final Iterator it2 = map.keySet().iterator(); assertEquals(true, it.hasNext()); assertEquals(true, it2.hasNext()); - final List list = new ArrayList(); + final List list = new ArrayList<>(); while (it.hasNext()) { final K key = it.next(); assertEquals(it2.next(), key); diff --git a/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java b/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java index ed8b3e72a..fe00aed3f 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayIterator2Test.java @@ -34,24 +34,24 @@ public class ArrayIterator2Test extends AbstractIteratorTest { @Override public ArrayIterator makeEmptyIterator() { - return new ArrayIterator(new int[0]); + return new ArrayIterator<>(new int[0]); } @Override public ArrayIterator makeObject() { - return new ArrayIterator(testArray); + return new ArrayIterator<>(testArray); } public ArrayIterator makeArrayIterator(final Object array) { - return new ArrayIterator(array); + return new ArrayIterator<>(array); } public ArrayIterator makeArrayIterator(final Object array, final int index) { - return new ArrayIterator(array, index); + return new ArrayIterator<>(array, index); } public ArrayIterator makeArrayIterator(final Object array, final int start, final int end) { - return new ArrayIterator(array, start, end); + return new ArrayIterator<>(array, start, end); } @Override diff --git a/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java index 20325a05c..1314429b7 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayIteratorTest.java @@ -36,12 +36,12 @@ public class ArrayIteratorTest extends AbstractIteratorTest { @Override public ArrayIterator makeEmptyIterator() { - return new ArrayIterator(new Object[0]); + return new ArrayIterator<>(new Object[0]); } @Override public ArrayIterator makeObject() { - return new ArrayIterator(testArray); + return new ArrayIterator<>(testArray); } @Override @@ -70,7 +70,7 @@ public class ArrayIteratorTest extends AbstractIteratorTest { public void testNullArray() { try { - new ArrayIterator(null); + new ArrayIterator<>(null); fail("Constructor should throw a NullPointerException when constructed with a null array"); } catch (final NullPointerException e) { // expected diff --git a/src/test/java/org/apache/commons/collections4/iterators/ArrayListIterator2Test.java b/src/test/java/org/apache/commons/collections4/iterators/ArrayListIterator2Test.java index 45cdc653a..c385e79b3 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ArrayListIterator2Test.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayListIterator2Test.java @@ -29,24 +29,24 @@ public class ArrayListIterator2Test extends ArrayIterator2Test { @Override public ArrayListIterator makeEmptyIterator() { - return new ArrayListIterator(new int[0]); + return new ArrayListIterator<>(new int[0]); } @Override public ArrayListIterator makeObject() { - return new ArrayListIterator(testArray); + return new ArrayListIterator<>(testArray); } public ArrayListIterator makeArrayListIterator(final Object array) { - return new ArrayListIterator(array); + return new ArrayListIterator<>(array); } public ArrayListIterator makeArrayListIterator(final Object array, final int index) { - return new ArrayListIterator(array, index); + return new ArrayListIterator<>(array, index); } public ArrayListIterator makeArrayListIterator(final Object array, final int start, final int end) { - return new ArrayListIterator(array, start, end); + return new ArrayListIterator<>(array, start, end); } } diff --git a/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java index 1388f3785..95d84c7de 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java @@ -33,16 +33,16 @@ public class ArrayListIteratorTest extends ArrayIteratorTest { @Override public ArrayListIterator makeEmptyIterator() { - return new ArrayListIterator(new Object[0]); + return new ArrayListIterator<>(new Object[0]); } @Override public ArrayListIterator makeObject() { - return new ArrayListIterator(testArray); + return new ArrayListIterator<>(testArray); } public ArrayListIterator makeArrayListIterator(final Object array) { - return new ArrayListIterator(array); + return new ArrayListIterator<>(array); } @Override diff --git a/src/test/java/org/apache/commons/collections4/iterators/BoundedIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/BoundedIteratorTest.java index 201e905e5..18abbd43c 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/BoundedIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/BoundedIteratorTest.java @@ -50,12 +50,12 @@ public class BoundedIteratorTest extends AbstractIteratorTest { @Override public Iterator makeEmptyIterator() { - return new BoundedIterator(Collections.emptyList().iterator(), 0, 10); + return new BoundedIterator<>(Collections.emptyList().iterator(), 0, 10); } @Override public Iterator makeObject() { - return new BoundedIterator(new ArrayList(testList).iterator(), 1, testList.size() - 1); + return new BoundedIterator<>(new ArrayList<>(testList).iterator(), 1, testList.size() - 1); } // ---------------- Tests --------------------- @@ -67,7 +67,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testBounded() { - Iterator iter = new BoundedIterator(testList.iterator(), 2, 4); + Iterator iter = new BoundedIterator<>(testList.iterator(), 2, 4); assertTrue(iter.hasNext()); assertEquals("c", iter.next()); @@ -93,7 +93,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testSameAsDecorated() { - Iterator iter = new BoundedIterator(testList.iterator(), 0, + Iterator iter = new BoundedIterator<>(testList.iterator(), 0, testList.size()); assertTrue(iter.hasNext()); @@ -126,7 +126,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testEmptyBounded() { - Iterator iter = new BoundedIterator(testList.iterator(), 3, 0); + Iterator iter = new BoundedIterator<>(testList.iterator(), 3, 0); assertFalse(iter.hasNext()); try { iter.next(); @@ -142,7 +142,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { @Test public void testNegativeOffset() { try { - new BoundedIterator(testList.iterator(), -1, 4); + new BoundedIterator<>(testList.iterator(), -1, 4); fail("Expected IllegalArgumentException."); } catch (IllegalArgumentException iae) { /* Success case */ } @@ -155,7 +155,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { @Test public void testNegativeMax() { try { - new BoundedIterator(testList.iterator(), 3, -1); + new BoundedIterator<>(testList.iterator(), 3, -1); fail("Expected IllegalArgumentException."); } catch (IllegalArgumentException iae) { /* Success case */ } @@ -168,7 +168,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testOffsetGreaterThanSize() { - Iterator iter = new BoundedIterator(testList.iterator(), 10, 4); + Iterator iter = new BoundedIterator<>(testList.iterator(), 10, 4); assertFalse(iter.hasNext()); try { iter.next(); @@ -185,7 +185,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testMaxGreaterThanSize() { - Iterator iter = new BoundedIterator(testList.iterator(), 1, 10); + Iterator iter = new BoundedIterator<>(testList.iterator(), 1, 10); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -214,8 +214,8 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveWithoutCallingNext() { - List testListCopy = new ArrayList(testList); - Iterator iter = new BoundedIterator(testListCopy.iterator(), 1, 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); try { iter.remove(); @@ -230,8 +230,8 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveCalledTwice() { - List testListCopy = new ArrayList(testList); - Iterator iter = new BoundedIterator(testListCopy.iterator(), 1, 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -250,8 +250,8 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveFirst() { - List testListCopy = new ArrayList(testList); - Iterator iter = new BoundedIterator(testListCopy.iterator(), 1, 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -282,8 +282,8 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveMiddle() { - List testListCopy = new ArrayList(testList); - Iterator iter = new BoundedIterator(testListCopy.iterator(), 1, 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -314,8 +314,8 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveLast() { - List testListCopy = new ArrayList(testList); - Iterator iter = new BoundedIterator(testListCopy.iterator(), 1, 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -359,7 +359,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { } }; - Iterator iter = new BoundedIterator(mockIterator, 1, 5); + Iterator iter = new BoundedIterator<>(mockIterator, 1, 5); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); try { diff --git a/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java index aac2bb5fc..d46c35b70 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/CollatingIteratorTest.java @@ -47,9 +47,9 @@ public class CollatingIteratorTest extends AbstractIteratorTest { @Override public void setUp() throws Exception { super.setUp(); - comparator = new ComparableComparator(); - evens = new ArrayList(); - odds = new ArrayList(); + comparator = new ComparableComparator<>(); + evens = new ArrayList<>(); + odds = new ArrayList<>(); for (int i = 0; i < 20; i++) { if (0 == i % 2) { evens.add(i); @@ -57,7 +57,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { odds.add(i); } } - fib = new ArrayList(); + fib = new ArrayList<>(); fib.add(1); fib.add(1); fib.add(2); @@ -72,12 +72,12 @@ public class CollatingIteratorTest extends AbstractIteratorTest { @Override public CollatingIterator makeEmptyIterator() { - return new CollatingIterator(comparator); + return new CollatingIterator<>(comparator); } @Override public CollatingIterator makeObject() { - final CollatingIterator iter = new CollatingIterator(comparator); + final CollatingIterator iter = new CollatingIterator<>(comparator); iter.addIterator(evens.iterator()); iter.addIterator(odds.iterator()); iter.addIterator(fib.iterator()); @@ -87,7 +87,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { //------------------------------------------------------------------- Tests public void testGetSetComparator() { - final CollatingIterator iter = new CollatingIterator(); + final CollatingIterator iter = new CollatingIterator<>(); assertNull(iter.getComparator()); iter.setComparator(comparator); assertSame(comparator, iter.getComparator()); @@ -96,7 +96,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { } public void testIterateEven() { - final CollatingIterator iter = new CollatingIterator(comparator); + final CollatingIterator iter = new CollatingIterator<>(comparator); iter.addIterator(evens.iterator()); for (int i = 0; i < evens.size(); i++) { assertTrue(iter.hasNext()); @@ -107,7 +107,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { } public void testIterateEvenOdd() { - final CollatingIterator iter = new CollatingIterator(comparator, evens.iterator(), odds.iterator()); + final CollatingIterator iter = new CollatingIterator<>(comparator, evens.iterator(), odds.iterator()); for (int i = 0; i < 20; i++) { assertTrue(iter.hasNext()); assertEquals(Integer.valueOf(i), iter.next()); @@ -117,7 +117,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { } public void testIterateOddEven() { - final CollatingIterator iter = new CollatingIterator(comparator, odds.iterator(), evens.iterator()); + final CollatingIterator iter = new CollatingIterator<>(comparator, odds.iterator(), evens.iterator()); for (int i = 0; i < 20; i++) { assertTrue(iter.hasNext()); assertEquals(Integer.valueOf(i),iter.next()); @@ -127,7 +127,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { } public void testIterateEvenEven() { - final CollatingIterator iter = new CollatingIterator(comparator); + final CollatingIterator iter = new CollatingIterator<>(comparator); iter.addIterator(evens.iterator()); iter.addIterator(evens.iterator()); for (int i = 0; i < evens.size(); i++) { @@ -142,7 +142,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { } public void testIterateFibEvenOdd() { - final CollatingIterator iter = new CollatingIterator(comparator); + final CollatingIterator iter = new CollatingIterator<>(comparator); iter.addIterator(fib.iterator()); iter.addIterator(evens.iterator()); iter.addIterator(odds.iterator()); @@ -208,7 +208,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { } public void testRemoveFromSingle() { - final CollatingIterator iter = new CollatingIterator(comparator); + final CollatingIterator iter = new CollatingIterator<>(comparator); iter.addIterator(evens.iterator()); int expectedSize = evens.size(); while (iter.hasNext()) { @@ -223,7 +223,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { } public void testRemoveFromDouble() { - final CollatingIterator iter = new CollatingIterator(comparator); + final CollatingIterator iter = new CollatingIterator<>(comparator); iter.addIterator(evens.iterator()); iter.addIterator(odds.iterator()); int expectedSize = evens.size() + odds.size(); @@ -242,7 +242,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { final List l1 = Arrays.asList(1, 3, 5); final List l2 = Arrays.asList(2, 4, 6); - final CollatingIterator collatingIterator1 = new CollatingIterator(null, l1.iterator(), l2.iterator()); + final CollatingIterator collatingIterator1 = new CollatingIterator<>(null, l1.iterator(), l2.iterator()); try { collatingIterator1.next(); } catch (final NullPointerException e) { @@ -250,7 +250,7 @@ public class CollatingIteratorTest extends AbstractIteratorTest { } int i = 0; - final CollatingIterator collatingIterator2 = new CollatingIterator(null, l1.iterator(), l2.iterator()); + final CollatingIterator collatingIterator2 = new CollatingIterator<>(null, l1.iterator(), l2.iterator()); collatingIterator2.setComparator(new ComparableComparator()); for ( ; collatingIterator2.hasNext(); i++ ) { final Integer n = collatingIterator2.next(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java index 7e4af43c0..a5adf2a0a 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/FilterIteratorTest.java @@ -81,7 +81,7 @@ public class FilterIteratorTest extends AbstractIteratorTest { @Override @SuppressWarnings("unchecked") public FilterIterator makeObject() { - list = new ArrayList(Arrays.asList((E[]) array)); + list = new ArrayList<>(Arrays.asList((E[]) array)); return makePassThroughFilter(list.iterator()); } @@ -119,7 +119,7 @@ public class FilterIteratorTest extends AbstractIteratorTest { final Iterator iter1 = Collections.singleton((E) new Object()).iterator(); final Iterator iter2 = Collections.emptyList().iterator(); - final FilterIterator filterIterator = new FilterIterator(iter1); + final FilterIterator filterIterator = new FilterIterator<>(iter1); filterIterator.setPredicate(truePredicate()); // this iterator has elements assertEquals(true, filterIterator.hasNext()); @@ -136,7 +136,7 @@ public class FilterIteratorTest extends AbstractIteratorTest { public void testSetPredicate() { final Iterator iter = Collections.singleton((E) null).iterator(); - final FilterIterator filterIterator = new FilterIterator(iter); + final FilterIterator filterIterator = new FilterIterator<>(iter); filterIterator.setPredicate(truePredicate()); // this predicate matches assertEquals(true, filterIterator.hasNext()); @@ -204,7 +204,7 @@ public class FilterIteratorTest extends AbstractIteratorTest { @Override public boolean evaluate(final E x) { return true; } }; - return new FilterIterator(i, pred); + return new FilterIterator<>(i, pred); } /** @@ -219,7 +219,7 @@ public class FilterIteratorTest extends AbstractIteratorTest { @Override public boolean evaluate(final E x) { return false; } }; - return new FilterIterator(i, pred); + return new FilterIterator<>(i, pred); } } diff --git a/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java index ef8a9cf4e..ff2454f66 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/FilterListIteratorTest.java @@ -52,12 +52,12 @@ public class FilterListIteratorTest extends TestCase { @Override public void setUp() { - list = new ArrayList(); - odds = new ArrayList(); - evens = new ArrayList(); - threes = new ArrayList(); - fours = new ArrayList(); - sixes = new ArrayList(); + list = new ArrayList<>(); + odds = new ArrayList<>(); + evens = new ArrayList<>(); + threes = new ArrayList<>(); + fours = new ArrayList<>(); + sixes = new ArrayList<>(); for (int i = 0; i < 20; i++) { list.add(Integer.valueOf(i)); if (i % 2 == 0) { evens.add(Integer.valueOf(i)); } @@ -134,7 +134,7 @@ public class FilterListIteratorTest extends TestCase { public void testManual() { // do this one "by hand" as a sanity check - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), threePred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), threePred); assertEquals(Integer.valueOf(0), filtered.next()); assertEquals(Integer.valueOf(3), filtered.next()); @@ -192,80 +192,80 @@ public class FilterListIteratorTest extends TestCase { } public void testTruePredicate() { - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), truePred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), truePred); walkLists(list, filtered); } public void testFalsePredicate() { - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), falsePred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), falsePred); walkLists(new ArrayList(), filtered); } public void testEvens() { - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), evenPred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), evenPred); walkLists(evens, filtered); } public void testOdds() { - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), oddPred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), oddPred); walkLists(odds, filtered); } public void testThrees() { - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), threePred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), threePred); walkLists(threes, filtered); } public void testFours() { - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), fourPred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), fourPred); walkLists(fours, filtered); } public void testNestedSixes() { - final FilterListIterator filtered = new FilterListIterator( - new FilterListIterator(list.listIterator(), threePred), + final FilterListIterator filtered = new FilterListIterator<>( + new FilterListIterator<>(list.listIterator(), threePred), evenPred ); walkLists(sixes, filtered); } public void testNestedSixes2() { - final FilterListIterator filtered = new FilterListIterator( - new FilterListIterator(list.listIterator(), evenPred), + final FilterListIterator filtered = new FilterListIterator<>( + new FilterListIterator<>(list.listIterator(), evenPred), threePred ); walkLists(sixes, filtered); } public void testNestedSixes3() { - final FilterListIterator filtered = new FilterListIterator( - new FilterListIterator(list.listIterator(), threePred), + final FilterListIterator filtered = new FilterListIterator<>( + new FilterListIterator<>(list.listIterator(), threePred), evenPred ); - walkLists(sixes, new FilterListIterator(filtered, truePred)); + walkLists(sixes, new FilterListIterator<>(filtered, truePred)); } public void testNextChangesPrevious() { { - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), threePred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), threePred); nextNextPrevious(threes.listIterator(), filtered); } { - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), truePred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), truePred); nextNextPrevious(list.listIterator(), filtered); } } public void testPreviousChangesNext() { { - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), threePred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), threePred); final ListIterator expected = threes.listIterator(); walkForward(expected,filtered); previousPreviousNext(expected,filtered); } { - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), truePred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), truePred); final ListIterator expected = list.listIterator(); walkForward(expected, filtered); previousPreviousNext(expected, filtered); @@ -273,7 +273,7 @@ public class FilterListIteratorTest extends TestCase { } public void testFailingHasNextBug() { - final FilterListIterator filtered = new FilterListIterator(list.listIterator(), fourPred); + final FilterListIterator filtered = new FilterListIterator<>(list.listIterator(), fourPred); final ListIterator expected = fours.listIterator(); while (expected.hasNext()) { expected.next(); @@ -288,11 +288,11 @@ public class FilterListIteratorTest extends TestCase { * Test for {@link "https://issues.apache.org/jira/browse/COLLECTIONS-360 COLLECTIONS-360"} */ public void testCollections360() throws Throwable { - final Collection> var7 = new GrowthList>(); + final Collection> var7 = new GrowthList<>(); final Predicate var9 = PredicateUtils.anyPredicate(var7); - final FilterListIterator var13 = new FilterListIterator(var9); + final FilterListIterator var13 = new FilterListIterator<>(var9); Assert.assertFalse(var13.hasNext()); - final FilterListIterator var14 = new FilterListIterator(var9); + final FilterListIterator var14 = new FilterListIterator<>(var9); Assert.assertFalse(var14.hasPrevious()); } diff --git a/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java b/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java index b5ed6b6ae..727c1613e 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java @@ -45,26 +45,26 @@ public class IteratorChainTest extends AbstractIteratorTest { @Override public void setUp() { - list1 = new ArrayList(); + list1 = new ArrayList<>(); list1.add("One"); list1.add("Two"); list1.add("Three"); - list2 = new ArrayList(); + list2 = new ArrayList<>(); list2.add("Four"); - list3 = new ArrayList(); + list3 = new ArrayList<>(); list3.add("Five"); list3.add("Six"); } @Override public IteratorChain makeEmptyIterator() { - final ArrayList list = new ArrayList(); - return new IteratorChain(list.iterator()); + final ArrayList list = new ArrayList<>(); + return new IteratorChain<>(list.iterator()); } @Override public IteratorChain makeObject() { - final IteratorChain chain = new IteratorChain(); + final IteratorChain chain = new IteratorChain<>(); chain.addIterator(list1.iterator()); chain.addIterator(list2.iterator()); @@ -99,8 +99,8 @@ public class IteratorChainTest extends AbstractIteratorTest { } }; - final List list1 = new ArrayList(); - final List list2 = new ArrayList(); + final List list1 = new ArrayList<>(); + final List list2 = new ArrayList<>(); list1.add(Integer.valueOf(1)); list1.add(Integer.valueOf(2)); @@ -146,12 +146,12 @@ public class IteratorChainTest extends AbstractIteratorTest { } public void testFirstIteratorIsEmptyBug() { - final List empty = new ArrayList(); - final List notEmpty = new ArrayList(); + final List empty = new ArrayList<>(); + final List notEmpty = new ArrayList<>(); notEmpty.add("A"); notEmpty.add("B"); notEmpty.add("C"); - final IteratorChain chain = new IteratorChain(); + final IteratorChain chain = new IteratorChain<>(); chain.addIterator(empty.iterator()); chain.addIterator(notEmpty.iterator()); assertTrue("should have next",chain.hasNext()); @@ -164,7 +164,7 @@ public class IteratorChainTest extends AbstractIteratorTest { } public void testEmptyChain() { - final IteratorChain chain = new IteratorChain(); + final IteratorChain chain = new IteratorChain<>(); assertEquals(false, chain.hasNext()); try { chain.next(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java b/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java index 957741ee9..ca276352e 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java @@ -32,7 +32,7 @@ public class IteratorEnumerationTest extends TestCase { public void testEnumeration() { Iterator iterator = Arrays.asList("a", "b", "c").iterator(); - IteratorEnumeration enumeration = new IteratorEnumeration(iterator); + IteratorEnumeration enumeration = new IteratorEnumeration<>(iterator); assertEquals(iterator, enumeration.getIterator()); diff --git a/src/test/java/org/apache/commons/collections4/iterators/IteratorIterableTest.java b/src/test/java/org/apache/commons/collections4/iterators/IteratorIterableTest.java index e504acf8d..dcdc3ba74 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/IteratorIterableTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/IteratorIterableTest.java @@ -37,7 +37,7 @@ public class IteratorIterableTest extends BulkTest { } private Iterator createIterator() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add(Integer.valueOf(0)); list.add(Integer.valueOf(1)); list.add(Integer.valueOf(2)); diff --git a/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java b/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java index 70aefbb3f..5ec819a42 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/LazyIteratorChainTest.java @@ -45,13 +45,13 @@ public class LazyIteratorChainTest extends AbstractIteratorTest { @Override public void setUp() { - list1 = new ArrayList(); + list1 = new ArrayList<>(); list1.add("One"); list1.add("Two"); list1.add("Three"); - list2 = new ArrayList(); + list2 = new ArrayList<>(); list2.add("Four"); - list3 = new ArrayList(); + list3 = new ArrayList<>(); list3.add("Five"); list3.add("Six"); } @@ -113,8 +113,8 @@ public class LazyIteratorChainTest extends AbstractIteratorTest { } }; - final List list1 = new ArrayList(); - final List list2 = new ArrayList(); + final List list1 = new ArrayList<>(); + final List list2 = new ArrayList<>(); list1.add(Integer.valueOf(1)); list1.add(Integer.valueOf(2)); @@ -160,8 +160,8 @@ public class LazyIteratorChainTest extends AbstractIteratorTest { } public void testFirstIteratorIsEmptyBug() { - final List empty = new ArrayList(); - final List notEmpty = new ArrayList(); + final List empty = new ArrayList<>(); + final List notEmpty = new ArrayList<>(); notEmpty.add("A"); notEmpty.add("B"); notEmpty.add("C"); diff --git a/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java b/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java index ef5941892..2d83fbc0b 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java @@ -43,7 +43,7 @@ public class ListIteratorWrapper2Test extends AbstractIteratorTest { @Override @SuppressWarnings("unchecked") public void setUp() { - list1 = new ArrayList(); + list1 = new ArrayList<>(); list1.add((E) "One"); list1.add((E) "Two"); list1.add((E) "Three"); @@ -54,13 +54,13 @@ public class ListIteratorWrapper2Test extends AbstractIteratorTest { @Override public ResettableListIterator makeEmptyIterator() { - final ArrayList list = new ArrayList(); - return new ListIteratorWrapper(list.listIterator()); + final ArrayList list = new ArrayList<>(); + return new ListIteratorWrapper<>(list.listIterator()); } @Override public ResettableListIterator makeObject() { - return new ListIteratorWrapper(list1.listIterator()); + return new ListIteratorWrapper<>(list1.listIterator()); } public void testIterator() { diff --git a/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapperTest.java b/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapperTest.java index a96970699..960fc25df 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapperTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapperTest.java @@ -44,7 +44,7 @@ public class ListIteratorWrapperTest extends AbstractIteratorTest { @Override @SuppressWarnings("unchecked") public void setUp() { - list1 = new ArrayList(); + list1 = new ArrayList<>(); list1.add((E) "One"); list1.add((E) "Two"); list1.add((E) "Three"); @@ -55,13 +55,13 @@ public class ListIteratorWrapperTest extends AbstractIteratorTest { @Override public ResettableListIterator makeEmptyIterator() { - final ArrayList list = new ArrayList(); - return new ListIteratorWrapper(list.iterator()); + final ArrayList list = new ArrayList<>(); + return new ListIteratorWrapper<>(list.iterator()); } @Override public ResettableListIterator makeObject() { - return new ListIteratorWrapper(list1.iterator()); + return new ListIteratorWrapper<>(list1.iterator()); } public void testIterator() { diff --git a/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java index 08fbae45d..80e10709e 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/LoopingIteratorTest.java @@ -35,7 +35,7 @@ public class LoopingIteratorTest extends TestCase { */ public void testConstructorEx() throws Exception { try { - new LoopingIterator(null); + new LoopingIterator<>(null); fail(); } catch (final NullPointerException ex) { } @@ -46,8 +46,8 @@ public class LoopingIteratorTest extends TestCase { * @throws Exception If something unexpected occurs. */ public void testLooping0() throws Exception { - final List list = new ArrayList(); - final LoopingIterator loop = new LoopingIterator(list); + final List list = new ArrayList<>(); + final LoopingIterator loop = new LoopingIterator<>(list); assertTrue("hasNext should return false", !loop.hasNext()); try { @@ -63,7 +63,7 @@ public class LoopingIteratorTest extends TestCase { */ public void testLooping1() throws Exception { final List list = Arrays.asList("a"); - final LoopingIterator loop = new LoopingIterator(list); + final LoopingIterator loop = new LoopingIterator<>(list); assertTrue("1st hasNext should return true", loop.hasNext()); assertEquals("a", loop.next()); @@ -82,7 +82,7 @@ public class LoopingIteratorTest extends TestCase { */ public void testLooping2() throws Exception { final List list = Arrays.asList("a", "b"); - final LoopingIterator loop = new LoopingIterator(list); + final LoopingIterator loop = new LoopingIterator<>(list); assertTrue("1st hasNext should return true", loop.hasNext()); assertEquals("a", loop.next()); @@ -101,7 +101,7 @@ public class LoopingIteratorTest extends TestCase { */ public void testLooping3() throws Exception { final List list = Arrays.asList("a", "b", "c"); - final LoopingIterator loop = new LoopingIterator(list); + final LoopingIterator loop = new LoopingIterator<>(list); assertTrue("1st hasNext should return true", loop.hasNext()); assertEquals("a", loop.next()); @@ -122,8 +122,8 @@ public class LoopingIteratorTest extends TestCase { * @throws Exception If something unexpected occurs. */ public void testRemoving1() throws Exception { - final List list = new ArrayList(Arrays.asList("a", "b", "c")); - final LoopingIterator loop = new LoopingIterator(list); + final List list = new ArrayList<>(Arrays.asList("a", "b", "c")); + final LoopingIterator loop = new LoopingIterator<>(list); assertEquals("list should have 3 elements.", 3, list.size()); assertTrue("1st hasNext should return true", loop.hasNext()); @@ -155,7 +155,7 @@ public class LoopingIteratorTest extends TestCase { */ public void testReset() throws Exception { final List list = Arrays.asList("a", "b", "c"); - final LoopingIterator loop = new LoopingIterator(list); + final LoopingIterator loop = new LoopingIterator<>(list); assertEquals("a", loop.next()); assertEquals("b", loop.next()); @@ -176,8 +176,8 @@ public class LoopingIteratorTest extends TestCase { * @throws Exception If something unexpected occurs. */ public void testSize() throws Exception { - final List list = new ArrayList(Arrays.asList("a", "b", "c")); - final LoopingIterator loop = new LoopingIterator(list); + final List list = new ArrayList<>(Arrays.asList("a", "b", "c")); + final LoopingIterator loop = new LoopingIterator<>(list); assertEquals(3, loop.size()); loop.next(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java index 95da95476..928a765ad 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/LoopingListIteratorTest.java @@ -35,7 +35,7 @@ public class LoopingListIteratorTest extends TestCase { */ public void testConstructorEx() throws Exception { try { - new LoopingListIterator(null); + new LoopingListIterator<>(null); fail(); } catch (final NullPointerException ex) { } @@ -45,8 +45,8 @@ public class LoopingListIteratorTest extends TestCase { * Tests whether an empty looping list iterator works. */ public void testLooping0() throws Exception { - final List list = new ArrayList(); - final LoopingListIterator loop = new LoopingListIterator(list); + final List list = new ArrayList<>(); + final LoopingListIterator loop = new LoopingListIterator<>(list); assertFalse(loop.hasNext()); assertFalse(loop.hasPrevious()); @@ -69,7 +69,7 @@ public class LoopingListIteratorTest extends TestCase { */ public void testLooping1() throws Exception { final List list = Arrays.asList("a"); - final LoopingListIterator loop = new LoopingListIterator(list); // + final LoopingListIterator loop = new LoopingListIterator<>(list); // assertTrue(loop.hasNext()); assertEquals("a", loop.next()); // @@ -96,7 +96,7 @@ public class LoopingListIteratorTest extends TestCase { */ public void testLooping2() throws Exception { final List list = Arrays.asList("a", "b"); - final LoopingListIterator loop = new LoopingListIterator(list); // b + final LoopingListIterator loop = new LoopingListIterator<>(list); // b assertTrue(loop.hasNext()); assertEquals("a", loop.next()); // a @@ -126,7 +126,7 @@ public class LoopingListIteratorTest extends TestCase { */ public void testJoggingNotOverBoundary() { final List list = Arrays.asList("a", "b"); - final LoopingListIterator loop = new LoopingListIterator(list); // b + final LoopingListIterator loop = new LoopingListIterator<>(list); // b // Try jogging back and forth between the elements, but not // over the begin/end boundary. @@ -146,7 +146,7 @@ public class LoopingListIteratorTest extends TestCase { */ public void testJoggingOverBoundary() { final List list = Arrays.asList("a", "b"); - final LoopingListIterator loop = new LoopingListIterator(list); // b + final LoopingListIterator loop = new LoopingListIterator<>(list); // b // Try jogging back and forth between the elements, but not // over the begin/end boundary. @@ -163,8 +163,8 @@ public class LoopingListIteratorTest extends TestCase { * Tests removing an element from a wrapped ArrayList. */ public void testRemovingElementsAndIteratingForward() { - final List list = new ArrayList(Arrays.asList("a", "b", "c")); - final LoopingListIterator loop = new LoopingListIterator(list); // b c + final List list = new ArrayList<>(Arrays.asList("a", "b", "c")); + final LoopingListIterator loop = new LoopingListIterator<>(list); // b c assertTrue(loop.hasNext()); assertEquals("a", loop.next()); // a c @@ -193,8 +193,8 @@ public class LoopingListIteratorTest extends TestCase { * Tests removing an element from a wrapped ArrayList. */ public void testRemovingElementsAndIteratingBackwards() { - final List list = new ArrayList(Arrays.asList("a", "b", "c")); - final LoopingListIterator loop = new LoopingListIterator(list); // b c + final List list = new ArrayList<>(Arrays.asList("a", "b", "c")); + final LoopingListIterator loop = new LoopingListIterator<>(list); // b c assertTrue(loop.hasPrevious()); assertEquals("c", loop.previous()); // a b @@ -224,7 +224,7 @@ public class LoopingListIteratorTest extends TestCase { */ public void testReset() { final List list = Arrays.asList("a", "b", "c"); - final LoopingListIterator loop = new LoopingListIterator(list); // b c + final LoopingListIterator loop = new LoopingListIterator<>(list); // b c assertEquals("a", loop.next()); // a c assertEquals("b", loop.next()); // a b @@ -250,8 +250,8 @@ public class LoopingListIteratorTest extends TestCase { * Tests the add method. */ public void testAdd() { - List list = new ArrayList(Arrays.asList("b", "e", "f")); - LoopingListIterator loop = new LoopingListIterator(list); // e f + List list = new ArrayList<>(Arrays.asList("b", "e", "f")); + LoopingListIterator loop = new LoopingListIterator<>(list); // e f loop.add("a"); // b e f assertEquals("b", loop.next()); // a e f @@ -275,8 +275,8 @@ public class LoopingListIteratorTest extends TestCase { assertEquals("f", loop.next()); // b c d e f assertEquals("a", loop.next()); // a c d e f - list = new ArrayList(Arrays.asList("b", "e", "f")); - loop = new LoopingListIterator(list); // e f + list = new ArrayList<>(Arrays.asList("b", "e", "f")); + loop = new LoopingListIterator<>(list); // e f loop.add("a"); // a e f assertEquals("a", loop.previous()); // a b e @@ -305,7 +305,7 @@ public class LoopingListIteratorTest extends TestCase { */ public void testNextAndPreviousIndex() { final List list = Arrays.asList("a", "b", "c"); - final LoopingListIterator loop = new LoopingListIterator(list); // b c + final LoopingListIterator loop = new LoopingListIterator<>(list); // b c assertEquals(0, loop.nextIndex()); assertEquals(2, loop.previousIndex()); @@ -336,7 +336,7 @@ public class LoopingListIteratorTest extends TestCase { */ public void testSet() { final List list = Arrays.asList("q", "r", "z"); - final LoopingListIterator loop = new LoopingListIterator(list); // r z + final LoopingListIterator loop = new LoopingListIterator<>(list); // r z assertEquals("z", loop.previous()); // q r loop.set("c"); // q r diff --git a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayIteratorTest.java index f12aefa60..c3e415e80 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayIteratorTest.java @@ -35,30 +35,30 @@ public class ObjectArrayIteratorTest extends AbstractIteratorTest { @Override @SuppressWarnings("unchecked") public ObjectArrayIterator makeEmptyIterator() { - return new ObjectArrayIterator((E[]) new Object[0]); + return new ObjectArrayIterator<>((E[]) new Object[0]); } @Override @SuppressWarnings("unchecked") public ObjectArrayIterator makeObject() { - return new ObjectArrayIterator((E[]) testArray); + return new ObjectArrayIterator<>((E[]) testArray); } @SuppressWarnings("unchecked") public ObjectArrayIterator makeArrayIterator() { - return new ObjectArrayIterator(); + return new ObjectArrayIterator<>(); } public ObjectArrayIterator makeArrayIterator(final E[] array) { - return new ObjectArrayIterator(array); + return new ObjectArrayIterator<>(array); } public ObjectArrayIterator makeArrayIterator(final E[] array, final int index) { - return new ObjectArrayIterator(array, index); + return new ObjectArrayIterator<>(array, index); } public ObjectArrayIterator makeArrayIterator(final E[] array, final int start, final int end) { - return new ObjectArrayIterator(array, start, end); + return new ObjectArrayIterator<>(array, start, end); } @Override diff --git a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIterator2Test.java b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIterator2Test.java index 89a37a98d..d8653d148 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIterator2Test.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIterator2Test.java @@ -32,17 +32,17 @@ public class ObjectArrayListIterator2Test extends AbstractListIteratorTest @Override @SuppressWarnings("unchecked") public ObjectArrayListIterator makeEmptyIterator() { - return new ObjectArrayListIterator((E[]) new Object[0]); + return new ObjectArrayListIterator<>((E[]) new Object[0]); } @Override @SuppressWarnings("unchecked") public ObjectArrayListIterator makeObject() { - return new ObjectArrayListIterator((E[]) testArray); + return new ObjectArrayListIterator<>((E[]) testArray); } public ObjectArrayListIterator makeArrayListIterator(final E[] array) { - return new ObjectArrayListIterator(array); + return new ObjectArrayListIterator<>(array); } @Override diff --git a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java index 4c1eda6fe..719fb0ba3 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java @@ -34,17 +34,17 @@ public class ObjectArrayListIteratorTest extends ObjectArrayIteratorTest { @Override @SuppressWarnings("unchecked") public ObjectArrayListIterator makeEmptyIterator() { - return new ObjectArrayListIterator((E[]) new Object[0]); + return new ObjectArrayListIterator<>((E[]) new Object[0]); } @Override @SuppressWarnings("unchecked") public ObjectArrayListIterator makeObject() { - return new ObjectArrayListIterator((E[]) testArray); + return new ObjectArrayListIterator<>((E[]) testArray); } public ObjectArrayListIterator makeArrayListIterator(final E[] array) { - return new ObjectArrayListIterator(array); + return new ObjectArrayListIterator<>(array); } /** diff --git a/src/test/java/org/apache/commons/collections4/iterators/ObjectGraphIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ObjectGraphIteratorTest.java index 9372efbec..fdbc03e6b 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ObjectGraphIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ObjectGraphIteratorTest.java @@ -44,16 +44,16 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { @Override public void setUp() { - list1 = new ArrayList(); + list1 = new ArrayList<>(); list1.add("One"); list1.add("Two"); list1.add("Three"); - list2 = new ArrayList(); + list2 = new ArrayList<>(); list2.add("Four"); - list3 = new ArrayList(); + list3 = new ArrayList<>(); list3.add("Five"); list3.add("Six"); - iteratorList = new ArrayList>(); + iteratorList = new ArrayList<>(); iteratorList.add(list1.iterator()); iteratorList.add(list2.iterator()); iteratorList.add(list3.iterator()); @@ -62,8 +62,8 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { //----------------------------------------------------------------------- @Override public ObjectGraphIterator makeEmptyIterator() { - final ArrayList list = new ArrayList(); - return new ObjectGraphIterator(list.iterator()); + final ArrayList list = new ArrayList<>(); + return new ObjectGraphIterator<>(list.iterator()); } @Override @@ -73,7 +73,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { //----------------------------------------------------------------------- public void testIteratorConstructor_null1() { - final Iterator it = new ObjectGraphIterator(null); + final Iterator it = new ObjectGraphIterator<>(null); assertEquals(false, it.hasNext()); try { @@ -89,7 +89,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { } public void testIteratorConstructor_null_next() { - final Iterator it = new ObjectGraphIterator(null); + final Iterator it = new ObjectGraphIterator<>(null); try { it.next(); fail(); @@ -98,7 +98,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { } public void testIteratorConstructor_null_remove() { - final Iterator it = new ObjectGraphIterator(null); + final Iterator it = new ObjectGraphIterator<>(null); try { it.remove(); fail(); @@ -108,7 +108,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { //----------------------------------------------------------------------- public void testIteratorConstructorIteration_Empty() { - final List> iteratorList = new ArrayList>(); + final List> iteratorList = new ArrayList<>(); final Iterator it = new ObjectGraphIterator(iteratorList.iterator()); assertEquals(false, it.hasNext()); @@ -125,7 +125,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { } public void testIteratorConstructorIteration_Simple() { - final List> iteratorList = new ArrayList>(); + final List> iteratorList = new ArrayList<>(); iteratorList.add(list1.iterator()); iteratorList.add(list2.iterator()); iteratorList.add(list3.iterator()); @@ -144,7 +144,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { } public void testIteratorConstructorIteration_SimpleNoHasNext() { - final List> iteratorList = new ArrayList>(); + final List> iteratorList = new ArrayList<>(); iteratorList.add(list1.iterator()); iteratorList.add(list2.iterator()); iteratorList.add(list3.iterator()); @@ -161,7 +161,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { } public void testIteratorConstructorIteration_WithEmptyIterators() { - final List> iteratorList = new ArrayList>(); + final List> iteratorList = new ArrayList<>(); iteratorList.add(IteratorUtils.emptyIterator()); iteratorList.add(list1.iterator()); iteratorList.add(IteratorUtils.emptyIterator()); @@ -184,7 +184,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { } public void testIteratorConstructorRemove() { - final List> iteratorList = new ArrayList>(); + final List> iteratorList = new ArrayList<>(); iteratorList.add(list1.iterator()); iteratorList.add(list2.iterator()); iteratorList.add(list3.iterator()); @@ -202,7 +202,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { //----------------------------------------------------------------------- public void testIteration_IteratorOfIterators() { - final List> iteratorList = new ArrayList>(); + final List> iteratorList = new ArrayList<>(); iteratorList.add(list1.iterator()); iteratorList.add(list2.iterator()); iteratorList.add(list3.iterator()); @@ -216,7 +216,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { } public void testIteration_IteratorOfIteratorsWithEmptyIterators() { - final List> iteratorList = new ArrayList>(); + final List> iteratorList = new ArrayList<>(); iteratorList.add(IteratorUtils.emptyIterator()); iteratorList.add(list1.iterator()); iteratorList.add(IteratorUtils.emptyIterator()); @@ -235,7 +235,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { //----------------------------------------------------------------------- public void testIteration_RootNull() { - final Iterator it = new ObjectGraphIterator(null, null); + final Iterator it = new ObjectGraphIterator<>(null, null); assertEquals(false, it.hasNext()); try { @@ -267,7 +267,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { public void testIteration_Transformed1() { final Forest forest = new Forest(); final Leaf l1 = forest.addTree().addBranch().addLeaf(); - final Iterator it = new ObjectGraphIterator(forest, new LeafFinder()); + final Iterator it = new ObjectGraphIterator<>(forest, new LeafFinder()); assertEquals(true, it.hasNext()); assertSame(l1, it.next()); @@ -295,7 +295,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { final Leaf l4 = b3.addLeaf(); final Leaf l5 = b5.addLeaf(); - final Iterator it = new ObjectGraphIterator(forest, new LeafFinder()); + final Iterator it = new ObjectGraphIterator<>(forest, new LeafFinder()); assertEquals(true, it.hasNext()); assertSame(l1, it.next()); @@ -331,7 +331,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { final Leaf l4 = b3.addLeaf(); final Leaf l5 = b4.addLeaf(); - final Iterator it = new ObjectGraphIterator(forest, new LeafFinder()); + final Iterator it = new ObjectGraphIterator<>(forest, new LeafFinder()); assertEquals(true, it.hasNext()); assertSame(l1, it.next()); @@ -373,7 +373,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { //----------------------------------------------------------------------- static class Forest { - List trees = new ArrayList(); + List trees = new ArrayList<>(); Tree addTree() { trees.add(new Tree()); @@ -390,7 +390,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { } static class Tree { - List branches = new ArrayList(); + List branches = new ArrayList<>(); Branch addBranch() { branches.add(new Branch()); @@ -407,7 +407,7 @@ public class ObjectGraphIteratorTest extends AbstractIteratorTest { } static class Branch { - List leaves = new ArrayList(); + List leaves = new ArrayList<>(); Leaf addLeaf() { leaves.add(new Leaf()); diff --git a/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java index c16c9594f..c036b4bb3 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java @@ -49,7 +49,7 @@ public class PeekingIteratorTest extends AbstractIteratorTest { @Override protected void setUp() throws Exception { super.setUp(); - testList = new ArrayList(Arrays.asList((E[]) testArray)); + testList = new ArrayList<>(Arrays.asList((E[]) testArray)); } @Override diff --git a/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java index 7f59ba315..ef0ab44bd 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java @@ -42,7 +42,7 @@ public class PermutationIteratorTest extends AbstractIteratorTest(); + testList = new ArrayList<>(); testList.addAll(Arrays.asList(testArray)); } @@ -60,12 +60,12 @@ public class PermutationIteratorTest extends AbstractIteratorTest makeEmptyIterator() { - return new PermutationIterator(new ArrayList()); + return new PermutationIterator<>(new ArrayList()); } @Override public PermutationIterator makeObject() { - return new PermutationIterator(testList); + return new PermutationIterator<>(testList); } //----------------------------------------------------------------------- @@ -74,11 +74,11 @@ public class PermutationIteratorTest extends AbstractIteratorTest list = new ArrayList(); + List list = new ArrayList<>(); for (int j = 0; j < i; j++) { list.add(j); } - Iterator> it = new PermutationIterator(list); + Iterator> it = new PermutationIterator<>(list); int count = 0; while (it.hasNext()) { it.next(); @@ -93,12 +93,12 @@ public class PermutationIteratorTest extends AbstractIteratorTest perm1 = new ArrayList(); - List perm2 = new ArrayList(); - List perm3 = new ArrayList(); - List perm4 = new ArrayList(); - List perm5 = new ArrayList(); - List perm6 = new ArrayList(); + List perm1 = new ArrayList<>(); + List perm2 = new ArrayList<>(); + List perm3 = new ArrayList<>(); + List perm4 = new ArrayList<>(); + List perm5 = new ArrayList<>(); + List perm6 = new ArrayList<>(); perm1.add('A'); perm2.add('A'); @@ -121,7 +121,7 @@ public class PermutationIteratorTest extends AbstractIteratorTest> results = new ArrayList>(); + List> results = new ArrayList<>(); PermutationIterator it = makeObject(); while (it.hasNext()) { @@ -142,8 +142,8 @@ public class PermutationIteratorTest extends AbstractIteratorTest> resultsList = new ArrayList>(); - Set> resultsSet = new HashSet>(); + List> resultsList = new ArrayList<>(); + Set> resultsSet = new HashSet<>(); PermutationIterator it = makeObject(); while (it.hasNext()) { @@ -157,7 +157,7 @@ public class PermutationIteratorTest extends AbstractIteratorTest> resultsList = new ArrayList>(); + List> resultsList = new ArrayList<>(); PermutationIterator it = makeObject(); while (it.hasNext()) { diff --git a/src/test/java/org/apache/commons/collections4/iterators/PushbackIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/PushbackIteratorTest.java index 5cf050117..8cde44638 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/PushbackIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/PushbackIteratorTest.java @@ -47,7 +47,7 @@ public class PushbackIteratorTest extends AbstractIteratorTest { @Override protected void setUp() throws Exception { super.setUp(); - testList = new ArrayList(Arrays.asList((E[]) testArray)); + testList = new ArrayList<>(Arrays.asList((E[]) testArray)); } @Override diff --git a/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java index 024b382bd..9bf04b952 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ReverseListIteratorTest.java @@ -39,14 +39,14 @@ public class ReverseListIteratorTest extends AbstractListIteratorTest { @Override public ListIterator makeEmptyIterator() { - return new ReverseListIterator(new ArrayList()); + return new ReverseListIterator<>(new ArrayList()); } @Override @SuppressWarnings("unchecked") public ReverseListIterator makeObject() { - final List list = new ArrayList(Arrays.asList((E[]) testArray)); - return new ReverseListIterator(list); + final List list = new ArrayList<>(Arrays.asList((E[]) testArray)); + return new ReverseListIterator<>(list); } // overrides @@ -77,7 +77,7 @@ public class ReverseListIteratorTest extends AbstractListIteratorTest { @Override public void testWalkForwardAndBack() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); final ListIterator it = makeObject(); while (it.hasNext()) { list.add(it.next()); diff --git a/src/test/java/org/apache/commons/collections4/iterators/SingletonIterator2Test.java b/src/test/java/org/apache/commons/collections4/iterators/SingletonIterator2Test.java index 769d54563..2e00ee1df 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/SingletonIterator2Test.java +++ b/src/test/java/org/apache/commons/collections4/iterators/SingletonIterator2Test.java @@ -39,7 +39,7 @@ public class SingletonIterator2Test extends AbstractIteratorTest { @Override @SuppressWarnings("unchecked") public SingletonIterator makeEmptyIterator() { - final SingletonIterator iter = new SingletonIterator((E) testValue); + final SingletonIterator iter = new SingletonIterator<>((E) testValue); iter.next(); iter.remove(); iter.reset(); @@ -49,7 +49,7 @@ public class SingletonIterator2Test extends AbstractIteratorTest { @Override @SuppressWarnings("unchecked") public SingletonIterator makeObject() { - return new SingletonIterator((E) testValue, false); + return new SingletonIterator<>((E) testValue, false); } @Override diff --git a/src/test/java/org/apache/commons/collections4/iterators/SingletonIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/SingletonIteratorTest.java index 088897b05..628ac839c 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/SingletonIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/SingletonIteratorTest.java @@ -51,7 +51,7 @@ public class SingletonIteratorTest extends AbstractIteratorTest { @Override @SuppressWarnings("unchecked") public SingletonIterator makeObject() { - return new SingletonIterator((E) testValue); + return new SingletonIterator<>((E) testValue); } @Override @@ -84,7 +84,7 @@ public class SingletonIteratorTest extends AbstractIteratorTest { @SuppressWarnings("unchecked") public void testSingletonIteratorRemove() { - final ResettableIterator iter = new SingletonIterator((E) "xyzzy"); + final ResettableIterator iter = new SingletonIterator<>((E) "xyzzy"); assertTrue(iter.hasNext()); assertEquals("xyzzy",iter.next()); iter.remove(); diff --git a/src/test/java/org/apache/commons/collections4/iterators/SingletonListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/SingletonListIteratorTest.java index dea2e2ecb..9d9ff407c 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/SingletonListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/SingletonListIteratorTest.java @@ -50,7 +50,7 @@ public class SingletonListIteratorTest extends AbstractListIteratorTest { @Override @SuppressWarnings("unchecked") public SingletonListIterator makeObject() { - return new SingletonListIterator((E) testValue); + return new SingletonListIterator<>((E) testValue); } @Override diff --git a/src/test/java/org/apache/commons/collections4/iterators/SkippingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/SkippingIteratorTest.java index 070e3101d..f4bf3bd7e 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/SkippingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/SkippingIteratorTest.java @@ -50,12 +50,12 @@ public class SkippingIteratorTest extends AbstractIteratorTest { @Override public Iterator makeEmptyIterator() { - return new SkippingIterator(Collections.emptyList().iterator(), 0); + return new SkippingIterator<>(Collections.emptyList().iterator(), 0); } @Override public Iterator makeObject() { - return new SkippingIterator(new ArrayList(testList).iterator(), 1); + return new SkippingIterator<>(new ArrayList<>(testList).iterator(), 1); } // ---------------- Tests --------------------- @@ -67,7 +67,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testSkipping() { - Iterator iter = new SkippingIterator(testList.iterator(), 2); + Iterator iter = new SkippingIterator<>(testList.iterator(), 2); assertTrue(iter.hasNext()); assertEquals("c", iter.next()); @@ -95,7 +95,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testSameAsDecorated() { - Iterator iter = new SkippingIterator(testList.iterator(), 0); + Iterator iter = new SkippingIterator<>(testList.iterator(), 0); assertTrue(iter.hasNext()); assertEquals("a", iter.next()); @@ -127,7 +127,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testOffsetGreaterThanSize() { - Iterator iter = new SkippingIterator(testList.iterator(), 10); + Iterator iter = new SkippingIterator<>(testList.iterator(), 10); assertFalse(iter.hasNext()); try { iter.next(); @@ -143,7 +143,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { @Test public void testNegativeOffset() { try { - new SkippingIterator(testList.iterator(), -1); + new SkippingIterator<>(testList.iterator(), -1); fail("Expected IllegalArgumentException."); } catch (IllegalArgumentException iae) { /* Success case */ } @@ -155,8 +155,8 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveWithoutCallingNext() { - List testListCopy = new ArrayList(testList); - Iterator iter = new SkippingIterator(testListCopy.iterator(), 1); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 1); try { iter.remove(); @@ -171,8 +171,8 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveCalledTwice() { - List testListCopy = new ArrayList(testList); - Iterator iter = new SkippingIterator(testListCopy.iterator(), 1); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 1); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -191,8 +191,8 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveFirst() { - List testListCopy = new ArrayList(testList); - Iterator iter = new SkippingIterator(testListCopy.iterator(), 4); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 4); assertTrue(iter.hasNext()); assertEquals("e", iter.next()); @@ -219,8 +219,8 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveMiddle() { - List testListCopy = new ArrayList(testList); - Iterator iter = new SkippingIterator(testListCopy.iterator(), 3); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 3); assertTrue(iter.hasNext()); assertEquals("d", iter.next()); @@ -249,8 +249,8 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveLast() { - List testListCopy = new ArrayList(testList); - Iterator iter = new SkippingIterator(testListCopy.iterator(), 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 5); assertTrue(iter.hasNext()); assertEquals("f", iter.next()); @@ -288,7 +288,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { } }; - Iterator iter = new SkippingIterator(mockIterator, 1); + Iterator iter = new SkippingIterator<>(mockIterator, 1); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); try { diff --git a/src/test/java/org/apache/commons/collections4/iterators/UniqueFilterIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/UniqueFilterIteratorTest.java index 5701b6532..a22fa2c55 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/UniqueFilterIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/UniqueFilterIteratorTest.java @@ -41,7 +41,7 @@ public class UniqueFilterIteratorTest extends AbstractIteratorTest { @Override @SuppressWarnings("unchecked") public void setUp() { - list1 = new ArrayList(); + list1 = new ArrayList<>(); list1.add((E) "One"); list1.add((E) "Two"); list1.add((E) "Three"); @@ -56,14 +56,14 @@ public class UniqueFilterIteratorTest extends AbstractIteratorTest { @Override public UniqueFilterIterator makeEmptyIterator() { - final ArrayList list = new ArrayList(); - return new UniqueFilterIterator(list.iterator()); + final ArrayList list = new ArrayList<>(); + return new UniqueFilterIterator<>(list.iterator()); } @Override public UniqueFilterIterator makeObject() { final Iterator i = list1.iterator(); - return new UniqueFilterIterator(i); + return new UniqueFilterIterator<>(i); } public void testIterator() { diff --git a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableIteratorTest.java index 829a43753..d86e80cfb 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableIteratorTest.java @@ -45,7 +45,7 @@ public class UnmodifiableIteratorTest extends AbstractIteratorTest { @Override protected void setUp() throws Exception { super.setUp(); - testList = new ArrayList(Arrays.asList((E[]) testArray)); + testList = new ArrayList<>(Arrays.asList((E[]) testArray)); } @Override diff --git a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java index bba5ecc04..40a89ba59 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableListIteratorTest.java @@ -45,7 +45,7 @@ public class UnmodifiableListIteratorTest extends AbstractListIteratorTest @Override protected void setUp() throws Exception { super.setUp(); - testList = new ArrayList(Arrays.asList((E[]) testArray)); + testList = new ArrayList<>(Arrays.asList((E[]) testArray)); } @Override diff --git a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableMapIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableMapIteratorTest.java index c6b1b6898..406bff7da 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableMapIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableMapIteratorTest.java @@ -48,7 +48,7 @@ public class UnmodifiableMapIteratorTest extends AbstractMapIteratorTest getMap() { - final IterableMap testMap = new DualHashBidiMap(); + final IterableMap testMap = new DualHashBidiMap<>(); testMap.put((K) "A", (V) "a"); testMap.put((K) "B", (V)"b"); testMap.put((K) "C", (V) "c"); @@ -58,7 +58,7 @@ public class UnmodifiableMapIteratorTest extends AbstractMapIteratorTest getConfirmedMap() { - final Map testMap = new HashMap(); + final Map testMap = new HashMap<>(); testMap.put((K) "A", (V) "a"); testMap.put((K) "B", (V)"b"); testMap.put((K) "C", (V) "c"); diff --git a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIteratorTest.java index 55867a2df..ac17c6789 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/UnmodifiableOrderedMapIteratorTest.java @@ -60,7 +60,7 @@ public class UnmodifiableOrderedMapIteratorTest extends AbstractOrderedMap @Override @SuppressWarnings("unchecked") public Map getConfirmedMap() { - final Map testMap = new TreeMap(); + final Map testMap = new TreeMap<>(); testMap.put((K) "A", (V) "a"); testMap.put((K) "B", (V) "b"); testMap.put((K) "C", (V) "c"); diff --git a/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java index 121a03712..47c45889f 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java @@ -43,8 +43,8 @@ public class ZippingIteratorTest extends AbstractIteratorTest { @Override public void setUp() throws Exception { super.setUp(); - evens = new ArrayList(); - odds = new ArrayList(); + evens = new ArrayList<>(); + odds = new ArrayList<>(); for (int i = 0; i < 20; i++) { if (0 == i % 2) { evens.add(i); @@ -52,7 +52,7 @@ public class ZippingIteratorTest extends AbstractIteratorTest { odds.add(i); } } - fib = new ArrayList(); + fib = new ArrayList<>(); fib.add(1); fib.add(1); fib.add(2); @@ -68,19 +68,19 @@ public class ZippingIteratorTest extends AbstractIteratorTest { @Override @SuppressWarnings("unchecked") public ZippingIterator makeEmptyIterator() { - return new ZippingIterator(IteratorUtils.emptyIterator()); + return new ZippingIterator<>(IteratorUtils.emptyIterator()); } @Override public ZippingIterator makeObject() { - return new ZippingIterator(evens.iterator(), odds.iterator(), fib.iterator()); + return new ZippingIterator<>(evens.iterator(), odds.iterator(), fib.iterator()); } //------------------------------------------------------------------- Tests public void testIterateEven() { @SuppressWarnings("unchecked") - final ZippingIterator iter = new ZippingIterator(evens.iterator()); + final ZippingIterator iter = new ZippingIterator<>(evens.iterator()); for (int i = 0; i < evens.size(); i++) { assertTrue(iter.hasNext()); assertEquals(evens.get(i), iter.next()); @@ -89,7 +89,7 @@ public class ZippingIteratorTest extends AbstractIteratorTest { } public void testIterateEvenOdd() { - final ZippingIterator iter = new ZippingIterator(evens.iterator(), odds.iterator()); + final ZippingIterator iter = new ZippingIterator<>(evens.iterator(), odds.iterator()); for (int i = 0; i < 20; i++) { assertTrue(iter.hasNext()); assertEquals(Integer.valueOf(i), iter.next()); @@ -98,7 +98,7 @@ public class ZippingIteratorTest extends AbstractIteratorTest { } public void testIterateOddEven() { - final ZippingIterator iter = new ZippingIterator(odds.iterator(), evens.iterator()); + final ZippingIterator iter = new ZippingIterator<>(odds.iterator(), evens.iterator()); for (int i = 0, j = 0; i < 20; i++) { assertTrue(iter.hasNext()); int val = iter.next(); @@ -113,7 +113,7 @@ public class ZippingIteratorTest extends AbstractIteratorTest { } public void testIterateEvenEven() { - final ZippingIterator iter = new ZippingIterator(evens.iterator(), evens.iterator()); + final ZippingIterator iter = new ZippingIterator<>(evens.iterator(), evens.iterator()); for (int i = 0; i < evens.size(); i++) { assertTrue(iter.hasNext()); assertEquals(evens.get(i), iter.next()); @@ -124,7 +124,7 @@ public class ZippingIteratorTest extends AbstractIteratorTest { } public void testIterateFibEvenOdd() { - final ZippingIterator iter = new ZippingIterator(fib.iterator(), evens.iterator(), odds.iterator()); + final ZippingIterator iter = new ZippingIterator<>(fib.iterator(), evens.iterator(), odds.iterator()); assertEquals(Integer.valueOf(1),iter.next()); // fib 1 assertEquals(Integer.valueOf(0),iter.next()); // even 0 @@ -160,7 +160,7 @@ public class ZippingIteratorTest extends AbstractIteratorTest { public void testRemoveFromSingle() { @SuppressWarnings("unchecked") - final ZippingIterator iter = new ZippingIterator(evens.iterator()); + final ZippingIterator iter = new ZippingIterator<>(evens.iterator()); int expectedSize = evens.size(); while (iter.hasNext()) { final Object o = iter.next(); @@ -174,7 +174,7 @@ public class ZippingIteratorTest extends AbstractIteratorTest { } public void testRemoveFromDouble() { - final ZippingIterator iter = new ZippingIterator(evens.iterator(), odds.iterator()); + final ZippingIterator iter = new ZippingIterator<>(evens.iterator(), odds.iterator()); int expectedSize = evens.size() + odds.size(); while (iter.hasNext()) { final Object o = iter.next(); diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java index 9bdf5f2cb..f8b44cc1d 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/AbstractMapEntryTest.java @@ -64,7 +64,7 @@ public abstract class AbstractMapEntryTest extends TestCase { * Makes a Map.Entry of a type that's known to work correctly. */ public Map.Entry makeKnownMapEntry(final K key, final V value) { - final Map map = new HashMap(1); + final Map map = new HashMap<>(1); map.put(key, value); final Map.Entry entry = map.entrySet().iterator().next(); return entry; diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java index 67dacf761..f3587d2f6 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultKeyValueTest.java @@ -39,7 +39,7 @@ public class DefaultKeyValueTest extends TestCase { * of the type being tested. */ protected DefaultKeyValue makeDefaultKeyValue() { - return new DefaultKeyValue(null, null); + return new DefaultKeyValue<>(null, null); } /** @@ -48,7 +48,7 @@ public class DefaultKeyValueTest extends TestCase { * of the type being tested. */ protected DefaultKeyValue makeDefaultKeyValue(final K key, final V value) { - return new DefaultKeyValue(key, value); + return new DefaultKeyValue<>(key, value); } //----------------------------------------------------------------------- @@ -106,15 +106,15 @@ public class DefaultKeyValueTest extends TestCase { @SuppressWarnings("unchecked") public void testConstructors() { // 1. test default constructor - DefaultKeyValue kv = new DefaultKeyValue(); + DefaultKeyValue kv = new DefaultKeyValue<>(); assertTrue(kv.getKey() == null && kv.getValue() == null); // 2. test key-value constructor - kv = new DefaultKeyValue((K) key, (V) value); + kv = new DefaultKeyValue<>((K) key, (V) value); assertTrue(kv.getKey() == key && kv.getValue() == value); // 3. test copy constructor - final DefaultKeyValue kv2 = new DefaultKeyValue(kv); + final DefaultKeyValue kv2 = new DefaultKeyValue<>(kv); assertTrue(kv2.getKey() == key && kv2.getValue() == value); // test that the KVPs are independent @@ -124,11 +124,11 @@ public class DefaultKeyValueTest extends TestCase { assertTrue(kv2.getKey() == key && kv2.getValue() == value); // 4. test Map.Entry constructor - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put((K) key, (V) value); final Map.Entry entry = map.entrySet().iterator().next(); - kv = new DefaultKeyValue(entry); + kv = new DefaultKeyValue<>(entry); assertTrue(kv.getKey() == key && kv.getValue() == value); // test that the KVP is independent of the Map.Entry @@ -170,7 +170,7 @@ public class DefaultKeyValueTest extends TestCase { public void testToMapEntry() { final DefaultKeyValue kv = makeDefaultKeyValue((K) key, (V) value); - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put(kv.getKey(), kv.getValue()); final Map.Entry entry = map.entrySet().iterator().next(); diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java index fdc8d6e91..339e0242f 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/DefaultMapEntryTest.java @@ -36,7 +36,7 @@ public class DefaultMapEntryTest extends AbstractMapEntryTest { */ @Override public Map.Entry makeMapEntry() { - return new DefaultMapEntry(null, null); + return new DefaultMapEntry<>(null, null); } /** @@ -46,7 +46,7 @@ public class DefaultMapEntryTest extends AbstractMapEntryTest { */ @Override public Map.Entry makeMapEntry(final K key, final V value) { - return new DefaultMapEntry(key, value); + return new DefaultMapEntry<>(key, value); } //----------------------------------------------------------------------- @@ -58,17 +58,17 @@ public class DefaultMapEntryTest extends AbstractMapEntryTest { @SuppressWarnings("unchecked") public void testConstructors() { // 1. test key-value constructor - final Map.Entry entry = new DefaultMapEntry((K) key, (V) value); + final Map.Entry entry = new DefaultMapEntry<>((K) key, (V) value); assertSame(key, entry.getKey()); assertSame(value, entry.getValue()); // 2. test pair constructor - final KeyValue pair = new DefaultKeyValue((K) key, (V) value); + final KeyValue pair = new DefaultKeyValue<>((K) key, (V) value); assertSame(key, pair.getKey()); assertSame(value, pair.getValue()); // 3. test copy constructor - final Map.Entry entry2 = new DefaultMapEntry(entry); + final Map.Entry entry2 = new DefaultMapEntry<>(entry); assertSame(key, entry2.getKey()); assertSame(value, entry2.getValue()); diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java index 51b130928..0bbfa43d5 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/MultiKeyTest.java @@ -54,42 +54,42 @@ public class MultiKeyTest extends TestCase { //----------------------------------------------------------------------- public void testConstructors() throws Exception { MultiKey mk; - mk = new MultiKey(ONE, TWO); + mk = new MultiKey<>(ONE, TWO); assertTrue(Arrays.equals(new Object[] { ONE, TWO }, mk.getKeys())); - mk = new MultiKey(ONE, TWO, THREE); + mk = new MultiKey<>(ONE, TWO, THREE); assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE }, mk.getKeys())); - mk = new MultiKey(ONE, TWO, THREE, FOUR); + mk = new MultiKey<>(ONE, TWO, THREE, FOUR); assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE, FOUR }, mk.getKeys())); - mk = new MultiKey(ONE, TWO, THREE, FOUR, FIVE); + mk = new MultiKey<>(ONE, TWO, THREE, FOUR, FIVE); assertTrue(Arrays.equals(new Object[] { ONE, TWO, THREE, FOUR, FIVE }, mk.getKeys())); - mk = new MultiKey(new Integer[] { THREE, FOUR, ONE, TWO }, false); + mk = new MultiKey<>(new Integer[] { THREE, FOUR, ONE, TWO }, false); assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); } public void testConstructorsByArray() throws Exception { MultiKey mk; Integer[] keys = new Integer[] { THREE, FOUR, ONE, TWO }; - mk = new MultiKey(keys); + mk = new MultiKey<>(keys); assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); keys[3] = FIVE; // no effect assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); keys = new Integer[] {}; - mk = new MultiKey(keys); + mk = new MultiKey<>(keys); assertTrue(Arrays.equals(new Object[] {}, mk.getKeys())); keys = new Integer[] { THREE, FOUR, ONE, TWO }; - mk = new MultiKey(keys, true); + mk = new MultiKey<>(keys, true); assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); keys[3] = FIVE; // no effect assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); keys = new Integer[] { THREE, FOUR, ONE, TWO }; - mk = new MultiKey(keys, false); + mk = new MultiKey<>(keys, false); assertTrue(Arrays.equals(new Object[] { THREE, FOUR, ONE, TWO }, mk.getKeys())); // change key - don't do this! // the hashcode of the MultiKey is now broken @@ -100,37 +100,37 @@ public class MultiKeyTest extends TestCase { public void testConstructorsByArrayNull() throws Exception { final Integer[] keys = null; try { - new MultiKey(keys); + new MultiKey<>(keys); fail(); } catch (final IllegalArgumentException ex) {} try { - new MultiKey(keys, true); + new MultiKey<>(keys, true); fail(); } catch (final IllegalArgumentException ex) {} try { - new MultiKey(keys, false); + new MultiKey<>(keys, false); fail(); } catch (final IllegalArgumentException ex) {} } public void testSize() { - assertEquals(2, new MultiKey(ONE, TWO).size()); - assertEquals(2, new MultiKey(null, null).size()); - assertEquals(3, new MultiKey(ONE, TWO, THREE).size()); - assertEquals(3, new MultiKey(null, null, null).size()); - assertEquals(4, new MultiKey(ONE, TWO, THREE, FOUR).size()); - assertEquals(4, new MultiKey(null, null, null, null).size()); - assertEquals(5, new MultiKey(ONE, TWO, THREE, FOUR, FIVE).size()); - assertEquals(5, new MultiKey(null, null, null, null, null).size()); + assertEquals(2, new MultiKey<>(ONE, TWO).size()); + assertEquals(2, new MultiKey<>(null, null).size()); + assertEquals(3, new MultiKey<>(ONE, TWO, THREE).size()); + assertEquals(3, new MultiKey<>(null, null, null).size()); + assertEquals(4, new MultiKey<>(ONE, TWO, THREE, FOUR).size()); + assertEquals(4, new MultiKey<>(null, null, null, null).size()); + assertEquals(5, new MultiKey<>(ONE, TWO, THREE, FOUR, FIVE).size()); + assertEquals(5, new MultiKey<>(null, null, null, null, null).size()); - assertEquals(0, new MultiKey(new Object[] {}).size()); - assertEquals(1, new MultiKey(new Integer[] { ONE }).size()); - assertEquals(2, new MultiKey(new Integer[] { ONE, TWO }).size()); - assertEquals(7, new MultiKey(new Integer[] { ONE, TWO, ONE, TWO, ONE, TWO, ONE }).size()); + assertEquals(0, new MultiKey<>(new Object[] {}).size()); + assertEquals(1, new MultiKey<>(new Integer[] { ONE }).size()); + assertEquals(2, new MultiKey<>(new Integer[] { ONE, TWO }).size()); + assertEquals(7, new MultiKey<>(new Integer[] { ONE, TWO, ONE, TWO, ONE, TWO, ONE }).size()); } public void testGetIndexed() { - final MultiKey mk = new MultiKey(ONE, TWO); + final MultiKey mk = new MultiKey<>(ONE, TWO); assertSame(ONE, mk.getKey(0)); assertSame(TWO, mk.getKey(1)); try { @@ -144,7 +144,7 @@ public class MultiKeyTest extends TestCase { } public void testGetKeysSimpleConstructor() { - final MultiKey mk = new MultiKey(ONE, TWO); + final MultiKey mk = new MultiKey<>(ONE, TWO); final Object[] array = mk.getKeys(); assertSame(ONE, array[0]); assertSame(TWO, array[1]); @@ -153,7 +153,7 @@ public class MultiKeyTest extends TestCase { public void testGetKeysArrayConstructorCloned() { final Integer[] keys = new Integer[] { ONE, TWO }; - final MultiKey mk = new MultiKey(keys, true); + final MultiKey mk = new MultiKey<>(keys, true); final Object[] array = mk.getKeys(); assertTrue(array != keys); assertTrue(Arrays.equals(array, keys)); @@ -164,7 +164,7 @@ public class MultiKeyTest extends TestCase { public void testGetKeysArrayConstructorNonCloned() { final Integer[] keys = new Integer[] { ONE, TWO }; - final MultiKey mk = new MultiKey(keys, false); + final MultiKey mk = new MultiKey<>(keys, false); final Object[] array = mk.getKeys(); assertTrue(array != keys); // still not equal assertTrue(Arrays.equals(array, keys)); @@ -174,8 +174,8 @@ public class MultiKeyTest extends TestCase { } public void testHashCode() { - final MultiKey mk1 = new MultiKey(ONE, TWO); - final MultiKey mk2 = new MultiKey(ONE, TWO); + final MultiKey mk1 = new MultiKey<>(ONE, TWO); + final MultiKey mk2 = new MultiKey<>(ONE, TWO); final MultiKey mk3 = new MultiKey(ONE, "TWO"); assertTrue(mk1.hashCode() == mk1.hashCode()); @@ -187,8 +187,8 @@ public class MultiKeyTest extends TestCase { } public void testEquals() { - final MultiKey mk1 = new MultiKey(ONE, TWO); - final MultiKey mk2 = new MultiKey(ONE, TWO); + final MultiKey mk1 = new MultiKey<>(ONE, TWO); + final MultiKey mk2 = new MultiKey<>(ONE, TWO); final MultiKey mk3 = new MultiKey(ONE, "TWO"); assertEquals(mk1, mk1); @@ -232,7 +232,7 @@ public class MultiKeyTest extends TestCase { { SystemHashCodeSimulatingKey sysKey = new SystemHashCodeSimulatingKey("test"); final MultiKey mk = new MultiKey(ONE, sysKey); - final Map, Integer> map = new HashMap, Integer>(); + final Map, Integer> map = new HashMap<>(); map.put(mk, TWO); // serialize @@ -275,7 +275,7 @@ public class MultiKeyTest extends TestCase { public void testEqualsAfterSerializationOfDerivedClass() throws IOException, ClassNotFoundException { - final DerivedMultiKey mk = new DerivedMultiKey("A", "B"); + final DerivedMultiKey mk = new DerivedMultiKey<>("A", "B"); // serialize final ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java index 9c5187b5a..917b040a4 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/TiedMapEntryTest.java @@ -33,9 +33,9 @@ public class TiedMapEntryTest extends AbstractMapEntryTest { */ @Override public Map.Entry makeMapEntry(final K key, final V value) { - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put(key, value); - return new TiedMapEntry(map, key); + return new TiedMapEntry<>(map, key); } //----------------------------------------------------------------------- @@ -52,25 +52,25 @@ public class TiedMapEntryTest extends AbstractMapEntryTest { */ @SuppressWarnings("unchecked") public void testSetValue() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put((K) "A", (V) "a"); map.put((K) "B", (V) "b"); map.put((K) "C", (V) "c"); - Map.Entry entry = new TiedMapEntry(map, (K) "A"); + Map.Entry entry = new TiedMapEntry<>(map, (K) "A"); assertSame("A", entry.getKey()); assertSame("a", entry.getValue()); assertSame("a", entry.setValue((V) "x")); assertSame("A", entry.getKey()); assertSame("x", entry.getValue()); - entry = new TiedMapEntry(map, (K) "B"); + entry = new TiedMapEntry<>(map, (K) "B"); assertSame("B", entry.getKey()); assertSame("b", entry.getValue()); assertSame("b", entry.setValue((V) "y")); assertSame("B", entry.getKey()); assertSame("y", entry.getValue()); - entry = new TiedMapEntry(map, (K) "C"); + entry = new TiedMapEntry<>(map, (K) "C"); assertSame("C", entry.getKey()); assertSame("c", entry.getValue()); assertSame("c", entry.setValue((V) "z")); diff --git a/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java b/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java index aee874cad..08db57488 100644 --- a/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java +++ b/src/test/java/org/apache/commons/collections4/keyvalue/UnmodifiableMapEntryTest.java @@ -37,7 +37,7 @@ public class UnmodifiableMapEntryTest extends AbstractMapEntryTest { */ @Override public Map.Entry makeMapEntry() { - return new UnmodifiableMapEntry(null, null); + return new UnmodifiableMapEntry<>(null, null); } /** @@ -47,7 +47,7 @@ public class UnmodifiableMapEntryTest extends AbstractMapEntryTest { */ @Override public Map.Entry makeMapEntry(final K key, final V value) { - return new UnmodifiableMapEntry(key, value); + return new UnmodifiableMapEntry<>(key, value); } //----------------------------------------------------------------------- @@ -59,18 +59,18 @@ public class UnmodifiableMapEntryTest extends AbstractMapEntryTest { @SuppressWarnings("unchecked") public void testConstructors() { // 1. test key-value constructor - Map.Entry entry = new UnmodifiableMapEntry((K) key, (V) value); + Map.Entry entry = new UnmodifiableMapEntry<>((K) key, (V) value); assertSame(key, entry.getKey()); assertSame(value, entry.getValue()); // 2. test pair constructor - final KeyValue pair = new DefaultKeyValue((K) key, (V) value); - entry = new UnmodifiableMapEntry(pair); + final KeyValue pair = new DefaultKeyValue<>((K) key, (V) value); + entry = new UnmodifiableMapEntry<>(pair); assertSame(key, entry.getKey()); assertSame(value, entry.getValue()); // 3. test copy constructor - final Map.Entry entry2 = new UnmodifiableMapEntry(entry); + final Map.Entry entry2 = new UnmodifiableMapEntry<>(entry); assertSame(key, entry2.getKey()); assertSame(value, entry2.getValue()); diff --git a/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java b/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java index 452805cb8..bc4ce7cbb 100644 --- a/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java @@ -120,7 +120,7 @@ public abstract class AbstractListTest extends AbstractCollectionTest { */ @Override public Collection makeConfirmedCollection() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); return list; } @@ -129,7 +129,7 @@ public abstract class AbstractListTest extends AbstractCollectionTest { */ @Override public Collection makeConfirmedFullCollection() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } @@ -323,7 +323,7 @@ public abstract class AbstractListTest extends AbstractCollectionTest { // main list is only size 1, so lets add other elements to get a better list list.addAll(Arrays.asList(getOtherElements())); getConfirmed().addAll(Arrays.asList(getOtherElements())); - list2 = new ArrayList(list2); + list2 = new ArrayList<>(list2); list2.addAll(Arrays.asList(getOtherElements())); } if (list2.size() > 1) { @@ -1133,7 +1133,7 @@ public abstract class AbstractListTest extends AbstractCollectionTest { if (getFullElements().length - 6 < 10) { return null; } - return new BulkTestSubList(this); + return new BulkTestSubList<>(this); } public static class BulkTestSubList extends AbstractListTest { diff --git a/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java b/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java index 3af40797b..9a2b316ee 100644 --- a/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java @@ -47,12 +47,12 @@ public class CursorableLinkedListTest extends AbstractLinkedListTest { @Override public void setUp() { - list = new CursorableLinkedList(); + list = new CursorableLinkedList<>(); } @Override public CursorableLinkedList makeObject() { - return new CursorableLinkedList(); + return new CursorableLinkedList<>(); } @SuppressWarnings("unchecked") @@ -75,7 +75,7 @@ public class CursorableLinkedListTest extends AbstractLinkedListTest { list.add(7,(E) Integer.valueOf(5)); assertEquals("[-2, -1, 0, 1, 2, 3, 4, 5]",list.toString()); - final List list2 = new LinkedList(); + final List list2 = new LinkedList<>(); list2.add((E) "A"); list2.add((E) "B"); list2.add((E) "C"); @@ -140,7 +140,7 @@ public class CursorableLinkedListTest extends AbstractLinkedListTest { @SuppressWarnings("unchecked") public void testContainsAll() { assertTrue(list.containsAll(list)); - final java.util.List list2 = new java.util.LinkedList(); + final java.util.List list2 = new java.util.LinkedList<>(); assertTrue(list.containsAll(list2)); list2.add((E) "A"); assertTrue(!list.containsAll(list2)); @@ -836,11 +836,11 @@ public class CursorableLinkedListTest extends AbstractLinkedListTest { assertTrue(list.equals(list)); assertEquals(list.hashCode(),list.hashCode()); - final CursorableLinkedList list2 = new CursorableLinkedList(); + final CursorableLinkedList list2 = new CursorableLinkedList<>(); assertTrue(!list.equals(list2)); assertTrue(!list2.equals(list)); - final java.util.List list3 = new java.util.LinkedList(); + final java.util.List list3 = new java.util.LinkedList<>(); assertTrue(!list.equals(list3)); assertTrue(!list3.equals(list)); assertTrue(list2.equals(list3)); @@ -1178,7 +1178,7 @@ public class CursorableLinkedListTest extends AbstractLinkedListTest { list.add((E) "4"); list.add((E) "5"); - final HashSet set = new HashSet(); + final HashSet set = new HashSet<>(); set.add((E) "A"); set.add((E) "2"); set.add((E) "C"); @@ -1260,7 +1260,7 @@ public class CursorableLinkedListTest extends AbstractLinkedListTest { list.add((E) "5"); list.add((E) "5"); - final HashSet set = new HashSet(); + final HashSet set = new HashSet<>(); set.add((E) "A"); set.add((E) "2"); set.add((E) "C"); @@ -1501,7 +1501,7 @@ public class CursorableLinkedListTest extends AbstractLinkedListTest { */ @Override public String[] ignoredTests() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); final String prefix = "CursorableLinkedListTest"; final String bulk = ".bulkTestSubList"; final String[] ignored = new String[] { diff --git a/src/test/java/org/apache/commons/collections4/list/FixedSizeListTest.java b/src/test/java/org/apache/commons/collections4/list/FixedSizeListTest.java index 0b7996f1e..a93b80664 100644 --- a/src/test/java/org/apache/commons/collections4/list/FixedSizeListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/FixedSizeListTest.java @@ -40,7 +40,7 @@ public class FixedSizeListTest extends AbstractListTest { @Override public List makeFullCollection() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return FixedSizeList.fixedSizeList(list); } diff --git a/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java b/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java index 38d68c434..da3fedd0c 100644 --- a/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java @@ -35,12 +35,12 @@ public class GrowthListTest extends AbstractListTest { @Override public List makeObject() { - return new GrowthList(); + return new GrowthList<>(); } @Override public List makeFullCollection() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return GrowthList.growthList(list); } @@ -48,7 +48,7 @@ public class GrowthListTest extends AbstractListTest { //----------------------------------------------------------------------- public void testGrowthAdd() { final Integer one = Integer.valueOf(1); - final GrowthList grower = new GrowthList(); + final GrowthList grower = new GrowthList<>(); assertEquals(0, grower.size()); grower.add(1, one); assertEquals(2, grower.size()); @@ -59,10 +59,10 @@ public class GrowthListTest extends AbstractListTest { public void testGrowthAddAll() { final Integer one = Integer.valueOf(1); final Integer two = Integer.valueOf(2); - final Collection coll = new ArrayList(); + final Collection coll = new ArrayList<>(); coll.add(one); coll.add(two); - final GrowthList grower = new GrowthList(); + final GrowthList grower = new GrowthList<>(); assertEquals(0, grower.size()); grower.addAll(1, coll); assertEquals(3, grower.size()); @@ -73,7 +73,7 @@ public class GrowthListTest extends AbstractListTest { public void testGrowthSet1() { final Integer one = Integer.valueOf(1); - final GrowthList grower = new GrowthList(); + final GrowthList grower = new GrowthList<>(); assertEquals(0, grower.size()); grower.set(1, one); assertEquals(2, grower.size()); @@ -83,7 +83,7 @@ public class GrowthListTest extends AbstractListTest { public void testGrowthSet2() { final Integer one = Integer.valueOf(1); - final GrowthList grower = new GrowthList(); + final GrowthList grower = new GrowthList<>(); assertEquals(0, grower.size()); grower.set(0, one); assertEquals(1, grower.size()); diff --git a/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java b/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java index cb62502b9..00c57d46b 100644 --- a/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java @@ -41,7 +41,7 @@ public class NodeCachingLinkedListTest extends AbstractLinkedListTest { //----------------------------------------------------------------------- @Override public NodeCachingLinkedList makeObject() { - return new NodeCachingLinkedList(); + return new NodeCachingLinkedList<>(); } @Override @@ -73,8 +73,8 @@ public class NodeCachingLinkedListTest extends AbstractLinkedListTest { //----------------------------------------------------------------------- public static void compareSpeed() { - final NodeCachingLinkedList ncll = new NodeCachingLinkedList(); - final LinkedList ll = new LinkedList(); + final NodeCachingLinkedList ncll = new NodeCachingLinkedList<>(); + final LinkedList ll = new LinkedList<>(); final Object o1 = new Object(); final Object o2 = new Object(); diff --git a/src/test/java/org/apache/commons/collections4/list/PredicatedListTest.java b/src/test/java/org/apache/commons/collections4/list/PredicatedListTest.java index 8a5a6b717..0ecaf0db1 100644 --- a/src/test/java/org/apache/commons/collections4/list/PredicatedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/PredicatedListTest.java @@ -85,7 +85,7 @@ public class PredicatedListTest extends AbstractListTest { @SuppressWarnings("unchecked") public void testIllegalAddAll() { final List list = makeTestList(); - final List elements = new ArrayList(); + final List elements = new ArrayList<>(); elements.add((E) "one"); elements.add((E) "two"); elements.add((E) Integer.valueOf(3)); @@ -121,7 +121,7 @@ public class PredicatedListTest extends AbstractListTest { public void testLegalAddAll() { final List list = makeTestList(); list.add((E) "zero"); - final List elements = new ArrayList(); + final List elements = new ArrayList<>(); elements.add((E) "one"); elements.add((E) "two"); elements.add((E) "three"); diff --git a/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java b/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java index d57acbecb..4b5edb268 100644 --- a/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java @@ -40,7 +40,7 @@ public class SetUniqueListTest extends AbstractListTest { //----------------------------------------------------------------------- @Override public List makeObject() { - return new SetUniqueList(new ArrayList(), new HashSet()); + return new SetUniqueList<>(new ArrayList(), new HashSet()); } //----------------------------------------------------------------------- @@ -141,7 +141,7 @@ public class SetUniqueListTest extends AbstractListTest { public void testIntCollectionAddAll() { // make a SetUniqueList with one element - final List list = new SetUniqueList(new ArrayList(), new HashSet()); + final List list = new SetUniqueList<>(new ArrayList(), new HashSet()); final Integer existingElement = Integer.valueOf(1); list.add(existingElement); @@ -210,7 +210,7 @@ public class SetUniqueListTest extends AbstractListTest { //----------------------------------------------------------------------- public void testFactory() { final Integer[] array = new Integer[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(1) }; - final ArrayList list = new ArrayList(Arrays.asList(array)); + final ArrayList list = new ArrayList<>(Arrays.asList(array)); final SetUniqueList lset = SetUniqueList.setUniqueList(list); assertEquals("Duplicate element was added.", 2, lset.size()); @@ -222,7 +222,7 @@ public class SetUniqueListTest extends AbstractListTest { @SuppressWarnings("unchecked") public void testAdd() { - final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet()); + final SetUniqueList lset = new SetUniqueList<>(new ArrayList(), new HashSet()); // Duplicate element final E obj = (E) Integer.valueOf(1); @@ -237,7 +237,7 @@ public class SetUniqueListTest extends AbstractListTest { @SuppressWarnings("unchecked") public void testAddAll() { - final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet()); + final SetUniqueList lset = new SetUniqueList<>(new ArrayList(), new HashSet()); lset.addAll( Arrays.asList((E[]) new Integer[] { Integer.valueOf(1), Integer.valueOf(1)})); @@ -247,7 +247,7 @@ public class SetUniqueListTest extends AbstractListTest { @SuppressWarnings("unchecked") public void testSet() { - final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet()); + final SetUniqueList lset = new SetUniqueList<>(new ArrayList(), new HashSet()); // Duplicate element final E obj1 = (E) Integer.valueOf(1); @@ -286,7 +286,7 @@ public class SetUniqueListTest extends AbstractListTest { @SuppressWarnings("unchecked") public void testListIterator() { - final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet()); + final SetUniqueList lset = new SetUniqueList<>(new ArrayList(), new HashSet()); final E obj1 = (E) Integer.valueOf(1); final E obj2 = (E) Integer.valueOf(2); @@ -346,9 +346,9 @@ public class SetUniqueListTest extends AbstractListTest { * set(0,b): [b]->a * So UniqList contains [b] and a is returned */ - final ArrayList l = new ArrayList(); - final HashSet s = new HashSet(); - final SetUniqueList ul = new SetUniqueList(l, s); + final ArrayList l = new ArrayList<>(); + final HashSet s = new HashSet<>(); + final SetUniqueList ul = new SetUniqueList<>(l, s); final E a = (E) new Object(); final E b = (E) new Object(); @@ -375,9 +375,9 @@ public class SetUniqueListTest extends AbstractListTest { * set(0,b): [b,c]->a * So UniqList contains [b,c] and a is returned */ - final ArrayList l = new ArrayList(); - final HashSet s = new HashSet(); - final SetUniqueList ul = new SetUniqueList(l, s); + final ArrayList l = new ArrayList<>(); + final HashSet s = new HashSet<>(); + final SetUniqueList ul = new SetUniqueList<>(l, s); final E a = (E) new Object(); final E b = (E) new Object(); @@ -411,9 +411,9 @@ public class SetUniqueListTest extends AbstractListTest { * set(1,a): [a,c]->b * So UniqList contains [a,c] and b is returned */ - final ArrayList l = new ArrayList(); - final HashSet s = new HashSet(); - final SetUniqueList ul = new SetUniqueList(l, s); + final ArrayList l = new ArrayList<>(); + final HashSet s = new HashSet<>(); + final SetUniqueList ul = new SetUniqueList<>(l, s); final E a = (E) new String("A"); final E b = (E) new String("B"); @@ -440,7 +440,7 @@ public class SetUniqueListTest extends AbstractListTest { } public void testCollections304() { - final List list = new LinkedList(); + final List list = new LinkedList<>(); final SetUniqueList decoratedList = SetUniqueList.setUniqueList(list); final String s1 = "Apple"; final String s2 = "Lemon"; @@ -474,7 +474,7 @@ public class SetUniqueListTest extends AbstractListTest { } @SuppressWarnings("unchecked") public void testCollections307() { - List list = new ArrayList(); + List list = new ArrayList<>(); List uniqueList = SetUniqueList.setUniqueList(list); final String hello = "Hello"; @@ -488,14 +488,14 @@ public class SetUniqueListTest extends AbstractListTest { assertFalse(subList.contains(world)); // passes assertFalse(subUniqueList.contains(world)); // fails - List worldList = new ArrayList(); + List worldList = new ArrayList<>(); worldList.add((E) world); assertFalse(subList.contains("World")); // passes assertFalse(subUniqueList.contains("World")); // fails // repeat the test with a different class than HashSet; // which means subclassing SetUniqueList below - list = new ArrayList(); + list = new ArrayList<>(); uniqueList = new SetUniqueList307(list, new java.util.TreeSet()); uniqueList.add((E) hello); @@ -507,7 +507,7 @@ public class SetUniqueListTest extends AbstractListTest { assertFalse(subList.contains(world)); // passes assertFalse(subUniqueList.contains(world)); // fails - worldList = new ArrayList(); + worldList = new ArrayList<>(); worldList.add((E) world); assertFalse(subList.contains("World")); // passes assertFalse(subUniqueList.contains("World")); // fails @@ -515,13 +515,13 @@ public class SetUniqueListTest extends AbstractListTest { @SuppressWarnings("unchecked") public void testRetainAll() { - final List list = new ArrayList(10); + final List list = new ArrayList<>(10); final SetUniqueList uniqueList = SetUniqueList.setUniqueList(list); for (int i = 0; i < 10; ++i) { uniqueList.add((E)Integer.valueOf(i)); } - final Collection retained = new ArrayList(5); + final Collection retained = new ArrayList<>(5); for (int i = 0; i < 5; ++i) { retained.add((E)Integer.valueOf(i * 2)); } @@ -538,7 +538,7 @@ public class SetUniqueListTest extends AbstractListTest { @SuppressWarnings("unchecked") public void testRetainAllWithInitialList() { // initialized with empty list - final List list = new ArrayList(10); + final List list = new ArrayList<>(10); for (int i = 0; i < 5; ++i) { list.add((E)Integer.valueOf(i)); } @@ -547,7 +547,7 @@ public class SetUniqueListTest extends AbstractListTest { uniqueList.add((E)Integer.valueOf(i)); } - final Collection retained = new ArrayList(5); + final Collection retained = new ArrayList<>(5); for (int i = 0; i < 5; ++i) { retained.add((E)Integer.valueOf(i * 2)); } @@ -562,7 +562,7 @@ public class SetUniqueListTest extends AbstractListTest { } public void testSetCollections444() { - final SetUniqueList lset = new SetUniqueList(new ArrayList(), new HashSet()); + final SetUniqueList lset = new SetUniqueList<>(new ArrayList(), new HashSet()); // Duplicate element final Integer obj1 = Integer.valueOf(1); diff --git a/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java b/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java index 719b68061..97fb889da 100644 --- a/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java @@ -39,12 +39,12 @@ public class TransformedListTest extends AbstractListTest { @Override public List makeConfirmedCollection() { - return new ArrayList(); + return new ArrayList<>(); } @Override public List makeConfirmedFullCollection() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } @@ -58,7 +58,7 @@ public class TransformedListTest extends AbstractListTest { @Override @SuppressWarnings("unchecked") public List makeFullCollection() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return TransformedList.transformingList(list, (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); } @@ -95,7 +95,7 @@ public class TransformedListTest extends AbstractListTest { it.add((E) "44"); assertEquals(Integer.valueOf(44), list.get(1)); - final List adds = new ArrayList(); + final List adds = new ArrayList<>(); adds.add((E) "1"); adds.add((E) "2"); list.clear(); @@ -112,7 +112,7 @@ public class TransformedListTest extends AbstractListTest { } public void testTransformedList_decorateTransform() { - final List originalList = new ArrayList(); + final List originalList = new ArrayList<>(); final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; for (final Object el : els) { originalList.add(el); diff --git a/src/test/java/org/apache/commons/collections4/list/TreeListTest.java b/src/test/java/org/apache/commons/collections4/list/TreeListTest.java index 9377d88a9..98bd96fcd 100644 --- a/src/test/java/org/apache/commons/collections4/list/TreeListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/TreeListTest.java @@ -107,7 +107,7 @@ public class TreeListTest extends AbstractListTest { //----------------------------------------------------------------------- @Override public TreeList makeObject() { - return new TreeList(); + return new TreeList<>(); } //----------------------------------------------------------------------- @@ -220,7 +220,7 @@ public class TreeListTest extends AbstractListTest { public void testBug35258() { final Object objectToRemove = Integer.valueOf(3); - final List treelist = new TreeList(); + final List treelist = new TreeList<>(); treelist.add(Integer.valueOf(0)); treelist.add(Integer.valueOf(1)); treelist.add(Integer.valueOf(2)); @@ -248,7 +248,7 @@ public class TreeListTest extends AbstractListTest { } public void testBugCollections447() { - final List treeList = new TreeList(); + final List treeList = new TreeList<>(); treeList.add("A"); treeList.add("B"); treeList.add("C"); @@ -274,11 +274,11 @@ public class TreeListTest extends AbstractListTest { // when initializing the TreeList with another collection for (int size = 1; size < 1000; size++) { - List other = new ArrayList(size); + List other = new ArrayList<>(size); for (int i = 0; i < size; i++) { other.add(i); } - TreeList l = new TreeList(other); + TreeList l = new TreeList<>(other); ListIterator it = l.listIterator(); int i = 0; while (it.hasNext()) { @@ -304,11 +304,11 @@ public class TreeListTest extends AbstractListTest { int size = 1000; for (int i = 0; i < 100; i++) { - List other = new ArrayList(size); + List other = new ArrayList<>(size); for (int j = i; j < size; j++) { other.add(j); } - TreeList l = new TreeList(); + TreeList l = new TreeList<>(); for (int j = 0; j < i; j++) { l.add(j); } diff --git a/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java b/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java index 0e1fa5b50..8265d23cb 100644 --- a/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java @@ -37,14 +37,14 @@ public class UnmodifiableListTest extends AbstractListTest { //----------------------------------------------------------------------- @Override public UnmodifiableList makeObject() { - return new UnmodifiableList(new ArrayList()); + return new UnmodifiableList<>(new ArrayList()); } @Override public UnmodifiableList makeFullCollection() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); - return new UnmodifiableList(list); + return new UnmodifiableList<>(list); } @Override @@ -69,7 +69,7 @@ public class UnmodifiableListTest extends AbstractListTest { @SuppressWarnings("unchecked") protected void setupList() { list = makeFullCollection(); - array = new ArrayList(); + array = new ArrayList<>(); array.add((E) Integer.valueOf(1)); } diff --git a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java index 59b7db1d9..1739a5f55 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java @@ -322,7 +322,7 @@ public abstract class AbstractMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") protected List getAsList(final Object[] o) { - final ArrayList result = new ArrayList(); + final ArrayList result = new ArrayList<>(); for (final Object element : o) { result.add((E) element); } @@ -451,14 +451,14 @@ public abstract class AbstractMapTest extends AbstractObjectTest { * @return a map that is known to be valid */ public Map makeConfirmedMap() { - return new HashMap(); + return new HashMap<>(); } /** * Creates a new Map Entry that is independent of the first and the map. */ public static Map.Entry cloneMapEntry(final Map.Entry entry) { - final HashMap map = new HashMap(); + final HashMap map = new HashMap<>(); map.put(entry.getKey(), entry.getValue()); return map.entrySet().iterator().next(); } @@ -1128,7 +1128,7 @@ public abstract class AbstractMapTest extends AbstractObjectTest { resetFull(); final Set> entrySet = getMap().entrySet(); final Map.Entry entry = entrySet.iterator().next(); - final HashMap temp = new HashMap(); + final HashMap temp = new HashMap<>(); temp.put(entry.getKey(), (V) "A VERY DIFFERENT VALUE"); final Map.Entry test = temp.entrySet().iterator().next(); assertEquals(false, entrySet.contains(test)); @@ -1175,7 +1175,7 @@ public abstract class AbstractMapTest extends AbstractObjectTest { final Set> entrySet = getMap().entrySet(); final Map.Entry entry = entrySet.iterator().next(); final K key = entry.getKey(); - final HashMap temp = new HashMap(); + final HashMap temp = new HashMap<>(); temp.put(entry.getKey(), (V) "A VERY DIFFERENT VALUE"); final Map.Entry test = temp.entrySet().iterator().next(); @@ -1405,7 +1405,7 @@ public abstract class AbstractMapTest extends AbstractObjectTest { final Set> entrySet = getMap().entrySet(); for (int i = 0; i < sampleKeys.length; i++) { try { - entrySet.remove(new DefaultMapEntry(sampleKeys[i], sampleValues[i])); + entrySet.remove(new DefaultMapEntry<>(sampleKeys[i], sampleValues[i])); } catch (final UnsupportedOperationException e) { // if entrySet removal is unsupported, just skip this test return; @@ -1436,7 +1436,7 @@ public abstract class AbstractMapTest extends AbstractObjectTest { return; } final Set> entrySet = getMap().entrySet(); - final HashSet> comparisonSet = new HashSet>(entrySet); + final HashSet> comparisonSet = new HashSet<>(entrySet); try { assertFalse(entrySet.removeAll(Collections.> emptySet())); } catch (final UnsupportedOperationException e) { @@ -1471,7 +1471,7 @@ public abstract class AbstractMapTest extends AbstractObjectTest { return; } final Set> entrySet = getMap().entrySet(); - final HashSet> comparisonSet = new HashSet>(entrySet); + final HashSet> comparisonSet = new HashSet<>(entrySet); try { assertFalse(entrySet.retainAll(comparisonSet)); } catch (final UnsupportedOperationException e) { @@ -2011,7 +2011,7 @@ public abstract class AbstractMapTest extends AbstractObjectTest { } public void verifyValues() { - final List known = new ArrayList(getConfirmed().values()); + final List known = new ArrayList<>(getConfirmed().values()); // bug in IBM JDK: IBM J9 VM build 2.4, JRE 1.6.0 IBM J9 2.4 Linux x86-32 jvmxi3260sr12-20121024_126067 // a call to values() on an empty map retrieved via TreeMap#headMap or tailMap @@ -2019,7 +2019,7 @@ public abstract class AbstractMapTest extends AbstractObjectTest { // it will also not recover, as the value view is cached internally values = getMap().values(); - final List test = new ArrayList(values); + final List test = new ArrayList<>(values); final int size = getConfirmed().size(); final boolean empty = getConfirmed().isEmpty(); diff --git a/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java b/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java index f6a6f6356..037738380 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java @@ -69,7 +69,7 @@ public abstract class AbstractOrderedMapTest extends AbstractIterableMapTe */ @Override public Map makeConfirmedMap() { - return new TreeMap(new NullComparator()); + return new TreeMap<>(new NullComparator()); } /** @@ -79,7 +79,7 @@ public abstract class AbstractOrderedMapTest extends AbstractIterableMapTe @Override @SuppressWarnings("unchecked") public K[] getSampleKeys() { - final List list = new ArrayList(Arrays.asList(super.getSampleKeys())); + final List list = new ArrayList<>(Arrays.asList(super.getSampleKeys())); Collections.sort(list, new NullComparator()); return (K[]) list.toArray(); } @@ -164,7 +164,7 @@ public abstract class AbstractOrderedMapTest extends AbstractIterableMapTe resetFull(); ordered = getMap(); - final List list = new ArrayList(confirmed.keySet()); + final List list = new ArrayList<>(confirmed.keySet()); Collections.reverse(list); final Iterator it = list.iterator(); K confirmedLast = it.next(); diff --git a/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java index 9e603c3a0..8991a5f87 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java @@ -60,7 +60,7 @@ public abstract class AbstractSortedMapTest extends AbstractMapTest */ @Override public SortedMap makeConfirmedMap() { - return new TreeMap(); + return new TreeMap<>(); } //----------------------------------------------------------------------- @@ -99,22 +99,22 @@ public abstract class AbstractSortedMapTest extends AbstractMapTest //----------------------------------------------------------------------- public BulkTest bulkTestHeadMap() { - return new TestHeadMap(this); + return new TestHeadMap<>(this); } public BulkTest bulkTestTailMap() { - return new TestTailMap(this); + return new TestTailMap<>(this); } public BulkTest bulkTestSubMap() { - return new TestSubMap(this); + return new TestSubMap<>(this); } public static abstract class TestViewMap extends AbstractSortedMapTest { protected final AbstractMapTest main; - protected final List subSortedKeys = new ArrayList(); - protected final List subSortedValues = new ArrayList(); - protected final List subSortedNewValues = new ArrayList(); + protected final List subSortedKeys = new ArrayList<>(); + protected final List subSortedValues = new ArrayList<>(); + protected final List subSortedNewValues = new ArrayList<>(); public TestViewMap(final String name, final AbstractMapTest main) { super(name); diff --git a/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java b/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java index 9b06057e8..2d06e61b6 100644 --- a/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java @@ -42,7 +42,7 @@ public class CaseInsensitiveMapTest extends AbstractIterableMapTest @Override public CaseInsensitiveMap makeObject() { - return new CaseInsensitiveMap(); + return new CaseInsensitiveMap<>(); } @Override @@ -80,13 +80,13 @@ public class CaseInsensitiveMapTest extends AbstractIterableMapTest } public void testPutAll() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); map.put("One", "One"); map.put("Two", "Two"); map.put("one", "Three"); map.put(null, "Four"); map.put(Integer.valueOf(20), "Five"); - final Map caseInsensitiveMap = new CaseInsensitiveMap(map); + final Map caseInsensitiveMap = new CaseInsensitiveMap<>(map); assertEquals(4, caseInsensitiveMap.size()); // ones collapsed final Set keys = caseInsensitiveMap.keySet(); assertTrue(keys.contains("one")); @@ -101,7 +101,7 @@ public class CaseInsensitiveMapTest extends AbstractIterableMapTest @SuppressWarnings("unchecked") public void testClone() { - final CaseInsensitiveMap map = new CaseInsensitiveMap(10); + final CaseInsensitiveMap map = new CaseInsensitiveMap<>(10); map.put((K) "1", (V) "1"); final CaseInsensitiveMap cloned = map.clone(); assertEquals(map.size(), cloned.size()); @@ -133,7 +133,7 @@ public class CaseInsensitiveMapTest extends AbstractIterableMapTest Locale.setDefault(locale); for (int j = 0; j < data.length; j++) { assertTrue("Test data corrupt: " + j, data[j][0].equalsIgnoreCase(data[j][1])); - final CaseInsensitiveMap map = new CaseInsensitiveMap(); + final CaseInsensitiveMap map = new CaseInsensitiveMap<>(); map.put(data[j][0], "value"); assertEquals(Locale.getDefault() + ": " + j, "value", map.get(data[j][1])); } @@ -147,7 +147,7 @@ public class CaseInsensitiveMapTest extends AbstractIterableMapTest * Test for COLLECTIONS-323. */ public void testInitialCapacityZero() { - final CaseInsensitiveMap map = new CaseInsensitiveMap(0); + final CaseInsensitiveMap map = new CaseInsensitiveMap<>(0); assertEquals(1, map.data.length); } } diff --git a/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java b/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java index ecaafdc16..f89416968 100644 --- a/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java @@ -43,7 +43,7 @@ public class CompositeMapTest extends AbstractIterableMapTest { @Override public CompositeMap makeObject() { - final CompositeMap map = new CompositeMap(); + final CompositeMap map = new CompositeMap<>(); map.addComposited(new HashMap()); map.setMutator( new EmptyMapMutator() ); return map; @@ -51,7 +51,7 @@ public class CompositeMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") private Map buildOne() { - final HashMap map = new HashMap(); + final HashMap map = new HashMap<>(); map.put((K) "1", (V) "one"); map.put((K) "2", (V) "two"); return map; @@ -59,22 +59,22 @@ public class CompositeMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public Map buildTwo() { - final HashMap map = new HashMap(); + final HashMap map = new HashMap<>(); map.put((K) "3", (V) "three"); map.put((K) "4", (V) "four"); return map; } public void testGet() { - final CompositeMap map = new CompositeMap(buildOne(), buildTwo()); + final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo()); assertEquals("one", map.get("1")); assertEquals("four", map.get("4")); } @SuppressWarnings("unchecked") public void testAddComposited() { - final CompositeMap map = new CompositeMap(buildOne(), buildTwo()); - final HashMap three = new HashMap(); + final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo()); + final HashMap three = new HashMap<>(); three.put((K) "5", (V) "five"); map.addComposited(three); assertTrue(map.containsKey("5")); @@ -88,8 +88,8 @@ public class CompositeMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public void testRemoveComposited() { - final CompositeMap map = new CompositeMap(buildOne(), buildTwo()); - final HashMap three = new HashMap(); + final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo()); + final HashMap three = new HashMap<>(); three.put((K) "5", (V) "five"); map.addComposited(three); assertTrue(map.containsKey("5")); @@ -104,8 +104,8 @@ public class CompositeMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public void testRemoveFromUnderlying() { - final CompositeMap map = new CompositeMap(buildOne(), buildTwo()); - final HashMap three = new HashMap(); + final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo()); + final HashMap three = new HashMap<>(); three.put((K) "5", (V) "five"); map.addComposited(three); assertTrue(map.containsKey("5")); @@ -117,8 +117,8 @@ public class CompositeMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public void testRemoveFromComposited() { - final CompositeMap map = new CompositeMap(buildOne(), buildTwo()); - final HashMap three = new HashMap(); + final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo()); + final HashMap three = new HashMap<>(); three.put((K) "5", (V) "five"); map.addComposited(three); assertTrue(map.containsKey("5")); @@ -129,7 +129,7 @@ public class CompositeMapTest extends AbstractIterableMapTest { } public void testResolveCollision() { - final CompositeMap map = new CompositeMap(buildOne(), buildTwo(), + final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo(), new CompositeMap.MapMutator() { private static final long serialVersionUID = 1L; @@ -159,7 +159,7 @@ public class CompositeMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public void testPut() { - final CompositeMap map = new CompositeMap(buildOne(), buildTwo(), + final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo(), new CompositeMap.MapMutator() { private static final long serialVersionUID = 1L; @Override @@ -188,7 +188,7 @@ public class CompositeMapTest extends AbstractIterableMapTest { } public void testPutAll() { - final CompositeMap map = new CompositeMap(buildOne(), buildTwo(), + final CompositeMap map = new CompositeMap<>(buildOne(), buildTwo(), new CompositeMap.MapMutator() { private static final long serialVersionUID = 1L; @Override diff --git a/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java b/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java index 32321d256..44806d74b 100644 --- a/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java @@ -50,7 +50,7 @@ public class DefaultedMapTest extends AbstractIterableMapTest { @Override @SuppressWarnings("unchecked") public void testMapGet() { - final Map map = new DefaultedMap((V) "NULL"); + final Map map = new DefaultedMap<>((V) "NULL"); assertEquals(0, map.size()); assertEquals(false, map.containsKey("NotInMap")); @@ -66,7 +66,7 @@ public class DefaultedMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public void testMapGet2() { - final HashMap base = new HashMap(); + final HashMap base = new HashMap<>(); final Map map = DefaultedMap.defaultedMap(base, (V) "NULL"); assertEquals(0, map.size()); @@ -85,7 +85,7 @@ public class DefaultedMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public void testMapGet3() { - final HashMap base = new HashMap(); + final HashMap base = new HashMap<>(); final Map map = DefaultedMap.defaultedMap(base, ConstantFactory.constantFactory((V) "NULL")); assertEquals(0, map.size()); @@ -104,7 +104,7 @@ public class DefaultedMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public void testMapGet4() { - final HashMap base = new HashMap(); + final HashMap base = new HashMap<>(); final Map map = DefaultedMap.defaultedMap(base, new Transformer() { @Override public V transform(final K input) { diff --git a/src/test/java/org/apache/commons/collections4/map/FixedSizeMapTest.java b/src/test/java/org/apache/commons/collections4/map/FixedSizeMapTest.java index cb72ff2ab..937d36be8 100644 --- a/src/test/java/org/apache/commons/collections4/map/FixedSizeMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/FixedSizeMapTest.java @@ -41,7 +41,7 @@ public class FixedSizeMapTest extends AbstractIterableMapTest { @Override public IterableMap makeFullMap() { - final Map map = new HashMap(); + final Map map = new HashMap<>(); addSampleMappings(map); return FixedSizeMap.fixedSizeMap(map); } diff --git a/src/test/java/org/apache/commons/collections4/map/FixedSizeSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/FixedSizeSortedMapTest.java index 18a668623..0efa502da 100644 --- a/src/test/java/org/apache/commons/collections4/map/FixedSizeSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/FixedSizeSortedMapTest.java @@ -48,7 +48,7 @@ public class FixedSizeSortedMapTest extends AbstractSortedMapTest { @Override public SortedMap makeFullMap() { - final SortedMap map = new TreeMap(); + final SortedMap map = new TreeMap<>(); addSampleMappings(map); return FixedSizeSortedMap.fixedSizeSortedMap(map); } diff --git a/src/test/java/org/apache/commons/collections4/map/Flat3MapTest.java b/src/test/java/org/apache/commons/collections4/map/Flat3MapTest.java index 20363041b..a195994ac 100644 --- a/src/test/java/org/apache/commons/collections4/map/Flat3MapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/Flat3MapTest.java @@ -54,7 +54,7 @@ public class Flat3MapTest extends AbstractIterableMapTest { @Override public Flat3Map makeObject() { - return new Flat3Map(); + return new Flat3Map<>(); } //----------------------------------------------------------------------- @@ -410,7 +410,7 @@ public class Flat3MapTest extends AbstractIterableMapTest { // } public void testCollections261() { - final Flat3Map m = new Flat3Map(); + final Flat3Map m = new Flat3Map<>(); m.put( Integer.valueOf(1), Integer.valueOf(1) ); m.put( Integer.valueOf(0), Integer.valueOf(0) ); assertEquals( Integer.valueOf(1), m.remove( Integer.valueOf(1) ) ); @@ -425,7 +425,7 @@ public class Flat3MapTest extends AbstractIterableMapTest { } public void testToString() { - final Flat3Map m = new Flat3Map(); + final Flat3Map m = new Flat3Map<>(); final String string0 = m.toString(); assertNotNull(string0); m.put( Integer.valueOf(1), Integer.valueOf(1) ); diff --git a/src/test/java/org/apache/commons/collections4/map/HashedMapTest.java b/src/test/java/org/apache/commons/collections4/map/HashedMapTest.java index 884af5e7d..6dddcdd62 100644 --- a/src/test/java/org/apache/commons/collections4/map/HashedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/HashedMapTest.java @@ -37,7 +37,7 @@ public class HashedMapTest extends AbstractIterableMapTest { @Override public HashedMap makeObject() { - return new HashedMap(); + return new HashedMap<>(); } @Override @@ -47,7 +47,7 @@ public class HashedMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public void testClone() { - final HashedMap map = new HashedMap(10); + final HashedMap map = new HashedMap<>(10); map.put((K) "1", (V) "1"); final HashedMap cloned = map.clone(); assertEquals(map.size(), cloned.size()); @@ -55,7 +55,7 @@ public class HashedMapTest extends AbstractIterableMapTest { } public void testInternalState() { - final HashedMap map = new HashedMap(42, 0.75f); + final HashedMap map = new HashedMap<>(42, 0.75f); assertEquals(0.75f, map.loadFactor, 0.1f); assertEquals(0, map.size); assertEquals(64, map.data.length); @@ -74,7 +74,7 @@ public class HashedMapTest extends AbstractIterableMapTest { * Test for COLLECTIONS-323. */ public void testInitialCapacityZero() { - final HashedMap map = new HashedMap(0); + final HashedMap map = new HashedMap<>(0); assertEquals(1, map.data.length); } } diff --git a/src/test/java/org/apache/commons/collections4/map/IdentityMap.java b/src/test/java/org/apache/commons/collections4/map/IdentityMap.java index a1a7a031c..54050e5dd 100644 --- a/src/test/java/org/apache/commons/collections4/map/IdentityMap.java +++ b/src/test/java/org/apache/commons/collections4/map/IdentityMap.java @@ -141,7 +141,7 @@ public class IdentityMap @Override protected IdentityEntry createEntry(final HashEntry next, final int hashCode, final K key, final V value) { - return new IdentityEntry(next, hashCode, key, value); + return new IdentityEntry<>(next, hashCode, key, value); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java b/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java index 798e3854d..69efa932b 100644 --- a/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java @@ -46,7 +46,7 @@ public class LRUMapTest extends AbstractOrderedMapTest { @Override public LRUMap makeObject() { - return new LRUMap(); + return new LRUMap<>(); } /** @@ -124,7 +124,7 @@ public class LRUMapTest extends AbstractOrderedMapTest { Iterator kit; Iterator vit; - final LRUMap map = new LRUMap(2); + final LRUMap map = new LRUMap<>(2); assertEquals(0, map.size()); assertEquals(false, map.isFull()); assertEquals(2, map.maxSize()); @@ -188,7 +188,7 @@ public class LRUMapTest extends AbstractOrderedMapTest { resetFull(); ordered = getMap(); - final List list = new ArrayList(ordered.keySet()); + final List list = new ArrayList<>(ordered.keySet()); final ResettableIterator it = (ResettableIterator) ordered.mapIterator(); assertSame(list.get(0), it.next()); assertSame(list.get(1), it.next()); @@ -322,7 +322,7 @@ public class LRUMapTest extends AbstractOrderedMapTest { @SuppressWarnings("unchecked") public void testClone() { - final LRUMap map = new LRUMap(10); + final LRUMap map = new LRUMap<>(10); map.put((K) "1", (V) "1"); final Map cloned = map.clone(); assertEquals(map.size(), cloned.size()); @@ -331,7 +331,7 @@ public class LRUMapTest extends AbstractOrderedMapTest { @SuppressWarnings("unchecked") public void testRemoveLRU() { - final MockLRUMapSubclass map = new MockLRUMapSubclass(2); + final MockLRUMapSubclass map = new MockLRUMapSubclass<>(2); assertNull(map.entry); map.put((K) "A", "a"); assertNull(map.entry); @@ -372,7 +372,7 @@ public class LRUMapTest extends AbstractOrderedMapTest { @SuppressWarnings("unchecked") public void testRemoveLRUBlocksRemove() { - final MockLRUMapSubclassBlocksRemove map = new MockLRUMapSubclassBlocksRemove(2, false); + final MockLRUMapSubclassBlocksRemove map = new MockLRUMapSubclassBlocksRemove<>(2, false); assertEquals(0, map.size()); map.put((K) "A", (V) "a"); assertEquals(1, map.size()); @@ -388,7 +388,7 @@ public class LRUMapTest extends AbstractOrderedMapTest { @SuppressWarnings("unchecked") public void testRemoveLRUBlocksRemoveScan() { - final MockLRUMapSubclassBlocksRemove map = new MockLRUMapSubclassBlocksRemove(2, true); + final MockLRUMapSubclassBlocksRemove map = new MockLRUMapSubclassBlocksRemove<>(2, true); assertEquals(0, map.size()); map.put((K) "A", (V) "a"); assertEquals(1, map.size()); @@ -420,7 +420,7 @@ public class LRUMapTest extends AbstractOrderedMapTest { @SuppressWarnings("unchecked") public void testRemoveLRUFirstBlocksRemove() { - final MockLRUMapSubclassFirstBlocksRemove map = new MockLRUMapSubclassFirstBlocksRemove(2); + final MockLRUMapSubclassFirstBlocksRemove map = new MockLRUMapSubclassFirstBlocksRemove<>(2); assertEquals(0, map.size()); map.put((K) "A", (V) "a"); assertEquals(1, map.size()); @@ -484,7 +484,7 @@ public class LRUMapTest extends AbstractOrderedMapTest { final SingleHashCode five = new SingleHashCode("5"); final SingleHashCode six = new SingleHashCode("6"); - final LRUMap map = new LRUMap(3, 1.0f); + final LRUMap map = new LRUMap<>(3, 1.0f); final int hashIndex = map.hashIndex(map.hash(one), 4); map.put((K) one, (V) "A"); map.put((K) two, (V) "B"); @@ -571,7 +571,7 @@ public class LRUMapTest extends AbstractOrderedMapTest { final SingleHashCode two = new SingleHashCode("2"); final SingleHashCode three = new SingleHashCode("3"); - final LRUMap map = new LRUMap(3, 1.0f); + final LRUMap map = new LRUMap<>(3, 1.0f); map.put((K) one, (V) "A"); map.put((K) two, (V) "B"); map.put((K) three, (V) "C"); @@ -591,9 +591,9 @@ public class LRUMapTest extends AbstractOrderedMapTest { public void testSynchronizedRemoveFromMapIterator() throws InterruptedException { - final LRUMap map = new LRUMap(10000); + final LRUMap map = new LRUMap<>(10000); - final Map exceptions = new HashMap(); + final Map exceptions = new HashMap<>(); final ThreadGroup tg = new ThreadGroup(getName()) { @Override public void uncaughtException(final Thread t, final Throwable e) { @@ -674,9 +674,9 @@ public class LRUMapTest extends AbstractOrderedMapTest { public void testSynchronizedRemoveFromEntrySet() throws InterruptedException { - final Map map = new LRUMap(10000); + final Map map = new LRUMap<>(10000); - final Map exceptions = new HashMap(); + final Map exceptions = new HashMap<>(); final ThreadGroup tg = new ThreadGroup(getName()) { @Override public void uncaughtException(final Thread t, final Throwable e) { @@ -757,9 +757,9 @@ public class LRUMapTest extends AbstractOrderedMapTest { public void testSynchronizedRemoveFromKeySet() throws InterruptedException { - final Map map = new LRUMap(10000); + final Map map = new LRUMap<>(10000); - final Map exceptions = new HashMap(); + final Map exceptions = new HashMap<>(); final ThreadGroup tg = new ThreadGroup(getName()) { @Override public void uncaughtException(final Thread t, final Throwable e) { @@ -840,9 +840,9 @@ public class LRUMapTest extends AbstractOrderedMapTest { public void testSynchronizedRemoveFromValues() throws InterruptedException { - final Map map = new LRUMap(10000); + final Map map = new LRUMap<>(10000); - final Map exceptions = new HashMap(); + final Map exceptions = new HashMap<>(); final ThreadGroup tg = new ThreadGroup(getName()) { @Override public void uncaughtException(final Thread t, final Throwable e) { diff --git a/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java b/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java index ea04eefc5..34879d485 100644 --- a/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java @@ -46,7 +46,7 @@ public class LinkedMapTest extends AbstractOrderedMapTest { @Override public LinkedMap makeObject() { - return new LinkedMap(); + return new LinkedMap<>(); } /** @@ -71,7 +71,7 @@ public class LinkedMapTest extends AbstractOrderedMapTest { resetFull(); ordered = getMap(); - final List list = new ArrayList(ordered.keySet()); + final List list = new ArrayList<>(ordered.keySet()); final ResettableIterator it = (ResettableIterator) ordered.mapIterator(); assertSame(list.get(0), it.next()); assertSame(list.get(1), it.next()); @@ -186,7 +186,7 @@ public class LinkedMapTest extends AbstractOrderedMapTest { resetFull(); lm = getMap(); - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final MapIterator it = lm.mapIterator(); it.hasNext();) { list.add(it.next()); } @@ -214,7 +214,7 @@ public class LinkedMapTest extends AbstractOrderedMapTest { lm.remove(lm.size()); } catch (final IndexOutOfBoundsException ex) {} - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final MapIterator it = lm.mapIterator(); it.hasNext();) { list.add(it.next()); } @@ -275,7 +275,7 @@ public class LinkedMapTest extends AbstractOrderedMapTest { @SuppressWarnings("unchecked") public void testClone() { - final LinkedMap map = new LinkedMap(10); + final LinkedMap map = new LinkedMap<>(10); map.put((K) "1", (V) "1"); final Map cloned = map.clone(); assertEquals(map.size(), cloned.size()); @@ -301,7 +301,7 @@ public class LinkedMapTest extends AbstractOrderedMapTest { * Test for COLLECTIONS-323. */ public void testInitialCapacityZero() { - final LinkedMap map = new LinkedMap(0); + final LinkedMap map = new LinkedMap<>(0); assertEquals(1, map.data.length); } } diff --git a/src/test/java/org/apache/commons/collections4/map/ListOrderedMap2Test.java b/src/test/java/org/apache/commons/collections4/map/ListOrderedMap2Test.java index 87c7b79e6..26c191899 100644 --- a/src/test/java/org/apache/commons/collections4/map/ListOrderedMap2Test.java +++ b/src/test/java/org/apache/commons/collections4/map/ListOrderedMap2Test.java @@ -44,7 +44,7 @@ public class ListOrderedMap2Test extends AbstractOrderedMapTest { @Override public ListOrderedMap makeObject() { - return new ListOrderedMap(); + return new ListOrderedMap<>(); } /** @@ -114,7 +114,7 @@ public class ListOrderedMap2Test extends AbstractOrderedMapTest { resetFull(); lom = getMap(); - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final MapIterator it = lom.mapIterator(); it.hasNext();) { list.add(it.next()); } @@ -142,7 +142,7 @@ public class ListOrderedMap2Test extends AbstractOrderedMapTest { lom.remove(lom.size()); } catch (final IndexOutOfBoundsException ex) {} - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final MapIterator it = lom.mapIterator(); it.hasNext();) { list.add(it.next()); } diff --git a/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java b/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java index 6a0f75c8f..e24ff542a 100644 --- a/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java @@ -117,7 +117,7 @@ public class ListOrderedMapTest extends AbstractOrderedMapTest { resetFull(); lom = getMap(); - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final MapIterator it = lom.mapIterator(); it.hasNext();) { list.add(it.next()); } @@ -173,7 +173,7 @@ public class ListOrderedMapTest extends AbstractOrderedMapTest { lom.remove(lom.size()); } catch (final IndexOutOfBoundsException ex) {} - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (final MapIterator it = lom.mapIterator(); it.hasNext();) { list.add(it.next()); } @@ -222,7 +222,7 @@ public class ListOrderedMapTest extends AbstractOrderedMapTest { // put in a full map resetFull(); lom = getMap(); - final ListOrderedMap lom2 = new ListOrderedMap(); + final ListOrderedMap lom2 = new ListOrderedMap<>(); lom2.putAll(lom); lom2.put(0, (K) "testInsert0", (V) "testInsert0v"); @@ -317,7 +317,7 @@ public class ListOrderedMapTest extends AbstractOrderedMapTest { assertEquals("testInsert2v", lom.getValue(2)); // Create New Test Map and Add using putAll(int, Object, Object) - final Map values = new ListOrderedMap(); + final Map values = new ListOrderedMap<>(); values.put("NewInsert0", "NewInsert0v"); values.put("NewInsert1", "NewInsert1v"); lom.putAll(1, values); @@ -341,7 +341,7 @@ public class ListOrderedMapTest extends AbstractOrderedMapTest { lom.put((K) Integer.valueOf(i), (V) Boolean.TRUE); } - final Map map = new TreeMap(); + final Map map = new TreeMap<>(); for (int i = 0; i < size; i++) { map.put((K) Integer.valueOf(i), (V) Boolean.FALSE); } @@ -389,11 +389,11 @@ public class ListOrderedMapTest extends AbstractOrderedMapTest { public void testCOLLECTIONS_474_nullValues () { Object key1 = new Object(); Object key2 = new Object(); - HashMap hmap = new HashMap(); + HashMap hmap = new HashMap<>(); hmap.put(key1, null); hmap.put(key2, null); assertEquals("Should have two elements", 2, hmap.size()); - ListOrderedMap listMap = new ListOrderedMap(); + ListOrderedMap listMap = new ListOrderedMap<>(); listMap.put(key1, null); listMap.put(key2, null); assertEquals("Should have two elements", 2, listMap.size()); @@ -403,11 +403,11 @@ public class ListOrderedMapTest extends AbstractOrderedMapTest { public void testCOLLECTIONS_474_nonNullValues () { Object key1 = new Object(); Object key2 = new Object(); - HashMap hmap = new HashMap(); + HashMap hmap = new HashMap<>(); hmap.put(key1, "1"); hmap.put(key2, "2"); assertEquals("Should have two elements", 2, hmap.size()); - ListOrderedMap listMap = new ListOrderedMap(); + ListOrderedMap listMap = new ListOrderedMap<>(); listMap.put(key1, "3"); listMap.put(key2, "4"); assertEquals("Should have two elements", 2, listMap.size()); diff --git a/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java b/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java index f9c3c6e9d..ba16eb7ec 100644 --- a/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java @@ -50,7 +50,7 @@ public class MultiKeyMapTest extends AbstractIterableMapTest makeObject() { - return new MultiKeyMap(); + return new MultiKeyMap<>(); } @Override @@ -61,18 +61,18 @@ public class MultiKeyMapTest extends AbstractIterableMapTest[] getMultiKeyKeys() { return new MultiKey[] { - new MultiKey(I1, I2), - new MultiKey(I2, I3), - new MultiKey(I3, I4), - new MultiKey(I1, I1, I2), - new MultiKey(I2, I3, I4), - new MultiKey(I3, I7, I6), - new MultiKey(I1, I1, I2, I3), - new MultiKey(I2, I4, I5, I6), - new MultiKey(I3, I6, I7, I8), - new MultiKey(I1, I1, I2, I3, I4), - new MultiKey(I2, I3, I4, I5, I6), - new MultiKey(I3, I5, I6, I7, I8), + new MultiKey<>(I1, I2), + new MultiKey<>(I2, I3), + new MultiKey<>(I3, I4), + new MultiKey<>(I1, I1, I2), + new MultiKey<>(I2, I3, I4), + new MultiKey<>(I3, I7, I6), + new MultiKey<>(I1, I1, I2, I3), + new MultiKey<>(I2, I4, I5, I6), + new MultiKey<>(I3, I6, I7, I8), + new MultiKey<>(I1, I1, I2, I3, I4), + new MultiKey<>(I2, I3, I4, I5, I6), + new MultiKey<>(I3, I5, I6, I7, I8), }; } @@ -102,10 +102,10 @@ public class MultiKeyMapTest extends AbstractIterableMapTest[] getOtherKeys() { return new MultiKey[] { - new MultiKey(I1, I7), - new MultiKey(I1, I8), - new MultiKey(I2, I4), - new MultiKey(I2, I5), + new MultiKey<>(I1, I7), + new MultiKey<>(I1, I8), + new MultiKey<>(I2, I4), + new MultiKey<>(I2, I5), }; } @@ -244,7 +244,7 @@ public class MultiKeyMapTest extends AbstractIterableMapTest multimap = new MultiKeyMap(); + final MultiKeyMap multimap = new MultiKeyMap<>(); final MultiKey key = keys[i]; final V value = values[i]; @@ -255,7 +255,7 @@ public class MultiKeyMapTest extends AbstractIterableMapTest(key.getKey(0), key.getKey(1)))); + assertEquals(true, multimap.containsKey(new MultiKey<>(key.getKey(0), key.getKey(1)))); assertEquals(value, multimap.put(key.getKey(0), key.getKey(1), null)); assertEquals(1, multimap.size()); assertEquals(null, multimap.get(key.getKey(0), key.getKey(1))); @@ -266,7 +266,7 @@ public class MultiKeyMapTest extends AbstractIterableMapTest(key.getKey(0), key.getKey(1), key.getKey(2)))); + assertEquals(true, multimap.containsKey(new MultiKey<>(key.getKey(0), key.getKey(1), key.getKey(2)))); assertEquals(value, multimap.put(key.getKey(0), key.getKey(1), key.getKey(2), null)); assertEquals(1, multimap.size()); assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2))); @@ -277,7 +277,7 @@ public class MultiKeyMapTest extends AbstractIterableMapTest(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)))); + assertEquals(true, multimap.containsKey(new MultiKey<>(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3)))); assertEquals(value, multimap.put(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), null)); assertEquals(1, multimap.size()); assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3))); @@ -288,7 +288,7 @@ public class MultiKeyMapTest extends AbstractIterableMapTest(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)))); + assertEquals(true, multimap.containsKey(new MultiKey<>(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4)))); assertEquals(value, multimap.put(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4), null)); assertEquals(1, multimap.size()); assertEquals(null, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4))); @@ -301,7 +301,7 @@ public class MultiKeyMapTest extends AbstractIterableMapTest map = new MultiKeyMap(); + final MultiKeyMap map = new MultiKeyMap<>(); map.put("a", null, "value1"); map.put("b", null, "value2"); map.put("c", null, "value3"); @@ -422,11 +422,11 @@ public class MultiKeyMapTest extends AbstractIterableMapTest map = new MultiKeyMap(); - map.put(new MultiKey((K) I1, (K) I2), (V) "1-2"); + final MultiKeyMap map = new MultiKeyMap<>(); + map.put(new MultiKey<>((K) I1, (K) I2), (V) "1-2"); final Map, V> cloned = map.clone(); assertEquals(map.size(), cloned.size()); - assertSame(map.get(new MultiKey((K) I1, (K) I2)), cloned.get(new MultiKey((K) I1, (K) I2))); + assertSame(map.get(new MultiKey<>((K) I1, (K) I2)), cloned.get(new MultiKey<>((K) I1, (K) I2))); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java b/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java index 5b4150573..2fb3a3d7e 100644 --- a/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java @@ -61,7 +61,7 @@ public class MultiValueMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testMultipleValues() { final MultiValueMap map = createTestMap(HashSet.class); - final HashSet expected = new HashSet(); + final HashSet expected = new HashSet<>(); expected.add((V) "uno"); expected.add((V) "un"); assertEquals(expected, map.get("one")); @@ -94,7 +94,7 @@ public class MultiValueMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testValues() { final MultiValueMap map = createTestMap(HashSet.class); - final HashSet expected = new HashSet(); + final HashSet expected = new HashSet<>(); expected.add((V) "uno"); expected.add((V) "dos"); expected.add((V) "tres"); @@ -103,7 +103,7 @@ public class MultiValueMapTest extends AbstractObjectTest { expected.add((V) "trois"); final Collection c = map.values(); assertEquals(6, c.size()); - assertEquals(expected, new HashSet(c)); + assertEquals(expected, new HashSet<>(c)); } @SuppressWarnings("unchecked") @@ -153,7 +153,7 @@ public class MultiValueMapTest extends AbstractObjectTest { public void testIterator() { final MultiValueMap map = createTestMap(); @SuppressWarnings("unchecked") - Collection values = new ArrayList((Collection) map.values()); + Collection values = new ArrayList<>((Collection) map.values()); Iterator> iterator = map.iterator(); while (iterator.hasNext()) { Map.Entry entry = iterator.next(); @@ -181,26 +181,26 @@ public class MultiValueMapTest extends AbstractObjectTest { //----------------------------------------------------------------------- @SuppressWarnings("unchecked") public void testMapEquals() { - final MultiValueMap one = new MultiValueMap(); + final MultiValueMap one = new MultiValueMap<>(); final Integer value = Integer.valueOf(1); one.put((K) "One", value); one.removeMapping("One", value); - final MultiValueMap two = new MultiValueMap(); + final MultiValueMap two = new MultiValueMap<>(); assertEquals(two, one); } //----------------------------------------------------------------------- @SuppressWarnings("unchecked") public void testGetCollection() { - final MultiValueMap map = new MultiValueMap(); + final MultiValueMap map = new MultiValueMap<>(); map.put((K) "A", "AA"); assertSame(map.get("A"), map.getCollection("A")); } @SuppressWarnings("unchecked") public void testTotalSize() { - final MultiValueMap map = new MultiValueMap(); + final MultiValueMap map = new MultiValueMap<>(); assertEquals(0, map.totalSize()); map.put((K) "A", "AA"); assertEquals(1, map.totalSize()); @@ -218,7 +218,7 @@ public class MultiValueMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testSize() { - final MultiValueMap map = new MultiValueMap(); + final MultiValueMap map = new MultiValueMap<>(); assertEquals(0, map.size()); map.put((K) "A", "AA"); assertEquals(1, map.size()); @@ -236,7 +236,7 @@ public class MultiValueMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testSize_Key() { - final MultiValueMap map = new MultiValueMap(); + final MultiValueMap map = new MultiValueMap<>(); assertEquals(0, map.size("A")); assertEquals(0, map.size("B")); map.put((K) "A", "AA"); @@ -261,7 +261,7 @@ public class MultiValueMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testIterator_Key() { - final MultiValueMap map = new MultiValueMap(); + final MultiValueMap map = new MultiValueMap<>(); assertEquals(false, map.iterator("A").hasNext()); map.put((K) "A", "AA"); final Iterator it = map.iterator("A"); @@ -272,7 +272,7 @@ public class MultiValueMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testContainsValue_Key() { - final MultiValueMap map = new MultiValueMap(); + final MultiValueMap map = new MultiValueMap<>(); assertEquals(false, map.containsValue("A", "AA")); assertEquals(false, map.containsValue("B", "BB")); map.put((K) "A", "AA"); @@ -305,11 +305,11 @@ public class MultiValueMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testPutAll_Map1() { - final MultiMap original = new MultiValueMap(); + final MultiMap original = new MultiValueMap<>(); original.put((K) "key", "object1"); original.put((K) "key", "object2"); - final MultiValueMap test = new MultiValueMap(); + final MultiValueMap test = new MultiValueMap<>(); test.put((K) "keyA", "objectA"); test.put((K) "key", "object0"); test.putAll(original); @@ -326,11 +326,11 @@ public class MultiValueMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testPutAll_Map2() { - final Map original = new HashMap(); + final Map original = new HashMap<>(); original.put((K) "keyX", (V) "object1"); original.put((K) "keyY", (V) "object2"); - final MultiValueMap test = new MultiValueMap(); + final MultiValueMap test = new MultiValueMap<>(); test.put((K) "keyA", "objectA"); test.put((K) "keyX", "object0"); test.putAll(original); @@ -348,7 +348,7 @@ public class MultiValueMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testPutAll_KeyCollection() { - final MultiValueMap map = new MultiValueMap(); + final MultiValueMap map = new MultiValueMap<>(); Collection coll = (Collection) Arrays.asList("X", "Y", "Z"); assertEquals(true, map.putAll((K) "A", coll)); @@ -380,7 +380,7 @@ public class MultiValueMapTest extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testRemove_KeyItem() { - final MultiValueMap map = new MultiValueMap(); + final MultiValueMap map = new MultiValueMap<>(); map.put((K) "A", "AA"); map.put((K) "A", "AB"); map.put((K) "A", "AC"); diff --git a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java index c78b7447f..a96c5679e 100644 --- a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java @@ -75,24 +75,24 @@ public class PassiveExpiringMapTest extends AbstractMapTest { } private Map makeDecoratedTestMap() { - final Map m = new HashMap(); + final Map m = new HashMap<>(); m.put(Integer.valueOf(1), "one"); m.put(Integer.valueOf(2), "two"); m.put(Integer.valueOf(3), "three"); m.put(Integer.valueOf(4), "four"); m.put(Integer.valueOf(5), "five"); m.put(Integer.valueOf(6), "six"); - return new PassiveExpiringMap(new TestExpirationPolicy(), m); + return new PassiveExpiringMap<>(new TestExpirationPolicy(), m); } @Override public Map makeObject() { - return new PassiveExpiringMap(); + return new PassiveExpiringMap<>(); } private Map makeTestMap() { final Map m = - new PassiveExpiringMap(new TestExpirationPolicy()); + new PassiveExpiringMap<>(new TestExpirationPolicy()); m.put(Integer.valueOf(1), "one"); m.put(Integer.valueOf(2), "two"); m.put(Integer.valueOf(3), "three"); @@ -105,7 +105,7 @@ public class PassiveExpiringMapTest extends AbstractMapTest { public void testConstructors() { try { final Map map = null; - new PassiveExpiringMap(map); + new PassiveExpiringMap<>(map); fail("constructor - exception should have been thrown."); } catch (final NullPointerException ex) { // success @@ -113,7 +113,7 @@ public class PassiveExpiringMapTest extends AbstractMapTest { try { final ExpirationPolicy policy = null; - new PassiveExpiringMap(policy); + new PassiveExpiringMap<>(policy); fail("constructor - exception should have been thrown."); } catch (final NullPointerException ex) { // success @@ -221,7 +221,7 @@ public class PassiveExpiringMapTest extends AbstractMapTest { public void testZeroTimeToLive() { // item should not be available - final PassiveExpiringMap m = new PassiveExpiringMap(0L); + final PassiveExpiringMap m = new PassiveExpiringMap<>(0L); m.put("a", "b"); assertNull(m.get("a")); } @@ -229,9 +229,9 @@ public class PassiveExpiringMapTest extends AbstractMapTest { public void testExpiration() { validateExpiration(new PassiveExpiringMap(500), 500); validateExpiration(new PassiveExpiringMap(1000), 1000); - validateExpiration(new PassiveExpiringMap( + validateExpiration(new PassiveExpiringMap<>( new PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy(500)), 500); - validateExpiration(new PassiveExpiringMap( + validateExpiration(new PassiveExpiringMap<>( new PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy(1, TimeUnit.SECONDS)), 1000); } diff --git a/src/test/java/org/apache/commons/collections4/map/PredicatedMapTest.java b/src/test/java/org/apache/commons/collections4/map/PredicatedMapTest.java index 23b556779..d5e3ba4e1 100644 --- a/src/test/java/org/apache/commons/collections4/map/PredicatedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/PredicatedMapTest.java @@ -94,7 +94,7 @@ public class PredicatedMapTest extends AbstractIterableMapTest { assertTrue(!map.containsKey(Integer.valueOf(3))); assertTrue(!map.containsValue(Integer.valueOf(3))); - final Map map2 = new HashMap(); + final Map map2 = new HashMap<>(); map2.put((K) "A", (V) "a"); map2.put((K) "B", (V) "b"); map2.put((K) "C", (V) "c"); diff --git a/src/test/java/org/apache/commons/collections4/map/PredicatedSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/PredicatedSortedMapTest.java index df77bec3b..307b318ac 100644 --- a/src/test/java/org/apache/commons/collections4/map/PredicatedSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/PredicatedSortedMapTest.java @@ -108,7 +108,7 @@ public class PredicatedSortedMapTest extends AbstractSortedMapTest { assertTrue(!map.containsKey(Integer.valueOf(3))); assertTrue(!map.containsValue(Integer.valueOf(3))); - final Map map2 = new HashMap(); + final Map map2 = new HashMap<>(); map2.put((K) "A", (V) "a"); map2.put((K) "B", (V) "b"); map2.put((K) "C", (V) "c"); diff --git a/src/test/java/org/apache/commons/collections4/map/ReferenceIdentityMapTest.java b/src/test/java/org/apache/commons/collections4/map/ReferenceIdentityMapTest.java index 571a50f06..c56dbff1b 100644 --- a/src/test/java/org/apache/commons/collections4/map/ReferenceIdentityMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/ReferenceIdentityMapTest.java @@ -48,7 +48,7 @@ public class ReferenceIdentityMapTest extends AbstractIterableMapTest makeObject() { - return new ReferenceIdentityMap(ReferenceStrength.WEAK, ReferenceStrength.WEAK); + return new ReferenceIdentityMap<>(ReferenceStrength.WEAK, ReferenceStrength.WEAK); } @Override @@ -56,7 +56,7 @@ public class ReferenceIdentityMapTest extends AbstractIterableMapTest(); + return new IdentityMap<>(); } @Override @@ -88,7 +88,7 @@ public class ReferenceIdentityMapTest extends AbstractIterableMapTest map = new ReferenceIdentityMap(ReferenceStrength.HARD, ReferenceStrength.HARD); + final IterableMap map = new ReferenceIdentityMap<>(ReferenceStrength.HARD, ReferenceStrength.HARD); assertEquals(0, map.size()); map.put((K) I1A, (V) I2A); @@ -122,7 +122,7 @@ public class ReferenceIdentityMapTest extends AbstractIterableMapTest map = new ReferenceIdentityMap(ReferenceStrength.HARD, ReferenceStrength.HARD); + final IterableMap map = new ReferenceIdentityMap<>(ReferenceStrength.HARD, ReferenceStrength.HARD); map.put((K) I1A, (V) I2A); map.put((K) I1B, (V) I2A); @@ -281,10 +281,10 @@ public class ReferenceIdentityMapTest extends AbstractIterableMapTest(key); - valueReference = new WeakReference(value); + keyReference = new WeakReference<>(key); + valueReference = new WeakReference<>(value); - final Map testMap = new ReferenceIdentityMap(ReferenceStrength.WEAK, ReferenceStrength.HARD, true); + final Map testMap = new ReferenceIdentityMap<>(ReferenceStrength.WEAK, ReferenceStrength.HARD, true); testMap.put(key, value); assertEquals("In map", value, testMap.get(key)); diff --git a/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java b/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java index 55895171f..dec541854 100644 --- a/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/ReferenceMapTest.java @@ -41,7 +41,7 @@ public class ReferenceMapTest extends AbstractIterableMapTest { @Override public ReferenceMap makeObject() { - return new ReferenceMap(ReferenceStrength.WEAK, ReferenceStrength.WEAK); + return new ReferenceMap<>(ReferenceStrength.WEAK, ReferenceStrength.WEAK); } @Override @@ -214,10 +214,10 @@ public class ReferenceMapTest extends AbstractIterableMapTest { final K key = (K) new Object(); final V value = (V) new Object(); - keyReference = new WeakReference(key); - valueReference = new WeakReference(value); + keyReference = new WeakReference<>(key); + valueReference = new WeakReference<>(value); - final Map testMap = new ReferenceMap(ReferenceStrength.WEAK, ReferenceStrength.HARD, true); + final Map testMap = new ReferenceMap<>(ReferenceStrength.WEAK, ReferenceStrength.HARD, true); testMap.put(key, value); assertEquals("In map", value, testMap.get(key)); diff --git a/src/test/java/org/apache/commons/collections4/map/SingletonMapTest.java b/src/test/java/org/apache/commons/collections4/map/SingletonMapTest.java index 2910eae6a..e28d89b01 100644 --- a/src/test/java/org/apache/commons/collections4/map/SingletonMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/SingletonMapTest.java @@ -64,7 +64,7 @@ public class SingletonMapTest extends AbstractOrderedMapTest { @Override @SuppressWarnings("unchecked") public SingletonMap makeFullMap() { - return new SingletonMap((K) ONE, (V) TWO); + return new SingletonMap<>((K) ONE, (V) TWO); } @Override diff --git a/src/test/java/org/apache/commons/collections4/map/StaticBucketMapTest.java b/src/test/java/org/apache/commons/collections4/map/StaticBucketMapTest.java index 663f8c691..47bfef811 100644 --- a/src/test/java/org/apache/commons/collections4/map/StaticBucketMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/StaticBucketMapTest.java @@ -38,7 +38,7 @@ public class StaticBucketMapTest extends AbstractIterableMapTest { @Override public StaticBucketMap makeObject() { - return new StaticBucketMap(30); + return new StaticBucketMap<>(30); } /** @@ -63,7 +63,7 @@ public class StaticBucketMapTest extends AbstractIterableMapTest { // Bugzilla 37567 @SuppressWarnings("unchecked") public void test_get_nullMatchesIncorrectly() { - final StaticBucketMap map = new StaticBucketMap(17); + final StaticBucketMap map = new StaticBucketMap<>(17); map.put(null, (V) "A"); assertEquals("A", map.get(null)); // loop so we find a string that is in the same bucket as the null @@ -75,7 +75,7 @@ public class StaticBucketMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public void test_containsKey_nullMatchesIncorrectly() { - final StaticBucketMap map = new StaticBucketMap(17); + final StaticBucketMap map = new StaticBucketMap<>(17); map.put(null, (V) "A"); assertEquals(true, map.containsKey(null)); // loop so we find a string that is in the same bucket as the null @@ -87,7 +87,7 @@ public class StaticBucketMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public void test_containsValue_nullMatchesIncorrectly() { - final StaticBucketMap map = new StaticBucketMap(17); + final StaticBucketMap map = new StaticBucketMap<>(17); map.put((K) "A", null); assertEquals(true, map.containsValue(null)); // loop so we find a string that is in the same bucket as the null diff --git a/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java b/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java index e3c187192..7837a77dc 100644 --- a/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/TransformedMapTest.java @@ -98,7 +98,7 @@ public class TransformedMapTest extends AbstractIterableMapTest { //----------------------------------------------------------------------- @SuppressWarnings("unchecked") public void testFactory_Decorate() { - final Map base = new HashMap(); + final Map base = new HashMap<>(); base.put((K) "A", (V) "1"); base.put((K) "B", (V) "2"); base.put((K) "C", (V) "3"); @@ -118,7 +118,7 @@ public class TransformedMapTest extends AbstractIterableMapTest { @SuppressWarnings("unchecked") public void testFactory_decorateTransform() { - final Map base = new HashMap(); + final Map base = new HashMap<>(); base.put((K) "A", (V) "1"); base.put((K) "B", (V) "2"); base.put((K) "C", (V) "3"); diff --git a/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java index ab02f7a44..cfafb2572 100644 --- a/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/TransformedSortedMapTest.java @@ -144,7 +144,7 @@ public class TransformedSortedMapTest extends AbstractSortedMapTest //----------------------------------------------------------------------- @SuppressWarnings("unchecked") public void testFactory_Decorate() { - final SortedMap base = new TreeMap(); + final SortedMap base = new TreeMap<>(); base.put((K) "A", (V) "1"); base.put((K) "B", (V) "2"); base.put((K) "C", (V) "3"); @@ -164,7 +164,7 @@ public class TransformedSortedMapTest extends AbstractSortedMapTest @SuppressWarnings("unchecked") public void testFactory_decorateTransform() { - final SortedMap base = new TreeMap(); + final SortedMap base = new TreeMap<>(); base.put((K) "A", (V) "1"); base.put((K) "B", (V) "2"); base.put((K) "C", (V) "3"); diff --git a/src/test/java/org/apache/commons/collections4/map/UnmodifiableMapTest.java b/src/test/java/org/apache/commons/collections4/map/UnmodifiableMapTest.java index cabf3f071..d23ae1e7d 100644 --- a/src/test/java/org/apache/commons/collections4/map/UnmodifiableMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/UnmodifiableMapTest.java @@ -59,7 +59,7 @@ public class UnmodifiableMapTest extends AbstractIterableMapTest { @Override public IterableMap makeFullMap() { - final Map m = new HashMap(); + final Map m = new HashMap<>(); addSampleMappings(m); return (IterableMap) UnmodifiableMap.unmodifiableMap(m); } diff --git a/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java b/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java index b50b9038c..b3ce216d3 100644 --- a/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/UnmodifiableSortedMapTest.java @@ -58,7 +58,7 @@ public class UnmodifiableSortedMapTest extends AbstractSortedMapTest @Override public SortedMap makeFullMap() { - final SortedMap m = new TreeMap(); + final SortedMap m = new TreeMap<>(); addSampleMappings(m); return UnmodifiableSortedMap.unmodifiableSortedMap(m); } diff --git a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java index 79c15b76d..9e350d028 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java @@ -162,7 +162,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes * @return a MultiValuedMap that is known to be valid */ public MultiValuedMap makeConfirmedMap() { - return new ArrayListValuedHashMap(); + return new ArrayListValuedHashMap<>(); } public MultiValuedMap getConfirmed() { @@ -317,7 +317,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes @SuppressWarnings("unchecked") public void testValues() { final MultiValuedMap map = makeFullMap(); - final HashSet expected = new HashSet(); + final HashSet expected = new HashSet<>(); expected.add((V) "uno"); expected.add((V) "dos"); expected.add((V) "tres"); @@ -326,7 +326,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes expected.add((V) "trois"); final Collection c = map.values(); assertEquals(6, c.size()); - assertEquals(expected, new HashSet(c)); + assertEquals(expected, new HashSet<>(c)); } // public void testKeyedIterator() { @@ -389,7 +389,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes public void testEntriesCollectionIterator() { final MultiValuedMap map = makeFullMap(); - Collection values = new ArrayList(map.values()); + Collection values = new ArrayList<>(map.values()); Iterator> iterator = map.entries().iterator(); while (iterator.hasNext()) { Map.Entry entry = iterator.next(); @@ -560,7 +560,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes if (!isAddSupported()) { return; } - final Map original = new HashMap(); + final Map original = new HashMap<>(); original.put((K) "keyX", (V) "object1"); original.put((K) "keyY", (V) "object2"); @@ -649,12 +649,12 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes public void testKeysBagIterator() { MultiValuedMap map = makeFullMap(); - Collection col = new ArrayList(); + Collection col = new ArrayList<>(); Iterator it = map.keys().iterator(); while (it.hasNext()) { col.add(it.next()); } - Bag bag = new HashBag(col); + Bag bag = new HashBag<>(col); assertEquals(2, bag.getCount("one")); assertEquals(2, bag.getCount("two")); assertEquals(2, bag.getCount("three")); @@ -1092,7 +1092,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes Collection[] colArr = new Collection[3]; for(int i = 0; i < 3; i++) { Collection coll = Arrays.asList(sampleValues[i*2], sampleValues[i*2 + 1]); - colArr[i] = isSetValuedMap ? new HashSet(coll) : coll; + colArr[i] = isSetValuedMap ? new HashSet<>(coll) : coll; } return colArr; } @@ -1105,7 +1105,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes Collection[] colArr = new Collection[3]; for (int i = 0; i < 3; i++) { Collection coll = Arrays.asList((V) sampleValues[i * 2], (V) sampleValues[i * 2 + 1]); - colArr[i] = isSetValuedMap ? new HashSet(coll) : coll; + colArr[i] = isSetValuedMap ? new HashSet<>(coll) : coll; } return colArr; } diff --git a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java index 3bec0756b..883b87ae1 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java @@ -44,7 +44,7 @@ public class ArrayListValuedHashMapTest extends AbstractMultiValuedMapTest // ----------------------------------------------------------------------- @Override public ListValuedMap makeObject() { - return new ArrayListValuedHashMap(); + return new ArrayListValuedHashMap<>(); } // ----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java index b8c29b6c3..fc31bad6c 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java @@ -44,12 +44,12 @@ public class HashSetValuedHashMapTest extends AbstractMultiValuedMapTest makeObject() { - return new HashSetValuedHashMap(); + return new HashSetValuedHashMap<>(); } @Override public MultiValuedMap makeConfirmedMap() { - return new HashSetValuedHashMap(); + return new HashSetValuedHashMap<>(); } // ----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java index 2d4e8e326..70e068f54 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java @@ -96,7 +96,7 @@ public class TransformedMultiValuedMapTest extends AbstractMultiValuedMapT // ----------------------------------------------------------------------- @SuppressWarnings("unchecked") public void testFactory_Decorate() { - final MultiValuedMap base = new ArrayListValuedHashMap(); + final MultiValuedMap base = new ArrayListValuedHashMap<>(); base.put((K) "A", (V) "1"); base.put((K) "B", (V) "2"); base.put((K) "C", (V) "3"); @@ -116,7 +116,7 @@ public class TransformedMultiValuedMapTest extends AbstractMultiValuedMapT @SuppressWarnings("unchecked") public void testFactory_decorateTransform() { - final MultiValuedMap base = new ArrayListValuedHashMap(); + final MultiValuedMap base = new ArrayListValuedHashMap<>(); base.put((K) "A", (V) "1"); base.put((K) "B", (V) "2"); base.put((K) "C", (V) "3"); diff --git a/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java index 633af67f3..1379d5a61 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java @@ -66,7 +66,7 @@ public class UnmodifiableMultiValuedMapTest extends AbstractMultiValuedMap @Override protected MultiValuedMap makeFullMap() { - final MultiValuedMap map = new ArrayListValuedHashMap(); + final MultiValuedMap map = new ArrayListValuedHashMap<>(); addSampleMappings(map); return UnmodifiableMultiValuedMap. unmodifiableMultiValuedMap(map); } diff --git a/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java b/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java index 67ef70049..dde3c40bf 100644 --- a/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java +++ b/src/test/java/org/apache/commons/collections4/multiset/AbstractMultiSetTest.java @@ -73,7 +73,7 @@ public abstract class AbstractMultiSetTest extends AbstractCollectionTest */ @Override public Collection makeConfirmedCollection() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); return list; } @@ -202,7 +202,7 @@ public abstract class AbstractMultiSetTest extends AbstractCollectionTest multiset.add((T) "B"); multiset.add((T) "C"); assertEquals("Should have count of 4", 4, multiset.size()); - final List delete = new ArrayList(); + final List delete = new ArrayList<>(); delete.add("A"); delete.add("B"); multiset.removeAll(delete); @@ -243,15 +243,15 @@ public abstract class AbstractMultiSetTest extends AbstractCollectionTest } final MultiSet multiset = makeObject(); - final List known = new ArrayList(); - final List known1A = new ArrayList(); + final List known = new ArrayList<>(); + final List known1A = new ArrayList<>(); known1A.add("A"); - final List known2A = new ArrayList(); + final List known2A = new ArrayList<>(); known2A.add("A"); known2A.add("A"); - final List known1B = new ArrayList(); + final List known1B = new ArrayList<>(); known1B.add("B"); - final List known1A1B = new ArrayList(); + final List known1A1B = new ArrayList<>(); known1A1B.add("A"); known1A1B.add("B"); @@ -328,7 +328,7 @@ public abstract class AbstractMultiSetTest extends AbstractCollectionTest multiset.add((T) "B"); multiset.add((T) "B"); multiset.add((T) "C"); - final List retains = new ArrayList(); + final List retains = new ArrayList<>(); retains.add("B"); retains.add("C"); multiset.retainAll(retains); @@ -543,7 +543,7 @@ public abstract class AbstractMultiSetTest extends AbstractCollectionTest } final MultiSet multiset = makeObject(); - final MultiSet multiset2 = new HashMultiSet(); + final MultiSet multiset2 = new HashMultiSet<>(); assertEquals(true, multiset.equals(multiset2)); multiset.add((T) "A"); assertEquals(false, multiset.equals(multiset2)); @@ -654,14 +654,14 @@ public abstract class AbstractMultiSetTest extends AbstractCollectionTest public void resetEmpty() { AbstractMultiSetTest.this.resetEmpty(); TestMultiSetUniqueSet.this.setCollection(AbstractMultiSetTest.this.getCollection().uniqueSet()); - TestMultiSetUniqueSet.this.setConfirmed(new HashSet(AbstractMultiSetTest.this.getConfirmed())); + TestMultiSetUniqueSet.this.setConfirmed(new HashSet<>(AbstractMultiSetTest.this.getConfirmed())); } @Override public void resetFull() { AbstractMultiSetTest.this.resetFull(); TestMultiSetUniqueSet.this.setCollection(AbstractMultiSetTest.this.getCollection().uniqueSet()); - TestMultiSetUniqueSet.this.setConfirmed(new HashSet(AbstractMultiSetTest.this.getConfirmed())); + TestMultiSetUniqueSet.this.setConfirmed(new HashSet<>(AbstractMultiSetTest.this.getConfirmed())); } @Override diff --git a/src/test/java/org/apache/commons/collections4/multiset/HashMultiSetTest.java b/src/test/java/org/apache/commons/collections4/multiset/HashMultiSetTest.java index 5e7a09479..bee9c4c97 100644 --- a/src/test/java/org/apache/commons/collections4/multiset/HashMultiSetTest.java +++ b/src/test/java/org/apache/commons/collections4/multiset/HashMultiSetTest.java @@ -42,7 +42,7 @@ public class HashMultiSetTest extends AbstractMultiSetTest { @Override public MultiSet makeObject() { - return new HashMultiSet(); + return new HashMultiSet<>(); } @Override diff --git a/src/test/java/org/apache/commons/collections4/multiset/PredicatedMultiSetTest.java b/src/test/java/org/apache/commons/collections4/multiset/PredicatedMultiSetTest.java index 656b95941..75bff5345 100644 --- a/src/test/java/org/apache/commons/collections4/multiset/PredicatedMultiSetTest.java +++ b/src/test/java/org/apache/commons/collections4/multiset/PredicatedMultiSetTest.java @@ -104,7 +104,7 @@ public class PredicatedMultiSetTest extends AbstractMultiSetTest { @SuppressWarnings("unchecked") public void testIllegalDecorate() { - final HashMultiSet elements = new HashMultiSet(); + final HashMultiSet elements = new HashMultiSet<>(); elements.add("one"); elements.add("two"); elements.add(Integer.valueOf(3)); diff --git a/src/test/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSetTest.java b/src/test/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSetTest.java index 79c870083..5ef4fcf6f 100644 --- a/src/test/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSetTest.java +++ b/src/test/java/org/apache/commons/collections4/multiset/UnmodifiableMultiSetTest.java @@ -49,7 +49,7 @@ public class UnmodifiableMultiSetTest extends AbstractMultiSetTest { @Override public MultiSet makeFullCollection() { - final MultiSet multiset = new HashMultiSet(); + final MultiSet multiset = new HashMultiSet<>(); multiset.addAll(Arrays.asList(getFullElements())); return UnmodifiableMultiSet.unmodifiableMultiSet(multiset); } diff --git a/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java index e86ace2fd..5cf402917 100644 --- a/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java @@ -87,7 +87,7 @@ public abstract class AbstractQueueTest extends AbstractCollectionTest { */ @Override public Collection makeConfirmedCollection() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); return list; } @@ -96,7 +96,7 @@ public abstract class AbstractQueueTest extends AbstractCollectionTest { */ @Override public Collection makeConfirmedFullCollection() { - final ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } diff --git a/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java index e3fe6549d..f2b0edc77 100644 --- a/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java @@ -84,7 +84,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { */ @Override public Collection makeConfirmedCollection() { - return new ArrayList(); + return new ArrayList<>(); } /** @@ -106,7 +106,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { */ @Override public Queue makeObject() { - return new CircularFifoQueue(100); + return new CircularFifoQueue<>(100); } //----------------------------------------------------------------------- @@ -115,11 +115,11 @@ public class CircularFifoQueueTest extends AbstractQueueTest { */ @SuppressWarnings("unchecked") public void testCircularFifoQueueCircular() { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add((E) "A"); list.add((E) "B"); list.add((E) "C"); - final Queue queue = new CircularFifoQueue(list); + final Queue queue = new CircularFifoQueue<>(list); assertEquals(true, queue.contains("A")); assertEquals(true, queue.contains("B")); @@ -198,7 +198,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { @SuppressWarnings("unchecked") public void testRemoveError1() throws Exception { // based on bug 33071 - final CircularFifoQueue fifo = new CircularFifoQueue(5); + final CircularFifoQueue fifo = new CircularFifoQueue<>(5); fifo.add((E) "1"); fifo.add((E) "2"); fifo.add((E) "3"); @@ -217,7 +217,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { @SuppressWarnings("unchecked") public void testRemoveError2() throws Exception { // based on bug 33071 - final CircularFifoQueue fifo = new CircularFifoQueue(5); + final CircularFifoQueue fifo = new CircularFifoQueue<>(5); fifo.add((E) "1"); fifo.add((E) "2"); fifo.add((E) "3"); @@ -238,7 +238,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { @SuppressWarnings("unchecked") public void testRemoveError3() throws Exception { // based on bug 33071 - final CircularFifoQueue fifo = new CircularFifoQueue(5); + final CircularFifoQueue fifo = new CircularFifoQueue<>(5); fifo.add((E) "1"); fifo.add((E) "2"); fifo.add((E) "3"); @@ -261,7 +261,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { @SuppressWarnings("unchecked") public void testRemoveError4() throws Exception { // based on bug 33071 - final CircularFifoQueue fifo = new CircularFifoQueue(5); + final CircularFifoQueue fifo = new CircularFifoQueue<>(5); fifo.add((E) "1"); fifo.add((E) "2"); fifo.add((E) "3"); @@ -279,7 +279,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { @SuppressWarnings("unchecked") public void testRemoveError5() throws Exception { // based on bug 33071 - final CircularFifoQueue fifo = new CircularFifoQueue(5); + final CircularFifoQueue fifo = new CircularFifoQueue<>(5); fifo.add((E) "1"); fifo.add((E) "2"); fifo.add((E) "3"); @@ -297,7 +297,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { @SuppressWarnings("unchecked") public void testRemoveError6() throws Exception { // based on bug 33071 - final CircularFifoQueue fifo = new CircularFifoQueue(5); + final CircularFifoQueue fifo = new CircularFifoQueue<>(5); fifo.add((E) "1"); fifo.add((E) "2"); fifo.add((E) "3"); @@ -315,7 +315,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { @SuppressWarnings("unchecked") public void testRemoveError7() throws Exception { // based on bug 33071 - final CircularFifoQueue fifo = new CircularFifoQueue(5); + final CircularFifoQueue fifo = new CircularFifoQueue<>(5); fifo.add((E) "1"); fifo.add((E) "2"); fifo.add((E) "3"); @@ -333,7 +333,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { @SuppressWarnings("unchecked") public void testRemoveError8() throws Exception { // based on bug 33071 - final CircularFifoQueue fifo = new CircularFifoQueue(5); + final CircularFifoQueue fifo = new CircularFifoQueue<>(5); fifo.add((E) "1"); fifo.add((E) "2"); fifo.add((E) "3"); @@ -352,7 +352,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { @SuppressWarnings("unchecked") public void testRemoveError9() throws Exception { // based on bug 33071 - final CircularFifoQueue fifo = new CircularFifoQueue(5); + final CircularFifoQueue fifo = new CircularFifoQueue<>(5); fifo.add((E) "1"); fifo.add((E) "2"); fifo.add((E) "3"); @@ -372,7 +372,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { @SuppressWarnings("unchecked") public void testRepeatedSerialization() throws Exception { // bug 31433 - final CircularFifoQueue b = new CircularFifoQueue(2); + final CircularFifoQueue b = new CircularFifoQueue<>(2); b.add((E) "a"); assertEquals(1, b.size()); assertEquals(true, b.contains("a")); diff --git a/src/test/java/org/apache/commons/collections4/queue/PredicatedQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/PredicatedQueueTest.java index 5171e4ab9..3f027963c 100644 --- a/src/test/java/org/apache/commons/collections4/queue/PredicatedQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/PredicatedQueueTest.java @@ -54,19 +54,19 @@ public class PredicatedQueueTest extends AbstractQueueTest { @Override public Queue makeFullCollection() { - final Queue queue = new LinkedList(); + final Queue queue = new LinkedList<>(); queue.addAll(Arrays.asList(getFullElements())); return decorateCollection(queue, truePredicate); } @Override public Collection makeConfirmedCollection() { - return new LinkedList(); + return new LinkedList<>(); } @Override public Collection makeConfirmedFullCollection() { - final List list = new LinkedList(); + final List list = new LinkedList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } diff --git a/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java index a96958eae..5b01462b1 100644 --- a/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/TransformedQueueTest.java @@ -41,12 +41,12 @@ public class TransformedQueueTest extends AbstractQueueTest { //----------------------------------------------------------------------- @Override public Queue makeConfirmedCollection() { - return new LinkedList(); + return new LinkedList<>(); } @Override public Queue makeConfirmedFullCollection() { - final Queue list = new LinkedList(); + final Queue list = new LinkedList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } @@ -61,14 +61,14 @@ public class TransformedQueueTest extends AbstractQueueTest { @Override @SuppressWarnings("unchecked") public Queue makeFullCollection() { - final Queue list = new LinkedList(); + final Queue list = new LinkedList<>(); list.addAll(Arrays.asList(getFullElements())); return TransformedQueue.transformingQueue(list, (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); } //----------------------------------------------------------------------- public void testTransformedQueue() { - final Queue queue = TransformedQueue.transformingQueue(new LinkedList(), + final Queue queue = TransformedQueue.transformingQueue(new LinkedList<>(), TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); assertEquals(0, queue.size()); final Object[] elements = new Object[] { "1", "3", "5", "7", "2", "4", "6" }; diff --git a/src/test/java/org/apache/commons/collections4/queue/UnmodifiableQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/UnmodifiableQueueTest.java index 5fe8d4834..1f1d96a5e 100644 --- a/src/test/java/org/apache/commons/collections4/queue/UnmodifiableQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/UnmodifiableQueueTest.java @@ -45,19 +45,19 @@ public class UnmodifiableQueueTest extends AbstractQueueTest { @Override public Queue makeFullCollection() { - final Queue queue = new LinkedList(); + final Queue queue = new LinkedList<>(); queue.addAll(Arrays.asList(getFullElements())); return UnmodifiableQueue.unmodifiableQueue(queue); } @Override public Collection makeConfirmedCollection() { - return new LinkedList(); + return new LinkedList<>(); } @Override public Collection makeConfirmedFullCollection() { - final LinkedList list = new LinkedList(); + final LinkedList list = new LinkedList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } diff --git a/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java b/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java index 63c90b931..f2795ec59 100644 --- a/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java @@ -36,7 +36,7 @@ public class SequencesComparatorTest { public void testLength() { for (int i = 0; i < before.size(); ++i) { final SequencesComparator comparator = - new SequencesComparator(sequence(before.get(i)), + new SequencesComparator<>(sequence(before.get(i)), sequence(after.get(i))); Assert.assertEquals(length[i], comparator.getScript().getModifications()); } @@ -44,10 +44,10 @@ public class SequencesComparatorTest { @Test public void testExecution() { - final ExecutionVisitor ev = new ExecutionVisitor(); + final ExecutionVisitor ev = new ExecutionVisitor<>(); for (int i = 0; i < before.size(); ++i) { ev.setList(sequence(before.get(i))); - new SequencesComparator(sequence(before.get(i)), + new SequencesComparator<>(sequence(before.get(i)), sequence(after.get(i))).getScript().visit(ev); Assert.assertEquals(after.get(i), ev.getString()); } @@ -61,8 +61,8 @@ public class SequencesComparatorTest { new String("ZO"), new String("MEU") }; - final List sentenceBefore = new ArrayList(); - final List sentenceAfter = new ArrayList(); + final List sentenceBefore = new ArrayList<>(); + final List sentenceAfter = new ArrayList<>(); sentenceBefore.add(shadokAlph[0]); sentenceBefore.add(shadokAlph[2]); sentenceBefore.add(shadokAlph[3]); @@ -99,7 +99,7 @@ public class SequencesComparatorTest { } final SequencesComparator comparator = - new SequencesComparator(sentenceBefore, sentenceAfter); + new SequencesComparator<>(sentenceBefore, sentenceAfter); Assert.assertTrue(comparator.getScript().getModifications() <= nbCom); } } @@ -113,13 +113,13 @@ public class SequencesComparatorTest { new String("ZO"), new String("MEU") }; - List> shadokSentences = new ArrayList>(); + List> shadokSentences = new ArrayList<>(); for (int lg=0; lg> newTab = new ArrayList>(); + final List> newTab = new ArrayList<>(); newTab.add(new ArrayList()); for (final String element : shadokAlph) { for (final List sentence : shadokSentences) { - final List newSentence = new ArrayList(sentence); + final List newSentence = new ArrayList<>(sentence); newSentence.add(element); newTab.add(newSentence); } @@ -127,12 +127,12 @@ public class SequencesComparatorTest { shadokSentences = newTab; } - final ExecutionVisitor ev = new ExecutionVisitor(); + final ExecutionVisitor ev = new ExecutionVisitor<>(); for (int i = 0; i < shadokSentences.size(); ++i) { for (List shadokSentence : shadokSentences) { ev.setList(shadokSentences.get(i)); - new SequencesComparator(shadokSentences.get(i), + new SequencesComparator<>(shadokSentences.get(i), shadokSentence).getScript().visit(ev); final StringBuilder concat = new StringBuilder(); @@ -145,7 +145,7 @@ public class SequencesComparatorTest { } private List sequence(final String string) { - final List list = new ArrayList(); + final List list = new ArrayList<>(); for (int i = 0; i < string.length(); ++i) { list.add(new Character(string.charAt(i))); } @@ -158,7 +158,7 @@ public class SequencesComparatorTest { private int index; public void setList(final List array) { - v = new ArrayList(array); + v = new ArrayList<>(array); index = 0; } diff --git a/src/test/java/org/apache/commons/collections4/set/AbstractNavigableSetTest.java b/src/test/java/org/apache/commons/collections4/set/AbstractNavigableSetTest.java index 62bcd2f70..927719fe9 100644 --- a/src/test/java/org/apache/commons/collections4/set/AbstractNavigableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/AbstractNavigableSetTest.java @@ -67,7 +67,7 @@ public abstract class AbstractNavigableSetTest extends AbstractSortedSetTest< */ @Override public NavigableSet makeConfirmedCollection() { - return new TreeSet(); + return new TreeSet<>(); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java b/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java index 1b0b658ae..da1f7501a 100644 --- a/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java @@ -84,7 +84,7 @@ public abstract class AbstractSetTest extends AbstractCollectionTest { */ @Override public Collection makeConfirmedCollection() { - return new HashSet(); + return new HashSet<>(); } /** diff --git a/src/test/java/org/apache/commons/collections4/set/AbstractSortedSetTest.java b/src/test/java/org/apache/commons/collections4/set/AbstractSortedSetTest.java index 1250583c4..e0bc53cf4 100644 --- a/src/test/java/org/apache/commons/collections4/set/AbstractSortedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/AbstractSortedSetTest.java @@ -108,7 +108,7 @@ public abstract class AbstractSortedSetTest extends AbstractSetTest { */ @Override public SortedSet makeConfirmedCollection() { - return new TreeSet(); + return new TreeSet<>(); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java b/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java index 178a4cf90..3420eafdf 100644 --- a/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java @@ -37,15 +37,15 @@ public class CompositeSetTest extends AbstractSetTest { @Override public CompositeSet makeObject() { - final HashSet contained = new HashSet(); - final CompositeSet set = new CompositeSet(contained); - set.setMutator( new EmptySetMutator(contained) ); + final HashSet contained = new HashSet<>(); + final CompositeSet set = new CompositeSet<>(contained); + set.setMutator( new EmptySetMutator<>(contained) ); return set; } @SuppressWarnings("unchecked") public Set buildOne() { - final HashSet set = new HashSet(); + final HashSet set = new HashSet<>(); set.add((E) "1"); set.add((E) "2"); return set; @@ -53,7 +53,7 @@ public class CompositeSetTest extends AbstractSetTest { @SuppressWarnings("unchecked") public Set buildTwo() { - final HashSet set = new HashSet(); + final HashSet set = new HashSet<>(); set.add((E) "3"); set.add((E) "4"); return set; @@ -61,7 +61,7 @@ public class CompositeSetTest extends AbstractSetTest { @SuppressWarnings("unchecked") public void testContains() { - final CompositeSet set = new CompositeSet(new Set[]{ buildOne(), buildTwo() }); + final CompositeSet set = new CompositeSet<>(new Set[]{ buildOne(), buildTwo() }); assertTrue(set.contains("1")); } @@ -69,7 +69,7 @@ public class CompositeSetTest extends AbstractSetTest { public void testRemoveUnderlying() { final Set one = buildOne(); final Set two = buildTwo(); - final CompositeSet set = new CompositeSet(new Set[] { one, two }); + final CompositeSet set = new CompositeSet<>(new Set[] { one, two }); one.remove("1"); assertFalse(set.contains("1")); @@ -81,7 +81,7 @@ public class CompositeSetTest extends AbstractSetTest { public void testRemoveComposited() { final Set one = buildOne(); final Set two = buildTwo(); - final CompositeSet set = new CompositeSet(new Set[] { one, two }); + final CompositeSet set = new CompositeSet<>(new Set[] { one, two }); set.remove("1"); assertFalse(one.contains("1")); @@ -93,7 +93,7 @@ public class CompositeSetTest extends AbstractSetTest { public void testFailedCollisionResolution() { final Set one = buildOne(); final Set two = buildTwo(); - final CompositeSet set = new CompositeSet(new Set[] { one, two }); + final CompositeSet set = new CompositeSet<>(new Set[] { one, two }); set.setMutator(new SetMutator() { private static final long serialVersionUID = 1L; @@ -116,7 +116,7 @@ public class CompositeSetTest extends AbstractSetTest { } }); - final HashSet three = new HashSet(); + final HashSet three = new HashSet<>(); three.add((E) "1"); try { set.addComposited(three); @@ -131,18 +131,18 @@ public class CompositeSetTest extends AbstractSetTest { public void testAddComposited() { final Set one = buildOne(); final Set two = buildTwo(); - final CompositeSet set = new CompositeSet(); + final CompositeSet set = new CompositeSet<>(); set.addComposited(one, two); - final CompositeSet set2 = new CompositeSet(buildOne()); + final CompositeSet set2 = new CompositeSet<>(buildOne()); set2.addComposited(buildTwo()); assertTrue(set.equals(set2)); - final HashSet set3 = new HashSet(); + final HashSet set3 = new HashSet<>(); set3.add((E) "1"); set3.add((E) "2"); set3.add((E) "3"); - final HashSet set4 = new HashSet(); + final HashSet set4 = new HashSet<>(); set4.add((E) "4"); - final CompositeSet set5 = new CompositeSet(set3); + final CompositeSet set5 = new CompositeSet<>(set3); set5.addComposited(set4); assertTrue(set.equals(set5)); try { @@ -155,13 +155,13 @@ public class CompositeSetTest extends AbstractSetTest { @SuppressWarnings("unchecked") public void testAddCompositedCollision() { - final HashSet set1 = new HashSet(); + final HashSet set1 = new HashSet<>(); set1.add((E) "1"); set1.add((E) "2"); set1.add((E) "3"); - final HashSet set2 = new HashSet(); + final HashSet set2 = new HashSet<>(); set2.add((E) "4"); - final CompositeSet set3 = new CompositeSet(set1); + final CompositeSet set3 = new CompositeSet<>(set1); try { set3.addComposited(set1, buildOne()); fail("Expecting UnsupportedOperationException."); diff --git a/src/test/java/org/apache/commons/collections4/set/ListOrderedSet2Test.java b/src/test/java/org/apache/commons/collections4/set/ListOrderedSet2Test.java index 8df7cbc83..532127804 100644 --- a/src/test/java/org/apache/commons/collections4/set/ListOrderedSet2Test.java +++ b/src/test/java/org/apache/commons/collections4/set/ListOrderedSet2Test.java @@ -40,7 +40,7 @@ public class ListOrderedSet2Test extends AbstractSetTest { @Override public ListOrderedSet makeObject() { - return new ListOrderedSet(); + return new ListOrderedSet<>(); } @SuppressWarnings("unchecked") @@ -134,7 +134,7 @@ public class ListOrderedSet2Test extends AbstractSetTest { assertSame(ONE, set.get(1)); assertSame(TWO, set.get(2)); - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add((E) ZERO); list.add((E) TWO); diff --git a/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java b/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java index 38b431a0b..4ed0f3baa 100644 --- a/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/ListOrderedSetTest.java @@ -145,7 +145,7 @@ public class ListOrderedSetTest assertSame(ONE, set.get(1)); assertSame(TWO, set.get(2)); - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.add((E) ZERO); list.add((E) TWO); @@ -182,14 +182,14 @@ public class ListOrderedSetTest @SuppressWarnings("unchecked") public void testRetainAll() { - final List list = new ArrayList(10); - final Set set = new HashSet(10); + final List list = new ArrayList<>(10); + final Set set = new HashSet<>(10); final ListOrderedSet orderedSet = ListOrderedSet.listOrderedSet(set, list); for (int i = 0; i < 10; ++i) { orderedSet.add((E) Integer.valueOf(10 - i - 1)); } - final Collection retained = new ArrayList(5); + final Collection retained = new ArrayList<>(5); for (int i = 0; i < 5; ++i) { retained.add((E) Integer.valueOf(i * 2)); } @@ -206,7 +206,7 @@ public class ListOrderedSetTest @SuppressWarnings("unchecked") public void testDuplicates() { - final List list = new ArrayList(10); + final List list = new ArrayList<>(10); list.add((E) Integer.valueOf(1)); list.add((E) Integer.valueOf(2)); list.add((E) Integer.valueOf(3)); diff --git a/src/test/java/org/apache/commons/collections4/set/PredicatedNavigableSetTest.java b/src/test/java/org/apache/commons/collections4/set/PredicatedNavigableSetTest.java index 1fef276a0..6b9aae9cb 100644 --- a/src/test/java/org/apache/commons/collections4/set/PredicatedNavigableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/PredicatedNavigableSetTest.java @@ -56,7 +56,7 @@ public class PredicatedNavigableSetTest extends AbstractNavigableSetTest { @Override public NavigableSet makeFullCollection() { - final TreeSet set = new TreeSet(); + final TreeSet set = new TreeSet<>(); set.addAll(Arrays.asList(getFullElements())); return PredicatedNavigableSet.predicatedNavigableSet(set, truePredicate); } @@ -96,7 +96,7 @@ public class PredicatedNavigableSetTest extends AbstractNavigableSetTest { @SuppressWarnings("unchecked") public void testIllegalAddAll() { final NavigableSet set = makeTestSet(); - final Set elements = new TreeSet(); + final Set elements = new TreeSet<>(); elements.add((E) "Aone"); elements.add((E) "Atwo"); elements.add((E) "Bthree"); diff --git a/src/test/java/org/apache/commons/collections4/set/PredicatedSetTest.java b/src/test/java/org/apache/commons/collections4/set/PredicatedSetTest.java index 5e196cf70..c107f9b86 100644 --- a/src/test/java/org/apache/commons/collections4/set/PredicatedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/PredicatedSetTest.java @@ -90,7 +90,7 @@ public class PredicatedSetTest extends AbstractSetTest { @SuppressWarnings("unchecked") public void testIllegalAddAll() { final Set set = makeTestSet(); - final Set elements = new HashSet(); + final Set elements = new HashSet<>(); elements.add((E) "one"); elements.add((E) "two"); elements.add((E) Integer.valueOf(3)); diff --git a/src/test/java/org/apache/commons/collections4/set/PredicatedSortedSetTest.java b/src/test/java/org/apache/commons/collections4/set/PredicatedSortedSetTest.java index a6058980f..27a8b49d6 100644 --- a/src/test/java/org/apache/commons/collections4/set/PredicatedSortedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/PredicatedSortedSetTest.java @@ -56,7 +56,7 @@ public class PredicatedSortedSetTest extends AbstractSortedSetTest { @Override public SortedSet makeFullCollection() { - final TreeSet set = new TreeSet(); + final TreeSet set = new TreeSet<>(); set.addAll(Arrays.asList(getFullElements())); return PredicatedSortedSet.predicatedSortedSet(set, truePredicate); } @@ -96,7 +96,7 @@ public class PredicatedSortedSetTest extends AbstractSortedSetTest { @SuppressWarnings("unchecked") public void testIllegalAddAll() { final SortedSet set = makeTestSet(); - final Set elements = new TreeSet(); + final Set elements = new TreeSet<>(); elements.add((E) "Aone"); elements.add((E) "Atwo"); elements.add((E) "Bthree"); diff --git a/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java b/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java index cec1f6f45..7b77c3092 100644 --- a/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/TransformedNavigableSetTest.java @@ -56,7 +56,7 @@ public class TransformedNavigableSetTest extends AbstractNavigableSetTest @Override @SuppressWarnings("unchecked") public NavigableSet makeFullCollection() { - final NavigableSet set = new TreeSet(); + final NavigableSet set = new TreeSet<>(); set.addAll(Arrays.asList(getFullElements())); return TransformedNavigableSet.transformingNavigableSet(set, (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); @@ -79,7 +79,7 @@ public class TransformedNavigableSetTest extends AbstractNavigableSetTest } public void testTransformedSet_decorateTransform() { - final Set originalSet = new TreeSet(); + final Set originalSet = new TreeSet<>(); final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; Collections.addAll(originalSet, els); final Set set = TransformedSet.transformedSet(originalSet, diff --git a/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java b/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java index 2c19b5ed1..2f8e11621 100644 --- a/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/TransformedSetTest.java @@ -39,12 +39,12 @@ public class TransformedSetTest extends AbstractSetTest { @Override public Set makeConfirmedCollection() { - return new HashSet(); + return new HashSet<>(); } @Override public Set makeConfirmedFullCollection() { - final Set set = new HashSet(); + final Set set = new HashSet<>(); set.addAll(Arrays.asList(getFullElements())); return set; } @@ -59,7 +59,7 @@ public class TransformedSetTest extends AbstractSetTest { @Override @SuppressWarnings("unchecked") public Set makeFullCollection() { - final Set list = new HashSet(); + final Set list = new HashSet<>(); list.addAll(Arrays.asList(getFullElements())); return TransformedSet.transformingSet(list, (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); @@ -84,7 +84,7 @@ public class TransformedSetTest extends AbstractSetTest { } public void testTransformedSet_decorateTransform() { - final Set originalSet = new HashSet(); + final Set originalSet = new HashSet<>(); final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; Collections.addAll(originalSet, els); final Set set = TransformedSet.transformedSet(originalSet, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); diff --git a/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java b/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java index 9207986e4..594cfbed1 100644 --- a/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/TransformedSortedSetTest.java @@ -55,7 +55,7 @@ public class TransformedSortedSetTest extends AbstractSortedSetTest { @Override @SuppressWarnings("unchecked") public SortedSet makeFullCollection() { - final SortedSet set = new TreeSet(); + final SortedSet set = new TreeSet<>(); set.addAll(Arrays.asList(getFullElements())); return TransformedSortedSet.transformingSortedSet(set, (Transformer) TransformedCollectionTest.NOOP_TRANSFORMER); } @@ -77,7 +77,7 @@ public class TransformedSortedSetTest extends AbstractSortedSetTest { } public void testTransformedSet_decorateTransform() { - final Set originalSet = new TreeSet(); + final Set originalSet = new TreeSet<>(); final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; Collections.addAll(originalSet, els); final Set set = TransformedSet.transformedSet(originalSet, TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); diff --git a/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java b/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java index d2c4a4271..e4afcd82e 100644 --- a/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/UnmodifiableNavigableSetTest.java @@ -54,7 +54,7 @@ public class UnmodifiableNavigableSetTest extends AbstractNavigableSetTest @Override public UnmodifiableNavigableSet makeFullCollection() { - final TreeSet set = new TreeSet(); + final TreeSet set = new TreeSet<>(); set.addAll(Arrays.asList(getFullElements())); return (UnmodifiableNavigableSet) UnmodifiableNavigableSet.unmodifiableNavigableSet(set); } @@ -73,7 +73,7 @@ public class UnmodifiableNavigableSetTest extends AbstractNavigableSetTest @SuppressWarnings("unchecked") protected void setupSet() { set = makeFullCollection(); - array = new ArrayList(); + array = new ArrayList<>(); array.add((E) Integer.valueOf(1)); } diff --git a/src/test/java/org/apache/commons/collections4/set/UnmodifiableSetTest.java b/src/test/java/org/apache/commons/collections4/set/UnmodifiableSetTest.java index f5ec16917..55146edf5 100644 --- a/src/test/java/org/apache/commons/collections4/set/UnmodifiableSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/UnmodifiableSetTest.java @@ -50,7 +50,7 @@ public class UnmodifiableSetTest extends AbstractSetTest { @Override public Set makeFullCollection() { - final HashSet set = new HashSet(); + final HashSet set = new HashSet<>(); set.addAll(Arrays.asList(getFullElements())); return UnmodifiableSet.unmodifiableSet(set); } diff --git a/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java b/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java index 0a24cd698..037d91783 100644 --- a/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/UnmodifiableSortedSetTest.java @@ -54,7 +54,7 @@ public class UnmodifiableSortedSetTest extends AbstractSortedSetTest { @Override public UnmodifiableSortedSet makeFullCollection() { - final TreeSet set = new TreeSet(); + final TreeSet set = new TreeSet<>(); set.addAll(Arrays.asList(getFullElements())); return (UnmodifiableSortedSet) UnmodifiableSortedSet.unmodifiableSortedSet(set); } @@ -73,7 +73,7 @@ public class UnmodifiableSortedSetTest extends AbstractSortedSetTest { @SuppressWarnings("unchecked") protected void setupSet() { set = makeFullCollection(); - array = new ArrayList(); + array = new ArrayList<>(); array.add((E) Integer.valueOf(1)); } diff --git a/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java b/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java index 1e08e2a2d..98b5ecb4b 100644 --- a/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java +++ b/src/test/java/org/apache/commons/collections4/splitmap/TransformedSplitMapTest.java @@ -67,7 +67,7 @@ public class TransformedSplitMapTest extends BulkTest { new HashMap>(), intToString, objectToClass); final Integer[] k = new Integer[] { 0, 1, 2, 3, 4, 5, 6 }; - final Object[] v = new Object[] { "", new Object(), new HashMap(), 0, BigInteger.TEN, null, + final Object[] v = new Object[] { "", new Object(), new HashMap<>(), 0, BigInteger.TEN, null, new Object[0] }; assertEquals(0, map.size()); diff --git a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrie2Test.java b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrie2Test.java index cd136e544..04e773e5e 100644 --- a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrie2Test.java +++ b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrie2Test.java @@ -40,7 +40,7 @@ public class PatriciaTrie2Test extends AbstractOrderedMapTest { @Override public OrderedMap makeObject() { - return new PatriciaTrie(); + return new PatriciaTrie<>(); } @Override diff --git a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java index 92559fb7f..c143f0018 100755 --- a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java +++ b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java @@ -51,7 +51,7 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { @Override public SortedMap makeObject() { - return new PatriciaTrie(); + return new PatriciaTrie<>(); } @Override @@ -62,7 +62,7 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { //----------------------------------------------------------------------- public void testPrefixMap() { - final PatriciaTrie trie = new PatriciaTrie(); + final PatriciaTrie trie = new PatriciaTrie<>(); final String[] keys = new String[]{ "", @@ -289,7 +289,7 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { } public void testPrefixMapRemoval() { - final PatriciaTrie trie = new PatriciaTrie(); + final PatriciaTrie trie = new PatriciaTrie<>(); final String[] keys = new String[]{ "Albert", "Xavier", "XyZ", "Anna", "Alien", "Alberto", @@ -332,7 +332,7 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { public void testPrefixMapSizes() { // COLLECTIONS-525 - PatriciaTrie aTree = new PatriciaTrie(); + PatriciaTrie aTree = new PatriciaTrie<>(); aTree.put("点评", "测试"); aTree.put("书评", "测试"); assertTrue(aTree.prefixMap("点").containsKey("点评")); @@ -354,7 +354,7 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { final char u8000 = Character.toChars(32768)[0]; // U+8000 (1000000000000000) final char char_b = 'b'; // 1100010 - final PatriciaTrie trie = new PatriciaTrie(); + final PatriciaTrie trie = new PatriciaTrie<>(); final String prefixString = "" + char_b; final String longerString = prefixString + u8000; @@ -371,7 +371,7 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { } public void testPrefixMapClear() { - Trie trie = new PatriciaTrie(); + Trie trie = new PatriciaTrie<>(); trie.put("Anna", 1); trie.put("Anael", 2); trie.put("Analu", 3); @@ -380,33 +380,33 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { trie.put("Andres", 6); trie.put("Anatole", 7); SortedMap prefixMap = trie.prefixMap("And"); - assertEquals(new HashSet(Arrays.asList("Andrea", "Andreas", "Andres")), prefixMap.keySet()); - assertEquals(Arrays.asList(5, 4, 6), new ArrayList(prefixMap.values())); + assertEquals(new HashSet<>(Arrays.asList("Andrea", "Andreas", "Andres")), prefixMap.keySet()); + assertEquals(Arrays.asList(5, 4, 6), new ArrayList<>(prefixMap.values())); prefixMap.clear(); assertTrue(prefixMap.isEmpty()); assertTrue(prefixMap.keySet().isEmpty()); assertTrue(prefixMap.values().isEmpty()); - assertEquals(new HashSet(Arrays.asList("Anael", "Analu", "Anatole", "Anna")), trie.keySet()); - assertEquals(Arrays.asList(2, 3, 7, 1), new ArrayList(trie.values())); + assertEquals(new HashSet<>(Arrays.asList("Anael", "Analu", "Anatole", "Anna")), trie.keySet()); + assertEquals(Arrays.asList(2, 3, 7, 1), new ArrayList<>(trie.values())); } public void testPrefixMapClearNothing() { - Trie trie = new PatriciaTrie(); + Trie trie = new PatriciaTrie<>(); SortedMap prefixMap = trie.prefixMap("And"); assertEquals(new HashSet(), prefixMap.keySet()); - assertEquals(new ArrayList(0), new ArrayList(prefixMap.values())); + assertEquals(new ArrayList(0), new ArrayList<>(prefixMap.values())); prefixMap.clear(); assertTrue(prefixMap.isEmpty()); assertTrue(prefixMap.keySet().isEmpty()); assertTrue(prefixMap.values().isEmpty()); assertEquals(new HashSet(), trie.keySet()); - assertEquals(new ArrayList(0), new ArrayList(trie.values())); + assertEquals(new ArrayList(0), new ArrayList<>(trie.values())); } public void testPrefixMapClearUsingRemove() { - Trie trie = new PatriciaTrie(); + Trie trie = new PatriciaTrie<>(); trie.put("Anna", 1); trie.put("Anael", 2); trie.put("Analu", 3); @@ -415,17 +415,17 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { trie.put("Andres", 6); trie.put("Anatole", 7); SortedMap prefixMap = trie.prefixMap("And"); - assertEquals(new HashSet(Arrays.asList("Andrea", "Andreas", "Andres")), prefixMap.keySet()); - assertEquals(Arrays.asList(5, 4, 6), new ArrayList(prefixMap.values())); + assertEquals(new HashSet<>(Arrays.asList("Andrea", "Andreas", "Andres")), prefixMap.keySet()); + assertEquals(Arrays.asList(5, 4, 6), new ArrayList<>(prefixMap.values())); - Set keys = new HashSet(prefixMap.keySet()); + Set keys = new HashSet<>(prefixMap.keySet()); for (final String key : keys) { prefixMap.remove(key); } assertTrue(prefixMap.keySet().isEmpty()); assertTrue(prefixMap.values().isEmpty()); - assertEquals(new HashSet(Arrays.asList("Anael", "Analu", "Anatole", "Anna")), trie.keySet()); - assertEquals(Arrays.asList(2, 3, 7, 1), new ArrayList(trie.values())); + assertEquals(new HashSet<>(Arrays.asList("Anael", "Analu", "Anatole", "Anna")), trie.keySet()); + assertEquals(Arrays.asList(2, 3, 7, 1), new ArrayList<>(trie.values())); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/collections4/trie/UnmodifiableTrieTest.java b/src/test/java/org/apache/commons/collections4/trie/UnmodifiableTrieTest.java index 1fc8c01d8..df30a6b44 100644 --- a/src/test/java/org/apache/commons/collections4/trie/UnmodifiableTrieTest.java +++ b/src/test/java/org/apache/commons/collections4/trie/UnmodifiableTrieTest.java @@ -64,7 +64,7 @@ public class UnmodifiableTrieTest extends AbstractSortedMapTest { @Override public Trie makeFullMap() { - final Trie m = new PatriciaTrie(); + final Trie m = new PatriciaTrie<>(); addSampleMappings(m); return UnmodifiableTrie.unmodifiableTrie(m); }