diff --git a/src/main/java/org/apache/commons/collections4/CollectionUtils.java b/src/main/java/org/apache/commons/collections4/CollectionUtils.java index f7d3e8211..bd9ddf09a 100644 --- a/src/main/java/org/apache/commons/collections4/CollectionUtils.java +++ b/src/main/java/org/apache/commons/collections4/CollectionUtils.java @@ -1189,7 +1189,7 @@ public class CollectionUtils { */ public static Collection collect(final Iterator inputIterator, final Transformer transformer) { - return collect(inputIterator, transformer, new ArrayList()); + return collect(inputIterator, transformer, new ArrayList<>()); } /** @@ -1892,7 +1892,7 @@ public class CollectionUtils { final Transformer> transformer = input -> new EquatorWrapper<>(equator, input); final Set> retainSet = - collect(retain, transformer, new HashSet>()); + collect(retain, transformer, new HashSet<>()); final List list = new ArrayList<>(); for (final E element : collection) { @@ -2031,7 +2031,7 @@ public class CollectionUtils { final Transformer> transformer = input -> new EquatorWrapper<>(equator, input); final Set> removeSet = - collect(remove, transformer, new HashSet>()); + collect(remove, transformer, new HashSet<>()); final List list = new ArrayList<>(); for (final E element : collection) { diff --git a/src/main/java/org/apache/commons/collections4/ListUtils.java b/src/main/java/org/apache/commons/collections4/ListUtils.java index dfca88238..53dea6889 100644 --- a/src/main/java/org/apache/commons/collections4/ListUtils.java +++ b/src/main/java/org/apache/commons/collections4/ListUtils.java @@ -596,7 +596,7 @@ public class ListUtils { */ public static List select(final Collection inputCollection, final Predicate predicate) { - return CollectionUtils.select(inputCollection, predicate, new ArrayList(inputCollection.size())); + return CollectionUtils.select(inputCollection, predicate, new ArrayList<>(inputCollection.size())); } /** @@ -616,7 +616,7 @@ public class ListUtils { */ public static List selectRejected(final Collection inputCollection, final Predicate predicate) { - return CollectionUtils.selectRejected(inputCollection, predicate, new ArrayList(inputCollection.size())); + return CollectionUtils.selectRejected(inputCollection, predicate, new ArrayList<>(inputCollection.size())); } /** diff --git a/src/main/java/org/apache/commons/collections4/MapUtils.java b/src/main/java/org/apache/commons/collections4/MapUtils.java index a84b78320..15ea58b9c 100644 --- a/src/main/java/org/apache/commons/collections4/MapUtils.java +++ b/src/main/java/org/apache/commons/collections4/MapUtils.java @@ -167,7 +167,7 @@ public class MapUtils { * @throws NullPointerException if the stream is {@code null} */ public static void debugPrint(final PrintStream out, final Object label, final Map map) { - verbosePrintInternal(out, label, map, new ArrayDeque>(), true); + verbosePrintInternal(out, label, map, new ArrayDeque<>(), true); } /** @@ -1967,7 +1967,7 @@ public class MapUtils { * @throws NullPointerException if the stream is {@code null} */ public static void verbosePrint(final PrintStream out, final Object label, final Map map) { - verbosePrintInternal(out, label, map, new ArrayDeque>(), false); + verbosePrintInternal(out, label, map, new ArrayDeque<>(), false); } /** diff --git a/src/main/java/org/apache/commons/collections4/SetUtils.java b/src/main/java/org/apache/commons/collections4/SetUtils.java index 046b0673b..3c3beea4f 100644 --- a/src/main/java/org/apache/commons/collections4/SetUtils.java +++ b/src/main/java/org/apache/commons/collections4/SetUtils.java @@ -351,7 +351,7 @@ public class SetUtils { * @since 4.1 */ public static Set newIdentityHashSet() { - return Collections.newSetFromMap(new IdentityHashMap()); + return Collections.newSetFromMap(new IdentityHashMap<>()); } /** diff --git a/src/main/java/org/apache/commons/collections4/bag/HashBag.java b/src/main/java/org/apache/commons/collections4/bag/HashBag.java index ca9e45849..18d91546a 100644 --- a/src/main/java/org/apache/commons/collections4/bag/HashBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/HashBag.java @@ -46,7 +46,7 @@ public class HashBag extends AbstractMapBag implements Serializable { * Constructs an empty {@link HashBag}. */ public HashBag() { - super(new HashMap()); + super(new HashMap<>()); } /** @@ -79,7 +79,7 @@ public class HashBag extends AbstractMapBag implements Serializable { */ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); - super.doReadObject(new HashMap(), in); + super.doReadObject(new HashMap<>(), in); } } diff --git a/src/main/java/org/apache/commons/collections4/bag/TreeBag.java b/src/main/java/org/apache/commons/collections4/bag/TreeBag.java index 5bb8b9647..a0256f22e 100644 --- a/src/main/java/org/apache/commons/collections4/bag/TreeBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/TreeBag.java @@ -53,7 +53,7 @@ public class TreeBag extends AbstractMapBag implements SortedBag, Seria * Constructs an empty {@link TreeBag}. */ public TreeBag() { - super(new TreeMap()); + super(new TreeMap<>()); } /** @@ -63,7 +63,7 @@ public class TreeBag extends AbstractMapBag implements SortedBag, Seria * @param comparator the comparator to use */ public TreeBag(final Comparator comparator) { - super(new TreeMap(comparator)); + super(new TreeMap<>(comparator)); } /** @@ -139,7 +139,7 @@ public class TreeBag extends AbstractMapBag implements SortedBag, Seria in.defaultReadObject(); @SuppressWarnings("unchecked") // This will fail at runtime if the stream is incorrect final Comparator comp = (Comparator) in.readObject(); - super.doReadObject(new TreeMap(comp), in); + super.doReadObject(new TreeMap<>(comp), in); } } 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 9e96ed444..8fd0212f5 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/DualHashBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/DualHashBidiMap.java @@ -52,7 +52,7 @@ public class DualHashBidiMap extends AbstractDualBidiMap implements * Creates an empty {@code HashBidiMap}. */ public DualHashBidiMap() { - super(new HashMap(), new HashMap()); + super(new HashMap<>(), new HashMap<>()); } /** @@ -62,7 +62,7 @@ public class DualHashBidiMap extends AbstractDualBidiMap implements * @param map the map whose mappings are to be placed in this map */ public DualHashBidiMap(final Map map) { - super(new HashMap(), new HashMap()); + super(new HashMap<>(), new HashMap<>()); 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 8e9878622..a3ac683fb 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/DualLinkedHashBidiMap.java @@ -46,7 +46,7 @@ public class DualLinkedHashBidiMap extends AbstractDualBidiMap imple * Creates an empty {@code HashBidiMap}. */ public DualLinkedHashBidiMap() { - super(new LinkedHashMap(), new LinkedHashMap()); + super(new LinkedHashMap<>(), new LinkedHashMap<>()); } /** @@ -56,7 +56,7 @@ public class DualLinkedHashBidiMap extends AbstractDualBidiMap imple * @param map the map whose mappings are to be placed in this map */ public DualLinkedHashBidiMap(final Map map) { - super(new LinkedHashMap(), new LinkedHashMap()); + super(new LinkedHashMap<>(), new LinkedHashMap<>()); 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 2458b764c..7c3639d06 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap.java @@ -72,7 +72,7 @@ public class DualTreeBidiMap extends AbstractDualBidiMap * Creates an empty {@link DualTreeBidiMap}. */ public DualTreeBidiMap() { - super(new TreeMap(), new TreeMap()); + super(new TreeMap<>(), new TreeMap<>()); this.comparator = null; this.valueComparator = null; } @@ -84,7 +84,7 @@ public class DualTreeBidiMap extends AbstractDualBidiMap * @param map the map whose mappings are to be placed in this map */ public DualTreeBidiMap(final Map map) { - super(new TreeMap(), new TreeMap()); + super(new TreeMap<>(), new TreeMap<>()); putAll(map); this.comparator = null; this.valueComparator = null; @@ -97,7 +97,7 @@ public class DualTreeBidiMap extends AbstractDualBidiMap * @param valueComparator the values comparator to use */ public DualTreeBidiMap(final Comparator keyComparator, final Comparator valueComparator) { - super(new TreeMap(keyComparator), new TreeMap(valueComparator)); + super(new TreeMap<>(keyComparator), new TreeMap<>(valueComparator)); this.comparator = keyComparator; this.valueComparator = valueComparator; } 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 58942e8d3..e88012663 100644 --- a/src/main/java/org/apache/commons/collections4/collection/IndexedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/IndexedCollection.java @@ -76,7 +76,7 @@ public class IndexedCollection extends AbstractCollectionDecorator { public static IndexedCollection uniqueIndexedCollection(final Collection coll, final Transformer keyTransformer) { return new IndexedCollection<>(coll, keyTransformer, - MultiValueMap.multiValueMap(new HashMap>()), + MultiValueMap.multiValueMap(new HashMap<>()), true); } @@ -92,7 +92,7 @@ public class IndexedCollection extends AbstractCollectionDecorator { public static IndexedCollection nonUniqueIndexedCollection(final Collection coll, final Transformer keyTransformer) { return new IndexedCollection<>(coll, keyTransformer, - MultiValueMap.multiValueMap(new HashMap>()), + 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 560efee66..d72473cc3 100644 --- a/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java @@ -268,7 +268,7 @@ public class PredicatedCollection extends AbstractCollectionDecorator { * @return a new predicated list. */ public List createPredicatedList() { - return createPredicatedList(new ArrayList()); + return createPredicatedList(new ArrayList<>()); } /** @@ -299,7 +299,7 @@ public class PredicatedCollection extends AbstractCollectionDecorator { * @return a new predicated set. */ public Set createPredicatedSet() { - return createPredicatedSet(new HashSet()); + return createPredicatedSet(new HashSet<>()); } /** @@ -330,7 +330,7 @@ public class PredicatedCollection extends AbstractCollectionDecorator { * @return a new predicated multiset. */ public MultiSet createPredicatedMultiSet() { - return createPredicatedMultiSet(new HashMultiSet()); + return createPredicatedMultiSet(new HashMultiSet<>()); } /** @@ -362,7 +362,7 @@ public class PredicatedCollection extends AbstractCollectionDecorator { * @return a new predicated bag. */ public Bag createPredicatedBag() { - return createPredicatedBag(new HashBag()); + return createPredicatedBag(new HashBag<>()); } /** @@ -393,7 +393,7 @@ public class PredicatedCollection extends AbstractCollectionDecorator { * @return a new predicated queue. */ public Queue createPredicatedQueue() { - return createPredicatedQueue(new LinkedList()); + return createPredicatedQueue(new LinkedList<>()); } /** 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 766da8a0a..ee1fdb5ce 100644 --- a/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java +++ b/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java @@ -69,7 +69,7 @@ public class ComparatorChain implements Comparator, Serializable { * UnsupportedOperationException is thrown */ public ComparatorChain() { - this(new ArrayList>(), new BitSet()); + this(new ArrayList<>(), new BitSet()); } /** 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 3d8044827..b42d16e78 100644 --- a/src/main/java/org/apache/commons/collections4/list/GrowthList.java +++ b/src/main/java/org/apache/commons/collections4/list/GrowthList.java @@ -79,7 +79,7 @@ public class GrowthList extends AbstractSerializableListDecorator { * Constructor that uses an ArrayList internally. */ public GrowthList() { - super(new ArrayList()); + super(new ArrayList<>()); } /** @@ -89,7 +89,7 @@ public class GrowthList extends AbstractSerializableListDecorator { * @throws IllegalArgumentException if initial capacity is invalid */ public GrowthList(final int initialCapacity) { - super(new ArrayList(initialCapacity)); + super(new ArrayList<>(initialCapacity)); } /** 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 c3ba144c9..481ec11aa 100644 --- a/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java +++ b/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java @@ -76,11 +76,11 @@ public class SetUniqueList extends AbstractSerializableListDecorator { public static SetUniqueList setUniqueList(final List list) { Objects.requireNonNull(list, "list"); if (list.isEmpty()) { - return new SetUniqueList<>(list, new HashSet()); + return new SetUniqueList<>(list, new HashSet<>()); } 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; } 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 90e1bb0a4..46d663aa8 100644 --- a/src/main/java/org/apache/commons/collections4/map/DefaultedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/DefaultedMap.java @@ -152,7 +152,7 @@ public class DefaultedMap extends AbstractMapDecorator implements Se * @param defaultValueTransformer transformer to use to generate missing values. */ public DefaultedMap(final Transformer defaultValueTransformer) { - this(new HashMap(), defaultValueTransformer); + this(new HashMap<>(), defaultValueTransformer); } /** 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 0257714ca..da4df45c7 100644 --- a/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java +++ b/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java @@ -114,7 +114,7 @@ public class ListOrderedMap * @since 3.1 */ public ListOrderedMap() { - this(new HashMap()); + this(new HashMap<>()); } /** 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 d6dd0128d..0250f3f36 100644 --- a/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java +++ b/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java @@ -114,7 +114,7 @@ public class MultiKeyMap extends AbstractMapDecorator, V>()); + this(new HashedMap<>()); } /** 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 0979fa8b5..4b3e65720 100644 --- a/src/main/java/org/apache/commons/collections4/map/PassiveExpiringMap.java +++ b/src/main/java/org/apache/commons/collections4/map/PassiveExpiringMap.java @@ -218,7 +218,7 @@ public class PassiveExpiringMap * @throws NullPointerException if expiringPolicy is null */ public PassiveExpiringMap(final ExpirationPolicy expiringPolicy) { - this(expiringPolicy, new HashMap()); + this(expiringPolicy, new HashMap<>()); } /** @@ -249,8 +249,8 @@ public class PassiveExpiringMap * ALWAYS expire. */ public PassiveExpiringMap(final long timeToLiveMillis) { - this(new ConstantTimeToLiveExpirationPolicy(timeToLiveMillis), - new HashMap()); + this(new ConstantTimeToLiveExpirationPolicy<>(timeToLiveMillis), + new HashMap<>()); } /** @@ -268,7 +268,7 @@ public class PassiveExpiringMap * @throws NullPointerException if the map is null. */ public PassiveExpiringMap(final long timeToLiveMillis, final Map map) { - this(new ConstantTimeToLiveExpirationPolicy(timeToLiveMillis), + this(new ConstantTimeToLiveExpirationPolicy<>(timeToLiveMillis), map); } diff --git a/src/main/java/org/apache/commons/collections4/multiset/HashMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/HashMultiSet.java index caa51f7ce..715c469a0 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/HashMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/HashMultiSet.java @@ -44,7 +44,7 @@ public class HashMultiSet extends AbstractMapMultiSet implements Serializa * Constructs an empty {@link HashMultiSet}. */ public HashMultiSet() { - super(new HashMap()); + super(new HashMap<>()); } /** @@ -77,7 +77,7 @@ public class HashMultiSet extends AbstractMapMultiSet implements Serializa */ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); - setMap(new HashMap()); + setMap(new HashMap<>()); super.doReadObject(in); } 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 6bbb6a1c8..8d539d5ef 100644 --- a/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java @@ -133,7 +133,7 @@ public class ListOrderedSet * @since 3.1 */ public ListOrderedSet() { - super(new HashSet()); + super(new HashSet<>()); setOrder = new ArrayList<>(); }