http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/list/CursorableLinkedListTest.java ---------------------------------------------------------------------- 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 3af4079..9a2b316 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<E> extends AbstractLinkedListTest<E> { @Override public void setUp() { - list = new CursorableLinkedList<E>(); + list = new CursorableLinkedList<>(); } @Override public CursorableLinkedList<E> makeObject() { - return new CursorableLinkedList<E>(); + return new CursorableLinkedList<>(); } @SuppressWarnings("unchecked") @@ -75,7 +75,7 @@ public class CursorableLinkedListTest<E> extends AbstractLinkedListTest<E> { list.add(7,(E) Integer.valueOf(5)); assertEquals("[-2, -1, 0, 1, 2, 3, 4, 5]",list.toString()); - final List<E> list2 = new LinkedList<E>(); + final List<E> list2 = new LinkedList<>(); list2.add((E) "A"); list2.add((E) "B"); list2.add((E) "C"); @@ -140,7 +140,7 @@ public class CursorableLinkedListTest<E> extends AbstractLinkedListTest<E> { @SuppressWarnings("unchecked") public void testContainsAll() { assertTrue(list.containsAll(list)); - final java.util.List<E> list2 = new java.util.LinkedList<E>(); + final java.util.List<E> list2 = new java.util.LinkedList<>(); assertTrue(list.containsAll(list2)); list2.add((E) "A"); assertTrue(!list.containsAll(list2)); @@ -836,11 +836,11 @@ public class CursorableLinkedListTest<E> extends AbstractLinkedListTest<E> { assertTrue(list.equals(list)); assertEquals(list.hashCode(),list.hashCode()); - final CursorableLinkedList<E> list2 = new CursorableLinkedList<E>(); + final CursorableLinkedList<E> list2 = new CursorableLinkedList<>(); assertTrue(!list.equals(list2)); assertTrue(!list2.equals(list)); - final java.util.List<E> list3 = new java.util.LinkedList<E>(); + final java.util.List<E> list3 = new java.util.LinkedList<>(); assertTrue(!list.equals(list3)); assertTrue(!list3.equals(list)); assertTrue(list2.equals(list3)); @@ -1178,7 +1178,7 @@ public class CursorableLinkedListTest<E> extends AbstractLinkedListTest<E> { list.add((E) "4"); list.add((E) "5"); - final HashSet<E> set = new HashSet<E>(); + final HashSet<E> set = new HashSet<>(); set.add((E) "A"); set.add((E) "2"); set.add((E) "C"); @@ -1260,7 +1260,7 @@ public class CursorableLinkedListTest<E> extends AbstractLinkedListTest<E> { list.add((E) "5"); list.add((E) "5"); - final HashSet<E> set = new HashSet<E>(); + final HashSet<E> set = new HashSet<>(); set.add((E) "A"); set.add((E) "2"); set.add((E) "C"); @@ -1501,7 +1501,7 @@ public class CursorableLinkedListTest<E> extends AbstractLinkedListTest<E> { */ @Override public String[] ignoredTests() { - final ArrayList<String> list = new ArrayList<String>(); + final ArrayList<String> list = new ArrayList<>(); final String prefix = "CursorableLinkedListTest"; final String bulk = ".bulkTestSubList"; final String[] ignored = new String[] {
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/list/FixedSizeListTest.java ---------------------------------------------------------------------- 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 0b7996f..a93b806 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<E> extends AbstractListTest<E> { @Override public List<E> makeFullCollection() { - final List<E> list = new ArrayList<E>(); + final List<E> list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return FixedSizeList.fixedSizeList(list); } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/list/GrowthListTest.java ---------------------------------------------------------------------- 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 38d68c4..da3fedd 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<E> extends AbstractListTest<E> { @Override public List<E> makeObject() { - return new GrowthList<E>(); + return new GrowthList<>(); } @Override public List<E> makeFullCollection() { - final List<E> list = new ArrayList<E>(); + final List<E> list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return GrowthList.growthList(list); } @@ -48,7 +48,7 @@ public class GrowthListTest<E> extends AbstractListTest<E> { //----------------------------------------------------------------------- public void testGrowthAdd() { final Integer one = Integer.valueOf(1); - final GrowthList<Integer> grower = new GrowthList<Integer>(); + final GrowthList<Integer> grower = new GrowthList<>(); assertEquals(0, grower.size()); grower.add(1, one); assertEquals(2, grower.size()); @@ -59,10 +59,10 @@ public class GrowthListTest<E> extends AbstractListTest<E> { public void testGrowthAddAll() { final Integer one = Integer.valueOf(1); final Integer two = Integer.valueOf(2); - final Collection<Integer> coll = new ArrayList<Integer>(); + final Collection<Integer> coll = new ArrayList<>(); coll.add(one); coll.add(two); - final GrowthList<Integer> grower = new GrowthList<Integer>(); + final GrowthList<Integer> grower = new GrowthList<>(); assertEquals(0, grower.size()); grower.addAll(1, coll); assertEquals(3, grower.size()); @@ -73,7 +73,7 @@ public class GrowthListTest<E> extends AbstractListTest<E> { public void testGrowthSet1() { final Integer one = Integer.valueOf(1); - final GrowthList<Integer> grower = new GrowthList<Integer>(); + final GrowthList<Integer> grower = new GrowthList<>(); assertEquals(0, grower.size()); grower.set(1, one); assertEquals(2, grower.size()); @@ -83,7 +83,7 @@ public class GrowthListTest<E> extends AbstractListTest<E> { public void testGrowthSet2() { final Integer one = Integer.valueOf(1); - final GrowthList<Integer> grower = new GrowthList<Integer>(); + final GrowthList<Integer> grower = new GrowthList<>(); assertEquals(0, grower.size()); grower.set(0, one); assertEquals(1, grower.size()); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/list/NodeCachingLinkedListTest.java ---------------------------------------------------------------------- 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 cb62502..00c57d4 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<E> extends AbstractLinkedListTest<E> { //----------------------------------------------------------------------- @Override public NodeCachingLinkedList<E> makeObject() { - return new NodeCachingLinkedList<E>(); + return new NodeCachingLinkedList<>(); } @Override @@ -73,8 +73,8 @@ public class NodeCachingLinkedListTest<E> extends AbstractLinkedListTest<E> { //----------------------------------------------------------------------- public static void compareSpeed() { - final NodeCachingLinkedList<Object> ncll = new NodeCachingLinkedList<Object>(); - final LinkedList<Object> ll = new LinkedList<Object>(); + final NodeCachingLinkedList<Object> ncll = new NodeCachingLinkedList<>(); + final LinkedList<Object> ll = new LinkedList<>(); final Object o1 = new Object(); final Object o2 = new Object(); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/list/PredicatedListTest.java ---------------------------------------------------------------------- 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 8a5a6b7..0ecaf0d 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<E> extends AbstractListTest<E> { @SuppressWarnings("unchecked") public void testIllegalAddAll() { final List<E> list = makeTestList(); - final List<E> elements = new ArrayList<E>(); + final List<E> elements = new ArrayList<>(); elements.add((E) "one"); elements.add((E) "two"); elements.add((E) Integer.valueOf(3)); @@ -121,7 +121,7 @@ public class PredicatedListTest<E> extends AbstractListTest<E> { public void testLegalAddAll() { final List<E> list = makeTestList(); list.add((E) "zero"); - final List<E> elements = new ArrayList<E>(); + final List<E> elements = new ArrayList<>(); elements.add((E) "one"); elements.add((E) "two"); elements.add((E) "three"); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java ---------------------------------------------------------------------- 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 d57acbe..4b5edb2 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<E> extends AbstractListTest<E> { //----------------------------------------------------------------------- @Override public List<E> makeObject() { - return new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>()); + return new SetUniqueList<>(new ArrayList<E>(), new HashSet<E>()); } //----------------------------------------------------------------------- @@ -141,7 +141,7 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { public void testIntCollectionAddAll() { // make a SetUniqueList with one element - final List<Integer> list = new SetUniqueList<Integer>(new ArrayList<Integer>(), new HashSet<Integer>()); + final List<Integer> list = new SetUniqueList<>(new ArrayList<Integer>(), new HashSet<Integer>()); final Integer existingElement = Integer.valueOf(1); list.add(existingElement); @@ -210,7 +210,7 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { //----------------------------------------------------------------------- public void testFactory() { final Integer[] array = new Integer[] { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(1) }; - final ArrayList<Integer> list = new ArrayList<Integer>(Arrays.asList(array)); + final ArrayList<Integer> list = new ArrayList<>(Arrays.asList(array)); final SetUniqueList<Integer> lset = SetUniqueList.setUniqueList(list); assertEquals("Duplicate element was added.", 2, lset.size()); @@ -222,7 +222,7 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { @SuppressWarnings("unchecked") public void testAdd() { - final SetUniqueList<E> lset = new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>()); + final SetUniqueList<E> lset = new SetUniqueList<>(new ArrayList<E>(), new HashSet<E>()); // Duplicate element final E obj = (E) Integer.valueOf(1); @@ -237,7 +237,7 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { @SuppressWarnings("unchecked") public void testAddAll() { - final SetUniqueList<E> lset = new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>()); + final SetUniqueList<E> lset = new SetUniqueList<>(new ArrayList<E>(), new HashSet<E>()); lset.addAll( Arrays.asList((E[]) new Integer[] { Integer.valueOf(1), Integer.valueOf(1)})); @@ -247,7 +247,7 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { @SuppressWarnings("unchecked") public void testSet() { - final SetUniqueList<E> lset = new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>()); + final SetUniqueList<E> lset = new SetUniqueList<>(new ArrayList<E>(), new HashSet<E>()); // Duplicate element final E obj1 = (E) Integer.valueOf(1); @@ -286,7 +286,7 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { @SuppressWarnings("unchecked") public void testListIterator() { - final SetUniqueList<E> lset = new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>()); + final SetUniqueList<E> lset = new SetUniqueList<>(new ArrayList<E>(), new HashSet<E>()); final E obj1 = (E) Integer.valueOf(1); final E obj2 = (E) Integer.valueOf(2); @@ -346,9 +346,9 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { * set(0,b): [b]->a * So UniqList contains [b] and a is returned */ - final ArrayList<E> l = new ArrayList<E>(); - final HashSet<E> s = new HashSet<E>(); - final SetUniqueList<E> ul = new SetUniqueList<E>(l, s); + final ArrayList<E> l = new ArrayList<>(); + final HashSet<E> s = new HashSet<>(); + final SetUniqueList<E> ul = new SetUniqueList<>(l, s); final E a = (E) new Object(); final E b = (E) new Object(); @@ -375,9 +375,9 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { * set(0,b): [b,c]->a * So UniqList contains [b,c] and a is returned */ - final ArrayList<E> l = new ArrayList<E>(); - final HashSet<E> s = new HashSet<E>(); - final SetUniqueList<E> ul = new SetUniqueList<E>(l, s); + final ArrayList<E> l = new ArrayList<>(); + final HashSet<E> s = new HashSet<>(); + final SetUniqueList<E> ul = new SetUniqueList<>(l, s); final E a = (E) new Object(); final E b = (E) new Object(); @@ -411,9 +411,9 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { * set(1,a): [a,c]->b * So UniqList contains [a,c] and b is returned */ - final ArrayList<E> l = new ArrayList<E>(); - final HashSet<E> s = new HashSet<E>(); - final SetUniqueList<E> ul = new SetUniqueList<E>(l, s); + final ArrayList<E> l = new ArrayList<>(); + final HashSet<E> s = new HashSet<>(); + final SetUniqueList<E> 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<E> extends AbstractListTest<E> { } public void testCollections304() { - final List<String> list = new LinkedList<String>(); + final List<String> list = new LinkedList<>(); final SetUniqueList<String> decoratedList = SetUniqueList.setUniqueList(list); final String s1 = "Apple"; final String s2 = "Lemon"; @@ -474,7 +474,7 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { } @SuppressWarnings("unchecked") public void testCollections307() { - List<E> list = new ArrayList<E>(); + List<E> list = new ArrayList<>(); List<E> uniqueList = SetUniqueList.setUniqueList(list); final String hello = "Hello"; @@ -488,14 +488,14 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { assertFalse(subList.contains(world)); // passes assertFalse(subUniqueList.contains(world)); // fails - List<E> worldList = new ArrayList<E>(); + List<E> 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<E>(); + list = new ArrayList<>(); uniqueList = new SetUniqueList307(list, new java.util.TreeSet<E>()); uniqueList.add((E) hello); @@ -507,7 +507,7 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { assertFalse(subList.contains(world)); // passes assertFalse(subUniqueList.contains(world)); // fails - worldList = new ArrayList<E>(); + worldList = new ArrayList<>(); worldList.add((E) world); assertFalse(subList.contains("World")); // passes assertFalse(subUniqueList.contains("World")); // fails @@ -515,13 +515,13 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { @SuppressWarnings("unchecked") public void testRetainAll() { - final List<E> list = new ArrayList<E>(10); + final List<E> list = new ArrayList<>(10); final SetUniqueList<E> uniqueList = SetUniqueList.setUniqueList(list); for (int i = 0; i < 10; ++i) { uniqueList.add((E)Integer.valueOf(i)); } - final Collection<E> retained = new ArrayList<E>(5); + final Collection<E> 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<E> extends AbstractListTest<E> { @SuppressWarnings("unchecked") public void testRetainAllWithInitialList() { // initialized with empty list - final List<E> list = new ArrayList<E>(10); + final List<E> list = new ArrayList<>(10); for (int i = 0; i < 5; ++i) { list.add((E)Integer.valueOf(i)); } @@ -547,7 +547,7 @@ public class SetUniqueListTest<E> extends AbstractListTest<E> { uniqueList.add((E)Integer.valueOf(i)); } - final Collection<E> retained = new ArrayList<E>(5); + final Collection<E> 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<E> extends AbstractListTest<E> { } public void testSetCollections444() { - final SetUniqueList<Integer> lset = new SetUniqueList<Integer>(new ArrayList<Integer>(), new HashSet<Integer>()); + final SetUniqueList<Integer> lset = new SetUniqueList<>(new ArrayList<Integer>(), new HashSet<Integer>()); // Duplicate element final Integer obj1 = Integer.valueOf(1); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/list/TransformedListTest.java ---------------------------------------------------------------------- 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 719b680..97fb889 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<E> extends AbstractListTest<E> { @Override public List<E> makeConfirmedCollection() { - return new ArrayList<E>(); + return new ArrayList<>(); } @Override public List<E> makeConfirmedFullCollection() { - final List<E> list = new ArrayList<E>(); + final List<E> list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return list; } @@ -58,7 +58,7 @@ public class TransformedListTest<E> extends AbstractListTest<E> { @Override @SuppressWarnings("unchecked") public List<E> makeFullCollection() { - final List<E> list = new ArrayList<E>(); + final List<E> list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); return TransformedList.transformingList(list, (Transformer<E, E>) TransformedCollectionTest.NOOP_TRANSFORMER); } @@ -95,7 +95,7 @@ public class TransformedListTest<E> extends AbstractListTest<E> { it.add((E) "44"); assertEquals(Integer.valueOf(44), list.get(1)); - final List<E> adds = new ArrayList<E>(); + final List<E> adds = new ArrayList<>(); adds.add((E) "1"); adds.add((E) "2"); list.clear(); @@ -112,7 +112,7 @@ public class TransformedListTest<E> extends AbstractListTest<E> { } public void testTransformedList_decorateTransform() { - final List<Object> originalList = new ArrayList<Object>(); + final List<Object> originalList = new ArrayList<>(); final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; for (final Object el : els) { originalList.add(el); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/list/TreeListTest.java ---------------------------------------------------------------------- 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 9377d88..98bd96f 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<E> extends AbstractListTest<E> { //----------------------------------------------------------------------- @Override public TreeList<E> makeObject() { - return new TreeList<E>(); + return new TreeList<>(); } //----------------------------------------------------------------------- @@ -220,7 +220,7 @@ public class TreeListTest<E> extends AbstractListTest<E> { public void testBug35258() { final Object objectToRemove = Integer.valueOf(3); - final List<Integer> treelist = new TreeList<Integer>(); + final List<Integer> 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<E> extends AbstractListTest<E> { } public void testBugCollections447() { - final List<String> treeList = new TreeList<String>(); + final List<String> treeList = new TreeList<>(); treeList.add("A"); treeList.add("B"); treeList.add("C"); @@ -274,11 +274,11 @@ public class TreeListTest<E> extends AbstractListTest<E> { // when initializing the TreeList with another collection for (int size = 1; size < 1000; size++) { - List<Integer> other = new ArrayList<Integer>(size); + List<Integer> other = new ArrayList<>(size); for (int i = 0; i < size; i++) { other.add(i); } - TreeList<Integer> l = new TreeList<Integer>(other); + TreeList<Integer> l = new TreeList<>(other); ListIterator<Integer> it = l.listIterator(); int i = 0; while (it.hasNext()) { @@ -304,11 +304,11 @@ public class TreeListTest<E> extends AbstractListTest<E> { int size = 1000; for (int i = 0; i < 100; i++) { - List<Integer> other = new ArrayList<Integer>(size); + List<Integer> other = new ArrayList<>(size); for (int j = i; j < size; j++) { other.add(j); } - TreeList<Integer> l = new TreeList<Integer>(); + TreeList<Integer> l = new TreeList<>(); for (int j = 0; j < i; j++) { l.add(j); } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/list/UnmodifiableListTest.java ---------------------------------------------------------------------- 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 0e1fa5b..8265d23 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<E> extends AbstractListTest<E> { //----------------------------------------------------------------------- @Override public UnmodifiableList<E> makeObject() { - return new UnmodifiableList<E>(new ArrayList<E>()); + return new UnmodifiableList<>(new ArrayList<E>()); } @Override public UnmodifiableList<E> makeFullCollection() { - final ArrayList<E> list = new ArrayList<E>(); + final ArrayList<E> list = new ArrayList<>(); list.addAll(Arrays.asList(getFullElements())); - return new UnmodifiableList<E>(list); + return new UnmodifiableList<>(list); } @Override @@ -69,7 +69,7 @@ public class UnmodifiableListTest<E> extends AbstractListTest<E> { @SuppressWarnings("unchecked") protected void setupList() { list = makeFullCollection(); - array = new ArrayList<E>(); + array = new ArrayList<>(); array.add((E) Integer.valueOf(1)); } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java ---------------------------------------------------------------------- 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 59b7db1..1739a5f 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<K, V> extends AbstractObjectTest { @SuppressWarnings("unchecked") protected <E> List<E> getAsList(final Object[] o) { - final ArrayList<E> result = new ArrayList<E>(); + final ArrayList<E> result = new ArrayList<>(); for (final Object element : o) { result.add((E) element); } @@ -451,14 +451,14 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest { * @return a map that is known to be valid */ public Map<K, V> makeConfirmedMap() { - return new HashMap<K, V>(); + return new HashMap<>(); } /** * Creates a new Map Entry that is independent of the first and the map. */ public static <K, V> Map.Entry<K, V> cloneMapEntry(final Map.Entry<K, V> entry) { - final HashMap<K, V> map = new HashMap<K, V>(); + final HashMap<K, V> map = new HashMap<>(); map.put(entry.getKey(), entry.getValue()); return map.entrySet().iterator().next(); } @@ -1128,7 +1128,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest { resetFull(); final Set<Map.Entry<K, V>> entrySet = getMap().entrySet(); final Map.Entry<K, V> entry = entrySet.iterator().next(); - final HashMap<K, V> temp = new HashMap<K, V>(); + final HashMap<K, V> temp = new HashMap<>(); temp.put(entry.getKey(), (V) "A VERY DIFFERENT VALUE"); final Map.Entry<K, V> test = temp.entrySet().iterator().next(); assertEquals(false, entrySet.contains(test)); @@ -1175,7 +1175,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest { final Set<Map.Entry<K, V>> entrySet = getMap().entrySet(); final Map.Entry<K, V> entry = entrySet.iterator().next(); final K key = entry.getKey(); - final HashMap<K, V> temp = new HashMap<K, V>(); + final HashMap<K, V> temp = new HashMap<>(); temp.put(entry.getKey(), (V) "A VERY DIFFERENT VALUE"); final Map.Entry<K, V> test = temp.entrySet().iterator().next(); @@ -1405,7 +1405,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest { final Set<Map.Entry<K, V>> entrySet = getMap().entrySet(); for (int i = 0; i < sampleKeys.length; i++) { try { - entrySet.remove(new DefaultMapEntry<K, V>(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<K, V> extends AbstractObjectTest { return; } final Set<Map.Entry<K, V>> entrySet = getMap().entrySet(); - final HashSet<Map.Entry<K, V>> comparisonSet = new HashSet<Map.Entry<K, V>>(entrySet); + final HashSet<Map.Entry<K, V>> comparisonSet = new HashSet<>(entrySet); try { assertFalse(entrySet.removeAll(Collections.<Map.Entry<K, V>> emptySet())); } catch (final UnsupportedOperationException e) { @@ -1471,7 +1471,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest { return; } final Set<Map.Entry<K, V>> entrySet = getMap().entrySet(); - final HashSet<Map.Entry<K, V>> comparisonSet = new HashSet<Map.Entry<K, V>>(entrySet); + final HashSet<Map.Entry<K, V>> comparisonSet = new HashSet<>(entrySet); try { assertFalse(entrySet.retainAll(comparisonSet)); } catch (final UnsupportedOperationException e) { @@ -2011,7 +2011,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest { } public void verifyValues() { - final List<V> known = new ArrayList<V>(getConfirmed().values()); + final List<V> 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<K, V> extends AbstractObjectTest { // it will also not recover, as the value view is cached internally values = getMap().values(); - final List<V> test = new ArrayList<V>(values); + final List<V> test = new ArrayList<>(values); final int size = getConfirmed().size(); final boolean empty = getConfirmed().isEmpty(); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/AbstractOrderedMapTest.java ---------------------------------------------------------------------- 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 f6a6f63..0377383 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<K, V> extends AbstractIterableMapTe */ @Override public Map<K, V> makeConfirmedMap() { - return new TreeMap<K, V>(new NullComparator<K>()); + return new TreeMap<>(new NullComparator<K>()); } /** @@ -79,7 +79,7 @@ public abstract class AbstractOrderedMapTest<K, V> extends AbstractIterableMapTe @Override @SuppressWarnings("unchecked") public K[] getSampleKeys() { - final List<K> list = new ArrayList<K>(Arrays.asList(super.getSampleKeys())); + final List<K> list = new ArrayList<>(Arrays.asList(super.getSampleKeys())); Collections.sort(list, new NullComparator<K>()); return (K[]) list.toArray(); } @@ -164,7 +164,7 @@ public abstract class AbstractOrderedMapTest<K, V> extends AbstractIterableMapTe resetFull(); ordered = getMap(); - final List<K> list = new ArrayList<K>(confirmed.keySet()); + final List<K> list = new ArrayList<>(confirmed.keySet()); Collections.reverse(list); final Iterator<K> it = list.iterator(); K confirmedLast = it.next(); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java ---------------------------------------------------------------------- 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 9e603c3..8991a5f 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<K, V> extends AbstractMapTest<K, V> */ @Override public SortedMap<K, V> makeConfirmedMap() { - return new TreeMap<K, V>(); + return new TreeMap<>(); } //----------------------------------------------------------------------- @@ -99,22 +99,22 @@ public abstract class AbstractSortedMapTest<K, V> extends AbstractMapTest<K, V> //----------------------------------------------------------------------- public BulkTest bulkTestHeadMap() { - return new TestHeadMap<K, V>(this); + return new TestHeadMap<>(this); } public BulkTest bulkTestTailMap() { - return new TestTailMap<K, V>(this); + return new TestTailMap<>(this); } public BulkTest bulkTestSubMap() { - return new TestSubMap<K, V>(this); + return new TestSubMap<>(this); } public static abstract class TestViewMap <K, V> extends AbstractSortedMapTest<K, V> { protected final AbstractMapTest<K, V> main; - protected final List<K> subSortedKeys = new ArrayList<K>(); - protected final List<V> subSortedValues = new ArrayList<V>(); - protected final List<V> subSortedNewValues = new ArrayList<V>(); + protected final List<K> subSortedKeys = new ArrayList<>(); + protected final List<V> subSortedValues = new ArrayList<>(); + protected final List<V> subSortedNewValues = new ArrayList<>(); public TestViewMap(final String name, final AbstractMapTest<K, V> main) { super(name); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/CaseInsensitiveMapTest.java ---------------------------------------------------------------------- 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 9b06057..2d06e61 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<K, V> extends AbstractIterableMapTest<K, V> @Override public CaseInsensitiveMap<K, V> makeObject() { - return new CaseInsensitiveMap<K, V>(); + return new CaseInsensitiveMap<>(); } @Override @@ -80,13 +80,13 @@ public class CaseInsensitiveMapTest<K, V> extends AbstractIterableMapTest<K, V> } public void testPutAll() { - final Map<Object, String> map = new HashMap<Object, String>(); + final Map<Object, String> 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<Object, String> caseInsensitiveMap = new CaseInsensitiveMap<Object, String>(map); + final Map<Object, String> caseInsensitiveMap = new CaseInsensitiveMap<>(map); assertEquals(4, caseInsensitiveMap.size()); // ones collapsed final Set<Object> keys = caseInsensitiveMap.keySet(); assertTrue(keys.contains("one")); @@ -101,7 +101,7 @@ public class CaseInsensitiveMapTest<K, V> extends AbstractIterableMapTest<K, V> @SuppressWarnings("unchecked") public void testClone() { - final CaseInsensitiveMap<K, V> map = new CaseInsensitiveMap<K, V>(10); + final CaseInsensitiveMap<K, V> map = new CaseInsensitiveMap<>(10); map.put((K) "1", (V) "1"); final CaseInsensitiveMap<K, V> cloned = map.clone(); assertEquals(map.size(), cloned.size()); @@ -133,7 +133,7 @@ public class CaseInsensitiveMapTest<K, V> extends AbstractIterableMapTest<K, V> 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<String, String> map = new CaseInsensitiveMap<String, String>(); + final CaseInsensitiveMap<String, String> 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<K, V> extends AbstractIterableMapTest<K, V> * Test for <a href="https://issues.apache.org/jira/browse/COLLECTIONS-323">COLLECTIONS-323</a>. */ public void testInitialCapacityZero() { - final CaseInsensitiveMap<String,String> map = new CaseInsensitiveMap<String,String>(0); + final CaseInsensitiveMap<String,String> map = new CaseInsensitiveMap<>(0); assertEquals(1, map.data.length); } } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/CompositeMapTest.java ---------------------------------------------------------------------- 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 ecaafdc..f894169 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<K, V> extends AbstractIterableMapTest<K, V> { @Override public CompositeMap<K, V> makeObject() { - final CompositeMap<K, V> map = new CompositeMap<K, V>(); + final CompositeMap<K, V> map = new CompositeMap<>(); map.addComposited(new HashMap<K, V>()); map.setMutator( new EmptyMapMutator<K, V>() ); return map; @@ -51,7 +51,7 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> { @SuppressWarnings("unchecked") private Map<K, V> buildOne() { - final HashMap<K, V> map = new HashMap<K, V>(); + final HashMap<K, V> map = new HashMap<>(); map.put((K) "1", (V) "one"); map.put((K) "2", (V) "two"); return map; @@ -59,22 +59,22 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> { @SuppressWarnings("unchecked") public Map<K, V> buildTwo() { - final HashMap<K, V> map = new HashMap<K, V>(); + final HashMap<K, V> map = new HashMap<>(); map.put((K) "3", (V) "three"); map.put((K) "4", (V) "four"); return map; } public void testGet() { - final CompositeMap<K, V> map = new CompositeMap<K, V>(buildOne(), buildTwo()); + final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo()); assertEquals("one", map.get("1")); assertEquals("four", map.get("4")); } @SuppressWarnings("unchecked") public void testAddComposited() { - final CompositeMap<K, V> map = new CompositeMap<K, V>(buildOne(), buildTwo()); - final HashMap<K, V> three = new HashMap<K, V>(); + final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo()); + final HashMap<K, V> three = new HashMap<>(); three.put((K) "5", (V) "five"); map.addComposited(three); assertTrue(map.containsKey("5")); @@ -88,8 +88,8 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> { @SuppressWarnings("unchecked") public void testRemoveComposited() { - final CompositeMap<K, V> map = new CompositeMap<K, V>(buildOne(), buildTwo()); - final HashMap<K, V> three = new HashMap<K, V>(); + final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo()); + final HashMap<K, V> three = new HashMap<>(); three.put((K) "5", (V) "five"); map.addComposited(three); assertTrue(map.containsKey("5")); @@ -104,8 +104,8 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> { @SuppressWarnings("unchecked") public void testRemoveFromUnderlying() { - final CompositeMap<K, V> map = new CompositeMap<K, V>(buildOne(), buildTwo()); - final HashMap<K, V> three = new HashMap<K, V>(); + final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo()); + final HashMap<K, V> three = new HashMap<>(); three.put((K) "5", (V) "five"); map.addComposited(three); assertTrue(map.containsKey("5")); @@ -117,8 +117,8 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> { @SuppressWarnings("unchecked") public void testRemoveFromComposited() { - final CompositeMap<K, V> map = new CompositeMap<K, V>(buildOne(), buildTwo()); - final HashMap<K, V> three = new HashMap<K, V>(); + final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo()); + final HashMap<K, V> three = new HashMap<>(); three.put((K) "5", (V) "five"); map.addComposited(three); assertTrue(map.containsKey("5")); @@ -129,7 +129,7 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> { } public void testResolveCollision() { - final CompositeMap<K, V> map = new CompositeMap<K, V>(buildOne(), buildTwo(), + final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo(), new CompositeMap.MapMutator<K, V>() { private static final long serialVersionUID = 1L; @@ -159,7 +159,7 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> { @SuppressWarnings("unchecked") public void testPut() { - final CompositeMap<K, V> map = new CompositeMap<K, V>(buildOne(), buildTwo(), + final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo(), new CompositeMap.MapMutator<K, V>() { private static final long serialVersionUID = 1L; @Override @@ -188,7 +188,7 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> { } public void testPutAll() { - final CompositeMap<K, V> map = new CompositeMap<K, V>(buildOne(), buildTwo(), + final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo(), new CompositeMap.MapMutator<K, V>() { private static final long serialVersionUID = 1L; @Override http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/DefaultedMapTest.java ---------------------------------------------------------------------- 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 32321d2..44806d7 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<K, V> extends AbstractIterableMapTest<K, V> { @Override @SuppressWarnings("unchecked") public void testMapGet() { - final Map<K, V> map = new DefaultedMap<K, V>((V) "NULL"); + final Map<K, V> map = new DefaultedMap<>((V) "NULL"); assertEquals(0, map.size()); assertEquals(false, map.containsKey("NotInMap")); @@ -66,7 +66,7 @@ public class DefaultedMapTest<K, V> extends AbstractIterableMapTest<K, V> { @SuppressWarnings("unchecked") public void testMapGet2() { - final HashMap<K, V> base = new HashMap<K, V>(); + final HashMap<K, V> base = new HashMap<>(); final Map<K, V> map = DefaultedMap.defaultedMap(base, (V) "NULL"); assertEquals(0, map.size()); @@ -85,7 +85,7 @@ public class DefaultedMapTest<K, V> extends AbstractIterableMapTest<K, V> { @SuppressWarnings("unchecked") public void testMapGet3() { - final HashMap<K, V> base = new HashMap<K, V>(); + final HashMap<K, V> base = new HashMap<>(); final Map<K, V> map = DefaultedMap.defaultedMap(base, ConstantFactory.constantFactory((V) "NULL")); assertEquals(0, map.size()); @@ -104,7 +104,7 @@ public class DefaultedMapTest<K, V> extends AbstractIterableMapTest<K, V> { @SuppressWarnings("unchecked") public void testMapGet4() { - final HashMap<K, V> base = new HashMap<K, V>(); + final HashMap<K, V> base = new HashMap<>(); final Map<K, V> map = DefaultedMap.defaultedMap(base, new Transformer<K, V>() { @Override public V transform(final K input) { http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/FixedSizeMapTest.java ---------------------------------------------------------------------- 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 cb72ff2..937d36b 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<K, V> extends AbstractIterableMapTest<K, V> { @Override public IterableMap<K, V> makeFullMap() { - final Map<K, V> map = new HashMap<K, V>(); + final Map<K, V> map = new HashMap<>(); addSampleMappings(map); return FixedSizeMap.fixedSizeMap(map); } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/FixedSizeSortedMapTest.java ---------------------------------------------------------------------- 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 18a6686..0efa502 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<K, V> extends AbstractSortedMapTest<K, V> { @Override public SortedMap<K, V> makeFullMap() { - final SortedMap<K, V> map = new TreeMap<K, V>(); + final SortedMap<K, V> map = new TreeMap<>(); addSampleMappings(map); return FixedSizeSortedMap.fixedSizeSortedMap(map); } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/Flat3MapTest.java ---------------------------------------------------------------------- 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 2036304..a195994 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<K, V> extends AbstractIterableMapTest<K, V> { @Override public Flat3Map<K, V> makeObject() { - return new Flat3Map<K, V>(); + return new Flat3Map<>(); } //----------------------------------------------------------------------- @@ -410,7 +410,7 @@ public class Flat3MapTest<K, V> extends AbstractIterableMapTest<K, V> { // } public void testCollections261() { - final Flat3Map<Integer, Integer> m = new Flat3Map<Integer, Integer>(); + final Flat3Map<Integer, Integer> 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<K, V> extends AbstractIterableMapTest<K, V> { } public void testToString() { - final Flat3Map<Integer, Integer> m = new Flat3Map<Integer, Integer>(); + final Flat3Map<Integer, Integer> m = new Flat3Map<>(); final String string0 = m.toString(); assertNotNull(string0); m.put( Integer.valueOf(1), Integer.valueOf(1) ); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/HashedMapTest.java ---------------------------------------------------------------------- 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 884af5e..6dddcdd 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<K, V> extends AbstractIterableMapTest<K, V> { @Override public HashedMap<K, V> makeObject() { - return new HashedMap<K, V>(); + return new HashedMap<>(); } @Override @@ -47,7 +47,7 @@ public class HashedMapTest<K, V> extends AbstractIterableMapTest<K, V> { @SuppressWarnings("unchecked") public void testClone() { - final HashedMap<K, V> map = new HashedMap<K, V>(10); + final HashedMap<K, V> map = new HashedMap<>(10); map.put((K) "1", (V) "1"); final HashedMap<K, V> cloned = map.clone(); assertEquals(map.size(), cloned.size()); @@ -55,7 +55,7 @@ public class HashedMapTest<K, V> extends AbstractIterableMapTest<K, V> { } public void testInternalState() { - final HashedMap<K, V> map = new HashedMap<K, V>(42, 0.75f); + final HashedMap<K, V> 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<K, V> extends AbstractIterableMapTest<K, V> { * Test for <a href="https://issues.apache.org/jira/browse/COLLECTIONS-323">COLLECTIONS-323</a>. */ public void testInitialCapacityZero() { - final HashedMap<String,String> map = new HashedMap<String,String>(0); + final HashedMap<String,String> map = new HashedMap<>(0); assertEquals(1, map.data.length); } } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/IdentityMap.java ---------------------------------------------------------------------- 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 a1a7a03..54050e5 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<K, V> @Override protected IdentityEntry<K, V> createEntry(final HashEntry<K, V> next, final int hashCode, final K key, final V value) { - return new IdentityEntry<K, V>(next, hashCode, key, value); + return new IdentityEntry<>(next, hashCode, key, value); } //----------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java ---------------------------------------------------------------------- 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 798e385..69efa93 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<K, V> extends AbstractOrderedMapTest<K, V> { @Override public LRUMap<K, V> makeObject() { - return new LRUMap<K, V>(); + return new LRUMap<>(); } /** @@ -124,7 +124,7 @@ public class LRUMapTest<K, V> extends AbstractOrderedMapTest<K, V> { Iterator<K> kit; Iterator<V> vit; - final LRUMap<K, V> map = new LRUMap<K, V>(2); + final LRUMap<K, V> map = new LRUMap<>(2); assertEquals(0, map.size()); assertEquals(false, map.isFull()); assertEquals(2, map.maxSize()); @@ -188,7 +188,7 @@ public class LRUMapTest<K, V> extends AbstractOrderedMapTest<K, V> { resetFull(); ordered = getMap(); - final List<K> list = new ArrayList<K>(ordered.keySet()); + final List<K> list = new ArrayList<>(ordered.keySet()); final ResettableIterator<K> it = (ResettableIterator<K>) ordered.mapIterator(); assertSame(list.get(0), it.next()); assertSame(list.get(1), it.next()); @@ -322,7 +322,7 @@ public class LRUMapTest<K, V> extends AbstractOrderedMapTest<K, V> { @SuppressWarnings("unchecked") public void testClone() { - final LRUMap<K, V> map = new LRUMap<K, V>(10); + final LRUMap<K, V> map = new LRUMap<>(10); map.put((K) "1", (V) "1"); final Map<K, V> cloned = map.clone(); assertEquals(map.size(), cloned.size()); @@ -331,7 +331,7 @@ public class LRUMapTest<K, V> extends AbstractOrderedMapTest<K, V> { @SuppressWarnings("unchecked") public void testRemoveLRU() { - final MockLRUMapSubclass<K, String> map = new MockLRUMapSubclass<K, String>(2); + final MockLRUMapSubclass<K, String> map = new MockLRUMapSubclass<>(2); assertNull(map.entry); map.put((K) "A", "a"); assertNull(map.entry); @@ -372,7 +372,7 @@ public class LRUMapTest<K, V> extends AbstractOrderedMapTest<K, V> { @SuppressWarnings("unchecked") public void testRemoveLRUBlocksRemove() { - final MockLRUMapSubclassBlocksRemove<K, V> map = new MockLRUMapSubclassBlocksRemove<K, V>(2, false); + final MockLRUMapSubclassBlocksRemove<K, V> 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<K, V> extends AbstractOrderedMapTest<K, V> { @SuppressWarnings("unchecked") public void testRemoveLRUBlocksRemoveScan() { - final MockLRUMapSubclassBlocksRemove<K, V> map = new MockLRUMapSubclassBlocksRemove<K, V>(2, true); + final MockLRUMapSubclassBlocksRemove<K, V> 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<K, V> extends AbstractOrderedMapTest<K, V> { @SuppressWarnings("unchecked") public void testRemoveLRUFirstBlocksRemove() { - final MockLRUMapSubclassFirstBlocksRemove<K, V> map = new MockLRUMapSubclassFirstBlocksRemove<K, V>(2); + final MockLRUMapSubclassFirstBlocksRemove<K, V> 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<K, V> extends AbstractOrderedMapTest<K, V> { final SingleHashCode five = new SingleHashCode("5"); final SingleHashCode six = new SingleHashCode("6"); - final LRUMap<K, V> map = new LRUMap<K, V>(3, 1.0f); + final LRUMap<K, V> 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<K, V> extends AbstractOrderedMapTest<K, V> { final SingleHashCode two = new SingleHashCode("2"); final SingleHashCode three = new SingleHashCode("3"); - final LRUMap<K, V> map = new LRUMap<K, V>(3, 1.0f); + final LRUMap<K, V> 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<K, V> extends AbstractOrderedMapTest<K, V> { public void testSynchronizedRemoveFromMapIterator() throws InterruptedException { - final LRUMap<Object, Thread> map = new LRUMap<Object, Thread>(10000); + final LRUMap<Object, Thread> map = new LRUMap<>(10000); - final Map<Throwable, String> exceptions = new HashMap<Throwable, String>(); + final Map<Throwable, String> 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<K, V> extends AbstractOrderedMapTest<K, V> { public void testSynchronizedRemoveFromEntrySet() throws InterruptedException { - final Map<Object, Thread> map = new LRUMap<Object, Thread>(10000); + final Map<Object, Thread> map = new LRUMap<>(10000); - final Map<Throwable, String> exceptions = new HashMap<Throwable, String>(); + final Map<Throwable, String> 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<K, V> extends AbstractOrderedMapTest<K, V> { public void testSynchronizedRemoveFromKeySet() throws InterruptedException { - final Map<Object, Thread> map = new LRUMap<Object, Thread>(10000); + final Map<Object, Thread> map = new LRUMap<>(10000); - final Map<Throwable, String> exceptions = new HashMap<Throwable, String>(); + final Map<Throwable, String> 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<K, V> extends AbstractOrderedMapTest<K, V> { public void testSynchronizedRemoveFromValues() throws InterruptedException { - final Map<Object, Thread> map = new LRUMap<Object, Thread>(10000); + final Map<Object, Thread> map = new LRUMap<>(10000); - final Map<Throwable, String> exceptions = new HashMap<Throwable, String>(); + final Map<Throwable, String> exceptions = new HashMap<>(); final ThreadGroup tg = new ThreadGroup(getName()) { @Override public void uncaughtException(final Thread t, final Throwable e) { http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/LinkedMapTest.java ---------------------------------------------------------------------- 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 ea04eef..34879d4 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<K, V> extends AbstractOrderedMapTest<K, V> { @Override public LinkedMap<K, V> makeObject() { - return new LinkedMap<K, V>(); + return new LinkedMap<>(); } /** @@ -71,7 +71,7 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> { resetFull(); ordered = getMap(); - final List<K> list = new ArrayList<K>(ordered.keySet()); + final List<K> list = new ArrayList<>(ordered.keySet()); final ResettableIterator<K> it = (ResettableIterator<K>) ordered.mapIterator(); assertSame(list.get(0), it.next()); assertSame(list.get(1), it.next()); @@ -186,7 +186,7 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> { resetFull(); lm = getMap(); - final List<K> list = new ArrayList<K>(); + final List<K> list = new ArrayList<>(); for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext();) { list.add(it.next()); } @@ -214,7 +214,7 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> { lm.remove(lm.size()); } catch (final IndexOutOfBoundsException ex) {} - final List<K> list = new ArrayList<K>(); + final List<K> list = new ArrayList<>(); for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext();) { list.add(it.next()); } @@ -275,7 +275,7 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> { @SuppressWarnings("unchecked") public void testClone() { - final LinkedMap<K, V> map = new LinkedMap<K, V>(10); + final LinkedMap<K, V> map = new LinkedMap<>(10); map.put((K) "1", (V) "1"); final Map<K, V> cloned = map.clone(); assertEquals(map.size(), cloned.size()); @@ -301,7 +301,7 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> { * Test for <a href="https://issues.apache.org/jira/browse/COLLECTIONS-323">COLLECTIONS-323</a>. */ public void testInitialCapacityZero() { - final LinkedMap<String,String> map = new LinkedMap<String,String>(0); + final LinkedMap<String,String> map = new LinkedMap<>(0); assertEquals(1, map.data.length); } } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/ListOrderedMap2Test.java ---------------------------------------------------------------------- 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 87c7b79..26c1918 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<K, V> extends AbstractOrderedMapTest<K, V> { @Override public ListOrderedMap<K, V> makeObject() { - return new ListOrderedMap<K, V>(); + return new ListOrderedMap<>(); } /** @@ -114,7 +114,7 @@ public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> { resetFull(); lom = getMap(); - final List<K> list = new ArrayList<K>(); + final List<K> list = new ArrayList<>(); for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) { list.add(it.next()); } @@ -142,7 +142,7 @@ public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> { lom.remove(lom.size()); } catch (final IndexOutOfBoundsException ex) {} - final List<K> list = new ArrayList<K>(); + final List<K> list = new ArrayList<>(); for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) { list.add(it.next()); } http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java ---------------------------------------------------------------------- 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 6a0f75c..e24ff54 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<K, V> extends AbstractOrderedMapTest<K, V> { resetFull(); lom = getMap(); - final List<K> list = new ArrayList<K>(); + final List<K> list = new ArrayList<>(); for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) { list.add(it.next()); } @@ -173,7 +173,7 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> { lom.remove(lom.size()); } catch (final IndexOutOfBoundsException ex) {} - final List<K> list = new ArrayList<K>(); + final List<K> list = new ArrayList<>(); for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) { list.add(it.next()); } @@ -222,7 +222,7 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> { // put in a full map resetFull(); lom = getMap(); - final ListOrderedMap<K, V> lom2 = new ListOrderedMap<K, V>(); + final ListOrderedMap<K, V> lom2 = new ListOrderedMap<>(); lom2.putAll(lom); lom2.put(0, (K) "testInsert0", (V) "testInsert0v"); @@ -317,7 +317,7 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> { assertEquals("testInsert2v", lom.getValue(2)); // Create New Test Map and Add using putAll(int, Object, Object) - final Map<String, String> values = new ListOrderedMap<String, String>(); + final Map<String, String> values = new ListOrderedMap<>(); values.put("NewInsert0", "NewInsert0v"); values.put("NewInsert1", "NewInsert1v"); lom.putAll(1, values); @@ -341,7 +341,7 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> { lom.put((K) Integer.valueOf(i), (V) Boolean.TRUE); } - final Map<K, V> map = new TreeMap<K, V>(); + final Map<K, V> 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<K, V> extends AbstractOrderedMapTest<K, V> { public void testCOLLECTIONS_474_nullValues () { Object key1 = new Object(); Object key2 = new Object(); - HashMap<Object, Object> hmap = new HashMap<Object, Object>(); + HashMap<Object, Object> hmap = new HashMap<>(); hmap.put(key1, null); hmap.put(key2, null); assertEquals("Should have two elements", 2, hmap.size()); - ListOrderedMap<Object, Object> listMap = new ListOrderedMap<Object, Object>(); + ListOrderedMap<Object, Object> 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<K, V> extends AbstractOrderedMapTest<K, V> { public void testCOLLECTIONS_474_nonNullValues () { Object key1 = new Object(); Object key2 = new Object(); - HashMap<Object, Object> hmap = new HashMap<Object, Object>(); + HashMap<Object, Object> hmap = new HashMap<>(); hmap.put(key1, "1"); hmap.put(key2, "2"); assertEquals("Should have two elements", 2, hmap.size()); - ListOrderedMap<Object, Object> listMap = new ListOrderedMap<Object, Object>(); + ListOrderedMap<Object, Object> listMap = new ListOrderedMap<>(); listMap.put(key1, "3"); listMap.put(key2, "4"); assertEquals("Should have two elements", 2, listMap.size()); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/MultiKeyMapTest.java ---------------------------------------------------------------------- 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 f9c3c6e..ba16eb7 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<K, V> extends AbstractIterableMapTest<MultiKey<? ex @Override public MultiKeyMap<K, V> makeObject() { - return new MultiKeyMap<K, V>(); + return new MultiKeyMap<>(); } @Override @@ -61,18 +61,18 @@ public class MultiKeyMapTest<K, V> extends AbstractIterableMapTest<MultiKey<? ex @SuppressWarnings("unchecked") private MultiKey<K>[] getMultiKeyKeys() { return new MultiKey[] { - new MultiKey<Integer>(I1, I2), - new MultiKey<Integer>(I2, I3), - new MultiKey<Integer>(I3, I4), - new MultiKey<Integer>(I1, I1, I2), - new MultiKey<Integer>(I2, I3, I4), - new MultiKey<Integer>(I3, I7, I6), - new MultiKey<Integer>(I1, I1, I2, I3), - new MultiKey<Integer>(I2, I4, I5, I6), - new MultiKey<Integer>(I3, I6, I7, I8), - new MultiKey<Integer>(I1, I1, I2, I3, I4), - new MultiKey<Integer>(I2, I3, I4, I5, I6), - new MultiKey<Integer>(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<K, V> extends AbstractIterableMapTest<MultiKey<? ex @SuppressWarnings("unchecked") public MultiKey<K>[] getOtherKeys() { return new MultiKey[] { - new MultiKey<Integer>(I1, I7), - new MultiKey<Integer>(I1, I8), - new MultiKey<Integer>(I2, I4), - new MultiKey<Integer>(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<K, V> extends AbstractIterableMapTest<MultiKey<? ex final V[] values = getSampleValues(); for (int i = 0; i < keys.length; i++) { - final MultiKeyMap<K, V> multimap = new MultiKeyMap<K, V>(); + final MultiKeyMap<K, V> multimap = new MultiKeyMap<>(); final MultiKey<K> key = keys[i]; final V value = values[i]; @@ -255,7 +255,7 @@ public class MultiKeyMapTest<K, V> extends AbstractIterableMapTest<MultiKey<? ex assertEquals(1, multimap.size()); assertEquals(value, multimap.get(key.getKey(0), key.getKey(1))); assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1))); - assertEquals(true, multimap.containsKey(new MultiKey<K>(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<K, V> extends AbstractIterableMapTest<MultiKey<? ex assertEquals(1, multimap.size()); assertEquals(value, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2))); assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2))); - assertEquals(true, multimap.containsKey(new MultiKey<K>(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<K, V> extends AbstractIterableMapTest<MultiKey<? ex assertEquals(1, multimap.size()); assertEquals(value, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3))); assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3))); - assertEquals(true, multimap.containsKey(new MultiKey<K>(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<K, V> extends AbstractIterableMapTest<MultiKey<? ex assertEquals(1, multimap.size()); assertEquals(value, multimap.get(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4))); assertEquals(true, multimap.containsKey(key.getKey(0), key.getKey(1), key.getKey(2), key.getKey(3), key.getKey(4))); - assertEquals(true, multimap.containsKey(new MultiKey<K>(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<K, V> extends AbstractIterableMapTest<MultiKey<? ex } public void testMultiKeyPutWithNullKey() { - final MultiKeyMap<String, String> map = new MultiKeyMap<String, String>(); + final MultiKeyMap<String, String> 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<K, V> extends AbstractIterableMapTest<MultiKey<? ex //----------------------------------------------------------------------- @SuppressWarnings("unchecked") public void testClone() { - final MultiKeyMap<K, V> map = new MultiKeyMap<K, V>(); - map.put(new MultiKey<K>((K) I1, (K) I2), (V) "1-2"); + final MultiKeyMap<K, V> map = new MultiKeyMap<>(); + map.put(new MultiKey<>((K) I1, (K) I2), (V) "1-2"); final Map<MultiKey<? extends K>, V> cloned = map.clone(); assertEquals(map.size(), cloned.size()); - assertSame(map.get(new MultiKey<K>((K) I1, (K) I2)), cloned.get(new MultiKey<K>((K) I1, (K) I2))); + assertSame(map.get(new MultiKey<>((K) I1, (K) I2)), cloned.get(new MultiKey<>((K) I1, (K) I2))); } //----------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java ---------------------------------------------------------------------- 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 5b41505..2fb3a3d 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<K, V> extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testMultipleValues() { final MultiValueMap<K, V> map = createTestMap(HashSet.class); - final HashSet<V> expected = new HashSet<V>(); + final HashSet<V> expected = new HashSet<>(); expected.add((V) "uno"); expected.add((V) "un"); assertEquals(expected, map.get("one")); @@ -94,7 +94,7 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testValues() { final MultiValueMap<K, V> map = createTestMap(HashSet.class); - final HashSet<V> expected = new HashSet<V>(); + final HashSet<V> expected = new HashSet<>(); expected.add((V) "uno"); expected.add((V) "dos"); expected.add((V) "tres"); @@ -103,7 +103,7 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest { expected.add((V) "trois"); final Collection<Object> c = map.values(); assertEquals(6, c.size()); - assertEquals(expected, new HashSet<Object>(c)); + assertEquals(expected, new HashSet<>(c)); } @SuppressWarnings("unchecked") @@ -153,7 +153,7 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest { public void testIterator() { final MultiValueMap<K, V> map = createTestMap(); @SuppressWarnings("unchecked") - Collection<V> values = new ArrayList<V>((Collection<V>) map.values()); + Collection<V> values = new ArrayList<>((Collection<V>) map.values()); Iterator<Map.Entry<K, V>> iterator = map.iterator(); while (iterator.hasNext()) { Map.Entry<K, V> entry = iterator.next(); @@ -181,26 +181,26 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest { //----------------------------------------------------------------------- @SuppressWarnings("unchecked") public void testMapEquals() { - final MultiValueMap<K, V> one = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> one = new MultiValueMap<>(); final Integer value = Integer.valueOf(1); one.put((K) "One", value); one.removeMapping("One", value); - final MultiValueMap<K, V> two = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> two = new MultiValueMap<>(); assertEquals(two, one); } //----------------------------------------------------------------------- @SuppressWarnings("unchecked") public void testGetCollection() { - final MultiValueMap<K, V> map = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> map = new MultiValueMap<>(); map.put((K) "A", "AA"); assertSame(map.get("A"), map.getCollection("A")); } @SuppressWarnings("unchecked") public void testTotalSize() { - final MultiValueMap<K, V> map = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> map = new MultiValueMap<>(); assertEquals(0, map.totalSize()); map.put((K) "A", "AA"); assertEquals(1, map.totalSize()); @@ -218,7 +218,7 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testSize() { - final MultiValueMap<K, V> map = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> map = new MultiValueMap<>(); assertEquals(0, map.size()); map.put((K) "A", "AA"); assertEquals(1, map.size()); @@ -236,7 +236,7 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testSize_Key() { - final MultiValueMap<K, V> map = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> 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<K, V> extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testIterator_Key() { - final MultiValueMap<K, V> map = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> 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<K, V> extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testContainsValue_Key() { - final MultiValueMap<K, V> map = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> 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<K, V> extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testPutAll_Map1() { - final MultiMap<K, V> original = new MultiValueMap<K, V>(); + final MultiMap<K, V> original = new MultiValueMap<>(); original.put((K) "key", "object1"); original.put((K) "key", "object2"); - final MultiValueMap<K, V> test = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> test = new MultiValueMap<>(); test.put((K) "keyA", "objectA"); test.put((K) "key", "object0"); test.putAll(original); @@ -326,11 +326,11 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testPutAll_Map2() { - final Map<K, V> original = new HashMap<K, V>(); + final Map<K, V> original = new HashMap<>(); original.put((K) "keyX", (V) "object1"); original.put((K) "keyY", (V) "object2"); - final MultiValueMap<K, V> test = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> test = new MultiValueMap<>(); test.put((K) "keyA", "objectA"); test.put((K) "keyX", "object0"); test.putAll(original); @@ -348,7 +348,7 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testPutAll_KeyCollection() { - final MultiValueMap<K, V> map = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> map = new MultiValueMap<>(); Collection<V> coll = (Collection<V>) Arrays.asList("X", "Y", "Z"); assertEquals(true, map.putAll((K) "A", coll)); @@ -380,7 +380,7 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest { @SuppressWarnings("unchecked") public void testRemove_KeyItem() { - final MultiValueMap<K, V> map = new MultiValueMap<K, V>(); + final MultiValueMap<K, V> map = new MultiValueMap<>(); map.put((K) "A", "AA"); map.put((K) "A", "AB"); map.put((K) "A", "AC"); http://git-wip-us.apache.org/repos/asf/commons-collections/blob/eef8f1a0/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java ---------------------------------------------------------------------- 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 c78b744..a96c567 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<K, V> extends AbstractMapTest<K, V> { } private Map<Integer, String> makeDecoratedTestMap() { - final Map<Integer, String> m = new HashMap<Integer, String>(); + final Map<Integer, String> 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<Integer, String>(new TestExpirationPolicy(), m); + return new PassiveExpiringMap<>(new TestExpirationPolicy(), m); } @Override public Map<K, V> makeObject() { - return new PassiveExpiringMap<K, V>(); + return new PassiveExpiringMap<>(); } private Map<Integer, String> makeTestMap() { final Map<Integer, String> m = - new PassiveExpiringMap<Integer, String>(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<K, V> extends AbstractMapTest<K, V> { public void testConstructors() { try { final Map<String, String> map = null; - new PassiveExpiringMap<String, String>(map); + new PassiveExpiringMap<>(map); fail("constructor - exception should have been thrown."); } catch (final NullPointerException ex) { // success @@ -113,7 +113,7 @@ public class PassiveExpiringMapTest<K, V> extends AbstractMapTest<K, V> { try { final ExpirationPolicy<String, String> policy = null; - new PassiveExpiringMap<String, String>(policy); + new PassiveExpiringMap<>(policy); fail("constructor - exception should have been thrown."); } catch (final NullPointerException ex) { // success @@ -221,7 +221,7 @@ public class PassiveExpiringMapTest<K, V> extends AbstractMapTest<K, V> { public void testZeroTimeToLive() { // item should not be available - final PassiveExpiringMap<String, String> m = new PassiveExpiringMap<String, String>(0L); + final PassiveExpiringMap<String, String> m = new PassiveExpiringMap<>(0L); m.put("a", "b"); assertNull(m.get("a")); } @@ -229,9 +229,9 @@ public class PassiveExpiringMapTest<K, V> extends AbstractMapTest<K, V> { public void testExpiration() { validateExpiration(new PassiveExpiringMap<String, String>(500), 500); validateExpiration(new PassiveExpiringMap<String, String>(1000), 1000); - validateExpiration(new PassiveExpiringMap<String, String>( + validateExpiration(new PassiveExpiringMap<>( new PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<String, String>(500)), 500); - validateExpiration(new PassiveExpiringMap<String, String>( + validateExpiration(new PassiveExpiringMap<>( new PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<String, String>(1, TimeUnit.SECONDS)), 1000); }