From 992ab3c9f2855034f24ee3f7638f57126bc1cb93 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 11 Oct 2017 16:33:54 -0600 Subject: [PATCH] Revert "Use final for locals." This reverts commit 712ddb1e193967c27f5624485938e7de5d732c6b. --- .../commons/collections4/CollectionUtils.java | 2 +- .../commons/collections4/IterableUtils.java | 3 +- .../commons/collections4/ListUtils.java | 2 +- .../commons/collections4/MultiMapUtils.java | 6 +- .../collections4/bidimap/TreeBidiMap.java | 6 +- .../collection/PredicatedCollection.java | 2 +- .../iterators/PermutationIterator.java | 6 +- .../collections4/list/SetUniqueList.java | 2 +- .../multimap/AbstractListValuedMap.java | 8 +- .../multimap/AbstractMultiValuedMap.java | 28 +++---- .../multimap/AbstractSetValuedMap.java | 2 +- .../multimap/ArrayListValuedHashMap.java | 2 +- .../multimap/TransformedMultiValuedMap.java | 4 +- .../multiset/AbstractMapMultiSet.java | 4 +- .../multiset/AbstractMultiSet.java | 8 +- .../collections4/set/CompositeSet.java | 2 +- .../collections4/set/ListOrderedSet.java | 4 +- .../trie/AbstractPatriciaTrie.java | 10 +-- .../commons/collections4/BagUtilsTest.java | 16 ++-- .../collections4/CollectionUtilsTest.java | 42 +++++----- .../collections4/ComparatorUtilsTest.java | 18 ++-- .../collections4/FactoryUtilsTest.java | 2 +- .../collections4/FluentIterableTest.java | 82 +++++++++---------- .../collections4/IterableUtilsTest.java | 46 +++++------ .../collections4/IteratorUtilsTest.java | 10 +-- .../commons/collections4/ListUtilsTest.java | 18 ++-- .../commons/collections4/MapUtilsTest.java | 4 +- .../collections4/MultiMapUtilsTest.java | 36 ++++---- .../commons/collections4/QueueUtilsTest.java | 8 +- .../commons/collections4/SetUtilsTest.java | 24 +++--- .../collections4/TransformerUtilsTest.java | 4 +- .../commons/collections4/TrieUtilsTest.java | 2 +- .../bidimap/DualTreeBidiMap2Test.java | 2 +- .../collection/AbstractCollectionTest.java | 10 +-- .../PredicatedCollectionBuilderTest.java | 32 ++++---- .../TransformingComparatorTest.java | 6 +- .../iterators/BoundedIteratorTest.java | 62 +++++++------- .../iterators/IteratorEnumerationTest.java | 6 +- .../iterators/PeekingIteratorTest.java | 16 ++-- .../iterators/PermutationIteratorTest.java | 44 +++++----- .../iterators/PushbackIteratorTest.java | 8 +- .../iterators/SkippingIteratorTest.java | 52 ++++++------ .../iterators/ZippingIteratorTest.java | 2 +- .../collections4/list/AbstractListTest.java | 2 +- .../collections4/list/SetUniqueListTest.java | 4 +- .../collections4/list/TreeListTest.java | 22 ++--- .../collections4/map/AbstractMapTest.java | 4 +- .../map/AbstractSortedMapTest.java | 2 +- .../commons/collections4/map/LRUMapTest.java | 14 ++-- .../collections4/map/ListOrderedMapTest.java | 16 ++-- .../collections4/map/MultiValueMapTest.java | 19 ++--- .../map/PassiveExpiringMapTest.java | 2 +- .../multimap/AbstractMultiValuedMapTest.java | 70 ++++++++-------- .../multimap/ArrayListValuedHashMapTest.java | 14 ++-- .../multimap/HashSetValuedHashMapTest.java | 12 +-- .../TransformedMultiValuedMapTest.java | 6 +- .../UnmodifiableMultiValuedMapTest.java | 70 ++++++++-------- .../collections4/queue/AbstractQueueTest.java | 2 +- .../queue/CircularFifoQueueTest.java | 2 +- .../sequence/SequencesComparatorTest.java | 2 +- .../collections4/set/AbstractSetTest.java | 2 +- .../collections4/trie/PatriciaTrieTest.java | 16 ++-- 62 files changed, 464 insertions(+), 470 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/CollectionUtils.java b/src/main/java/org/apache/commons/collections4/CollectionUtils.java index 7a92bf18b..1b54be593 100644 --- a/src/main/java/org/apache/commons/collections4/CollectionUtils.java +++ b/src/main/java/org/apache/commons/collections4/CollectionUtils.java @@ -1245,7 +1245,7 @@ public class CollectionUtils { * @throws IllegalArgumentException if the object type is invalid */ public static Object get(final Object object, final int index) { - final int i = index; + int i = index; if (i < 0) { throw new IndexOutOfBoundsException("Index cannot be negative: " + i); } diff --git a/src/main/java/org/apache/commons/collections4/IterableUtils.java b/src/main/java/org/apache/commons/collections4/IterableUtils.java index 9a9dae8d8..15e50c244 100644 --- a/src/main/java/org/apache/commons/collections4/IterableUtils.java +++ b/src/main/java/org/apache/commons/collections4/IterableUtils.java @@ -548,7 +548,6 @@ public class IterableUtils { @Override public Iterator iterator() { @SuppressWarnings("unchecked") // safe - final Iterator[] iterators = new Iterator[others.length + 1]; iterators[0] = first.iterator(); for (int i = 0; i < others.length; i++) { @@ -921,7 +920,7 @@ public class IterableUtils { throw new NullPointerException("Predicates must not be null."); } - for (final Predicate p : predicates) { + for (Predicate p : predicates) { if (p == null) { throw new NullPointerException("Predicate must not be null."); } diff --git a/src/main/java/org/apache/commons/collections4/ListUtils.java b/src/main/java/org/apache/commons/collections4/ListUtils.java index d61509401..c5fe81340 100644 --- a/src/main/java/org/apache/commons/collections4/ListUtils.java +++ b/src/main/java/org/apache/commons/collections4/ListUtils.java @@ -569,7 +569,7 @@ public class ListUtils { } final List lcs = longestCommonSubsequence(new CharSequenceAsList( a ), new CharSequenceAsList( b )); final StringBuilder sb = new StringBuilder(); - for ( final Character ch : lcs ) { + for ( Character ch : lcs ) { sb.append(ch); } return sb.toString(); diff --git a/src/main/java/org/apache/commons/collections4/MultiMapUtils.java b/src/main/java/org/apache/commons/collections4/MultiMapUtils.java index e523e1bf4..118f7e654 100644 --- a/src/main/java/org/apache/commons/collections4/MultiMapUtils.java +++ b/src/main/java/org/apache/commons/collections4/MultiMapUtils.java @@ -127,7 +127,7 @@ public class MultiMapUtils { */ public static List getValuesAsList(final MultiValuedMap map, final K key) { if (map != null) { - final Collection col = map.get(key); + Collection col = map.get(key); if (col instanceof List) { return (List) col; } @@ -147,7 +147,7 @@ public class MultiMapUtils { */ public static Set getValuesAsSet(final MultiValuedMap map, final K key) { if (map != null) { - final Collection col = map.get(key); + Collection col = map.get(key); if (col instanceof Set) { return (Set) col; } @@ -167,7 +167,7 @@ public class MultiMapUtils { */ public static Bag getValuesAsBag(final MultiValuedMap map, final K key) { if (map != null) { - final Collection col = map.get(key); + Collection col = map.get(key); if (col instanceof Bag) { return (Bag) col; } diff --git a/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java index 2a2042f62..1f48b9c73 100644 --- a/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java +++ b/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java @@ -1439,10 +1439,10 @@ public class TreeBidiMap, V extends Comparable> private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException{ stream.defaultReadObject(); rootNode = new Node[2]; - final int size = stream.readInt(); + int size = stream.readInt(); for(int i = 0; i < size; i++){ - final K k =(K) stream.readObject(); - final V v =(V) stream.readObject(); + K k =(K) stream.readObject(); + V v =(V) stream.readObject(); put(k, v); } } 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 2753964ef..3f14664fa 100644 --- a/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java +++ b/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java @@ -256,7 +256,7 @@ public class PredicatedCollection extends AbstractCollectionDecorator { */ public Builder addAll(final Collection items) { if (items != null) { - for (final E item : items) { + for (E item : items) { add(item); } } diff --git a/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java b/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java index 1b7caa6bf..c0c5fe832 100644 --- a/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java +++ b/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java @@ -82,7 +82,7 @@ public class PermutationIterator implements Iterator> { Arrays.fill(direction, false); int value = 1; objectMap = new HashMap<>(); - for (final E e : coll) { + for (E e : coll) { objectMap.put(Integer.valueOf(value), e); keys[value - 1] = value; value++; @@ -123,7 +123,7 @@ public class PermutationIterator implements Iterator> { } } if (largestKey == -1) { - final List toReturn = nextPermutation; + List toReturn = nextPermutation; nextPermutation = null; return toReturn; } @@ -133,7 +133,7 @@ public class PermutationIterator implements Iterator> { final int tmpKey = keys[indexOfLargestMobileInteger]; keys[indexOfLargestMobileInteger] = keys[indexOfLargestMobileInteger + offset]; keys[indexOfLargestMobileInteger + offset] = tmpKey; - final boolean tmpDirection = direction[indexOfLargestMobileInteger]; + boolean tmpDirection = direction[indexOfLargestMobileInteger]; direction[indexOfLargestMobileInteger] = direction[indexOfLargestMobileInteger + offset]; direction[indexOfLargestMobileInteger + offset] = tmpDirection; 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 8aa081516..3291145b3 100644 --- a/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java +++ b/src/main/java/org/apache/commons/collections4/list/SetUniqueList.java @@ -261,7 +261,7 @@ public class SetUniqueList extends AbstractSerializableListDecorator { */ @Override public boolean retainAll(final Collection coll) { - final boolean result = set.retainAll(coll); + boolean result = set.retainAll(coll); if (result == false) { return false; } diff --git a/src/main/java/org/apache/commons/collections4/multimap/AbstractListValuedMap.java b/src/main/java/org/apache/commons/collections4/multimap/AbstractListValuedMap.java index a41631f92..ffe6978b2 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/AbstractListValuedMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/AbstractListValuedMap.java @@ -130,7 +130,7 @@ public abstract class AbstractListValuedMap extends AbstractMultiValuedMap List list = getMapping(); if (list == null) { list = createCollection(); - final boolean changed = list.addAll(index, c); + boolean changed = list.addAll(index, c); if (changed) { getMap().put(key, list); } @@ -170,7 +170,7 @@ public abstract class AbstractListValuedMap extends AbstractMultiValuedMap @Override public V remove(final int index) { final List list = ListUtils.emptyIfNull(getMapping()); - final V value = list.remove(index); + V value = list.remove(index); if (list.isEmpty()) { AbstractListValuedMap.this.remove(key); } @@ -198,7 +198,7 @@ public abstract class AbstractListValuedMap extends AbstractMultiValuedMap if (!(other instanceof List)) { return false; } - final List otherList = (List) other; + List otherList = (List) other; return ListUtils.isEqualList(list, otherList); } @@ -232,7 +232,7 @@ public abstract class AbstractListValuedMap extends AbstractMultiValuedMap @Override public void add(final V value) { if (getMap().get(key) == null) { - final List list = createCollection(); + List list = createCollection(); getMap().put(key, list); this.values = list; this.iterator = list.listIterator(); diff --git a/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java b/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java index 2ca6611b9..892718549 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMap.java @@ -128,7 +128,7 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap coll = getMap().get(key); + Collection coll = getMap().get(key); return coll != null && coll.contains(value); } @@ -186,7 +186,7 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap implements MultiValuedMap entry : map.entrySet()) { + for (Map.Entry entry : map.entrySet()) { changed |= put(entry.getKey(), entry.getValue()); } return changed; @@ -309,7 +309,7 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap entry : map.entries()) { + for (Map.Entry entry : map.entries()) { changed |= put(entry.getKey(), entry.getValue()); } return changed; @@ -353,10 +353,10 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap) { - final Collection valueCollection = (Collection) values; + Collection valueCollection = (Collection) values; return !valueCollection.isEmpty() && get(key).addAll(valueCollection); } else { - final Iterator it = values.iterator(); + Iterator it = values.iterator(); return it.hasNext() && CollectionUtils.addAll(get(key), it); } } @@ -484,7 +484,7 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap implements MultiValuedMap implements MultiValuedMap implements MultiValuedMap col = AbstractMultiValuedMap.this.getMap().get(object); + Collection col = AbstractMultiValuedMap.this.getMap().get(object); if (col != null) { count = col.size(); } @@ -797,12 +797,11 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap get(final Object key) { - final Collection collection = decoratedMap.get(key); + Collection collection = decoratedMap.get(key); if (collection == null) { return null; } @SuppressWarnings("unchecked") - final K k = (K) key; return wrappedCollection(k); } @@ -819,7 +818,7 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap remove(final Object key) { - final Collection collection = decoratedMap.remove(key); + Collection collection = decoratedMap.remove(key); if (collection == null) { return null; } @@ -877,7 +876,7 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap entry = (Map.Entry) o; + Map.Entry entry = (Map.Entry) o; AbstractMultiValuedMap.this.remove(entry.getKey()); return true; } @@ -935,7 +934,6 @@ public abstract class AbstractMultiValuedMap implements MultiValuedMap extends AbstractMultiValuedMap< if (!(other instanceof Set)) { return false; } - final Set otherSet = (Set) other; + Set otherSet = (Set) other; return SetUtils.isEqualSet(set, otherSet); } diff --git a/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java b/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java index 1ffa6744d..74255e301 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java @@ -121,7 +121,7 @@ public class ArrayListValuedHashMap extends AbstractListValuedMap * Trims the capacity of all value collections to their current size. */ public void trimToSize() { - for (final Collection coll : getMap().values()) { + for (Collection coll : getMap().values()) { final ArrayList list = (ArrayList) coll; list.trimToSize(); } diff --git a/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java b/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java index 51cc86167..ed1e17af1 100644 --- a/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java +++ b/src/main/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMap.java @@ -169,7 +169,7 @@ public class TransformedMultiValuedMap extends AbstractMultiValuedMapDecor throw new NullPointerException("Map must not be null."); } boolean changed = false; - for (final Map.Entry entry : map.entrySet()) { + for (Map.Entry entry : map.entrySet()) { changed |= put(entry.getKey(), entry.getValue()); } return changed; @@ -181,7 +181,7 @@ public class TransformedMultiValuedMap extends AbstractMultiValuedMapDecor throw new NullPointerException("Map must not be null."); } boolean changed = false; - for (final Map.Entry entry : map.entries()) { + for (Map.Entry entry : map.entries()) { changed |= put(entry.getKey(), entry.getValue()); } return changed; diff --git a/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java index 27560fbf3..f6a0cd82b 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java @@ -220,7 +220,7 @@ public abstract class AbstractMapMultiSet extends AbstractMultiSet { } final MutableInteger mut = map.get(object); - final int oldCount = mut != null ? mut.value : 0; + int oldCount = mut != null ? mut.value : 0; if (occurrences > 0) { modCount++; @@ -255,7 +255,7 @@ public abstract class AbstractMapMultiSet extends AbstractMultiSet { if (mut == null) { return 0; } - final int oldCount = mut.value; + int oldCount = mut.value; if (occurrences > 0) { modCount++; if (occurrences < mut.value) { diff --git a/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java index d3561cd13..46624cc85 100644 --- a/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java +++ b/src/main/java/org/apache/commons/collections4/multiset/AbstractMultiSet.java @@ -58,7 +58,7 @@ public abstract class AbstractMultiSet extends AbstractCollection implemen @Override public int size() { int totalSize = 0; - for (final Entry entry : entrySet()) { + for (Entry entry : entrySet()) { totalSize += entry.getCount(); } return totalSize; @@ -73,7 +73,7 @@ public abstract class AbstractMultiSet extends AbstractCollection implemen */ @Override public int getCount(final Object object) { - for (final Entry entry : entrySet()) { + for (Entry entry : entrySet()) { final E element = entry.getElement(); if (element == object || element != null && element.equals(object)) { @@ -89,7 +89,7 @@ public abstract class AbstractMultiSet extends AbstractCollection implemen throw new IllegalArgumentException("Count must not be negative."); } - final int oldCount = getCount(object); + int oldCount = getCount(object); if (oldCount < count) { add(object, count - oldCount); } else { @@ -196,7 +196,7 @@ public abstract class AbstractMultiSet extends AbstractCollection implemen */ @Override public void clear() { - final Iterator> it = entrySet().iterator(); + Iterator> it = entrySet().iterator(); while (it.hasNext()) { it.next(); it.remove(); diff --git a/src/main/java/org/apache/commons/collections4/set/CompositeSet.java b/src/main/java/org/apache/commons/collections4/set/CompositeSet.java index 2aeef90af..104a179c6 100644 --- a/src/main/java/org/apache/commons/collections4/set/CompositeSet.java +++ b/src/main/java/org/apache/commons/collections4/set/CompositeSet.java @@ -387,7 +387,7 @@ public class CompositeSet implements Set, Serializable { * @param sets the Sets to be appended to the composite */ public void addComposited(final Set... sets) { - for (final Set set : sets) { + for (Set set : sets) { addComposited(set); } } 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 70758807d..65f7184a8 100644 --- a/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java @@ -235,14 +235,14 @@ public class ListOrderedSet */ @Override public boolean retainAll(final Collection coll) { - final boolean result = decorated().retainAll(coll); + boolean result = decorated().retainAll(coll); if (result == false) { return false; } if (decorated().size() == 0) { setOrder.clear(); } else { - for (final Iterator it = setOrder.iterator(); it.hasNext();) { + for (Iterator it = setOrder.iterator(); it.hasNext();) { if (!decorated().contains(it.next())) { it.remove(); } diff --git a/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java b/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java index 37da91e15..8508a9186 100644 --- a/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java +++ b/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java @@ -2260,8 +2260,8 @@ abstract class AbstractPatriciaTrie extends AbstractBitwiseTrie { @Override public void clear() { - final Iterator> it = AbstractPatriciaTrie.this.entrySet().iterator(); - final Set currentKeys = keySet(); + Iterator> it = AbstractPatriciaTrie.this.entrySet().iterator(); + Set currentKeys = keySet(); while (it.hasNext()) { if (currentKeys.contains(it.next().getKey())) { it.remove(); @@ -2427,10 +2427,10 @@ abstract class AbstractPatriciaTrie extends AbstractBitwiseTrie { private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException{ stream.defaultReadObject(); root = new TrieEntry<>(null, null, -1); - final int size = stream.readInt(); + int size = stream.readInt(); for(int i = 0; i < size; i++){ - final K k = (K) stream.readObject(); - final V v = (V) stream.readObject(); + K k = (K) stream.readObject(); + V v = (V) stream.readObject(); put(k, v); } } diff --git a/src/test/java/org/apache/commons/collections4/BagUtilsTest.java b/src/test/java/org/apache/commons/collections4/BagUtilsTest.java index caba27826..6d0f856b0 100644 --- a/src/test/java/org/apache/commons/collections4/BagUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/BagUtilsTest.java @@ -44,7 +44,7 @@ public class BagUtilsTest { @Test public void testSynchronizedBag() { - final Bag bag = BagUtils.synchronizedBag(new HashBag<>()); + Bag bag = BagUtils.synchronizedBag(new HashBag<>()); assertTrue("Returned object should be a SynchronizedBag.", bag instanceof SynchronizedBag); try { @@ -57,7 +57,7 @@ public class BagUtilsTest { @Test public void testUnmodifiableBag() { - final Bag bag = BagUtils.unmodifiableBag(new HashBag<>()); + Bag bag = BagUtils.unmodifiableBag(new HashBag<>()); assertTrue("Returned object should be an UnmodifiableBag.", bag instanceof UnmodifiableBag); try { @@ -72,7 +72,7 @@ public class BagUtilsTest { @Test public void testPredicatedBag() { - final Bag bag = BagUtils.predicatedBag(new HashBag<>(), truePredicate); + Bag bag = BagUtils.predicatedBag(new HashBag<>(), truePredicate); assertTrue("Returned object should be a PredicatedBag.", bag instanceof PredicatedBag); try { @@ -91,7 +91,7 @@ public class BagUtilsTest { @Test public void testTransformedBag() { - final Bag bag = BagUtils.transformingBag(new HashBag<>(), nopTransformer); + Bag bag = BagUtils.transformingBag(new HashBag<>(), nopTransformer); assertTrue("Returned object should be an TransformedBag.", bag instanceof TransformedBag); try { @@ -110,7 +110,7 @@ public class BagUtilsTest { @Test public void testSynchronizedSortedBag() { - final Bag bag = BagUtils.synchronizedSortedBag(new TreeBag<>()); + Bag bag = BagUtils.synchronizedSortedBag(new TreeBag<>()); assertTrue("Returned object should be a SynchronizedSortedBag.", bag instanceof SynchronizedSortedBag); try { @@ -123,7 +123,7 @@ public class BagUtilsTest { @Test public void testUnmodifiableSortedBag() { - final SortedBag bag = BagUtils.unmodifiableSortedBag(new TreeBag<>()); + SortedBag bag = BagUtils.unmodifiableSortedBag(new TreeBag<>()); assertTrue("Returned object should be an UnmodifiableSortedBag.", bag instanceof UnmodifiableSortedBag); try { @@ -138,7 +138,7 @@ public class BagUtilsTest { @Test public void testPredicatedSortedBag() { - final Bag bag = BagUtils.predicatedSortedBag(new TreeBag<>(), truePredicate); + Bag bag = BagUtils.predicatedSortedBag(new TreeBag<>(), truePredicate); assertTrue("Returned object should be a PredicatedSortedBag.", bag instanceof PredicatedSortedBag); try { @@ -157,7 +157,7 @@ public class BagUtilsTest { @Test public void testTransformedSortedBag() { - final Bag bag = BagUtils.transformingSortedBag(new TreeBag<>(), nopTransformer); + Bag bag = BagUtils.transformingSortedBag(new TreeBag<>(), nopTransformer); assertTrue("Returned object should be an TransformedSortedBag", bag instanceof TransformedSortedBag); try { diff --git a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java index 866a4fd16..60fc30cdc 100644 --- a/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java @@ -698,7 +698,7 @@ public class CollectionUtilsTest extends MockTestCase { lastElement = CollectionUtils.forAllButLastDo(col, testClosure); assertNull(lastElement); - final Collection strings = Arrays.asList("a", "b", "c"); + Collection strings = Arrays.asList("a", "b", "c"); final StringBuffer result = new StringBuffer(); result.append(CollectionUtils.forAllButLastDo(strings, new Closure() { @Override @@ -708,7 +708,7 @@ public class CollectionUtilsTest extends MockTestCase { })); assertEquals("a;b;c", result.toString()); - final Collection oneString = Arrays.asList("a"); + Collection oneString = Arrays.asList("a"); final StringBuffer resultOne = new StringBuffer(); resultOne.append(CollectionUtils.forAllButLastDo(oneString, new Closure() { @Override @@ -728,7 +728,7 @@ public class CollectionUtilsTest extends MockTestCase { final Collection> col = new ArrayList<>(); col.add(collectionA); col.add(collectionB); - final List lastElement = CollectionUtils.forAllButLastDo(col.iterator(), testClosure); + List lastElement = CollectionUtils.forAllButLastDo(col.iterator(), testClosure); assertSame(lastElement, collectionB); assertTrue(collectionA.isEmpty() && !collectionB.isEmpty()); @@ -1178,14 +1178,14 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void selectWithOutputCollections() { - final List input = new ArrayList<>(); + List input = new ArrayList<>(); input.add(1); input.add(2); input.add(3); input.add(4); - final List output = new ArrayList<>(); - final List rejected = new ArrayList<>(); + List output = new ArrayList<>(); + List rejected = new ArrayList<>(); CollectionUtils.select(input, EQUALS_TWO, output, rejected); @@ -1194,7 +1194,7 @@ public class CollectionUtilsTest extends MockTestCase { assertEquals(2, CollectionUtils.extractSingleton(output).intValue()); // rejected contains 1, 3, and 4 - final Integer[] expected = {1, 3, 4}; + Integer[] expected = {1, 3, 4}; Assert.assertArrayEquals(expected, rejected.toArray()); output.clear(); @@ -1330,7 +1330,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void predicatedCollection() { final Predicate predicate = PredicateUtils.instanceofPredicate(Integer.class); - final Collection collection = CollectionUtils.predicatedCollection(new ArrayList(), predicate); + Collection collection = CollectionUtils.predicatedCollection(new ArrayList(), predicate); assertTrue("returned object should be a PredicatedCollection", collection instanceof PredicatedCollection); try { CollectionUtils.predicatedCollection(new ArrayList(), null); @@ -1505,7 +1505,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testTransformedCollection() { final Transformer transformer = TransformerUtils.nopTransformer(); - final Collection collection = CollectionUtils.transformingCollection(new ArrayList<>(), transformer); + Collection collection = CollectionUtils.transformingCollection(new ArrayList<>(), transformer); assertTrue("returned object should be a TransformedCollection", collection instanceof TransformedCollection); try { CollectionUtils.transformingCollection(new ArrayList<>(), null); @@ -1536,7 +1536,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test @Deprecated public void testSynchronizedCollection() { - final Collection col = CollectionUtils.synchronizedCollection(new ArrayList<>()); + Collection col = CollectionUtils.synchronizedCollection(new ArrayList<>()); assertTrue("Returned object should be a SynchronizedCollection.", col instanceof SynchronizedCollection); try { CollectionUtils.synchronizedCollection(null); @@ -1549,7 +1549,7 @@ public class CollectionUtilsTest extends MockTestCase { @Test @Deprecated public void testUnmodifiableCollection() { - final Collection col = CollectionUtils.unmodifiableCollection(new ArrayList<>()); + Collection col = CollectionUtils.unmodifiableCollection(new ArrayList<>()); assertTrue("Returned object should be a UnmodifiableCollection.", col instanceof UnmodifiableCollection); try { CollectionUtils.unmodifiableCollection(null); @@ -1735,7 +1735,7 @@ public class CollectionUtilsTest extends MockTestCase { List result2 = CollectionUtils.collate(collectionE, collectionD); assertEquals("Merge two lists 1", result1, result2); - final List combinedList = new ArrayList<>(); + List combinedList = new ArrayList<>(); combinedList.addAll(collectionD); combinedList.addAll(collectionE); Collections.sort(combinedList); @@ -1760,14 +1760,14 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testCollateIgnoreDuplicates() { - final List result1 = CollectionUtils.collate(collectionD, collectionE, false); - final List result2 = CollectionUtils.collate(collectionE, collectionD, false); + List result1 = CollectionUtils.collate(collectionD, collectionE, false); + List result2 = CollectionUtils.collate(collectionE, collectionD, false); assertEquals("Merge two lists 1 - ignore duplicates", result1, result2); - final Set combinedSet = new HashSet<>(); + Set combinedSet = new HashSet<>(); combinedSet.addAll(collectionD); combinedSet.addAll(collectionE); - final List combinedList = new ArrayList<>(combinedSet); + List combinedList = new ArrayList<>(combinedSet); Collections.sort(combinedList); assertEquals("Merge two lists 2 - ignore duplicates", combinedList, result2); @@ -1780,11 +1780,11 @@ public class CollectionUtilsTest extends MockTestCase { @Test public void testPermutations() { - final List sample = collectionA.subList(0, 5); - final Collection> permutations = CollectionUtils.permutations(sample); + List sample = collectionA.subList(0, 5); + Collection> permutations = CollectionUtils.permutations(sample); // result size = n! - final int collSize = sample.size(); + int collSize = sample.size(); int factorial = 1; for (int i = 1; i <= collSize; i++) { factorial *= i; @@ -1798,7 +1798,7 @@ public class CollectionUtilsTest extends MockTestCase { assertFalse(CollectionUtils.matchesAll(null, null)); assertFalse(CollectionUtils.matchesAll(collectionA, null)); - final Predicate lessThanFive = new Predicate() { + Predicate lessThanFive = new Predicate() { @Override public boolean evaluate(final Integer object) { return object < 5; @@ -1806,7 +1806,7 @@ public class CollectionUtilsTest extends MockTestCase { }; assertTrue(CollectionUtils.matchesAll(collectionA, lessThanFive)); - final Predicate lessThanFour = new Predicate() { + Predicate lessThanFour = new Predicate() { @Override public boolean evaluate(final Integer object) { return object < 4; diff --git a/src/test/java/org/apache/commons/collections4/ComparatorUtilsTest.java b/src/test/java/org/apache/commons/collections4/ComparatorUtilsTest.java index a5aa3b72d..4c4b1a90f 100644 --- a/src/test/java/org/apache/commons/collections4/ComparatorUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/ComparatorUtilsTest.java @@ -46,7 +46,7 @@ public class ComparatorUtilsTest { @Test public void chainedComparator() { // simple test: chain 2 natural comparators - final Comparator comp = ComparatorUtils.chainedComparator(ComparatorUtils.naturalComparator(), + Comparator comp = ComparatorUtils.chainedComparator(ComparatorUtils.naturalComparator(), ComparatorUtils.naturalComparator()); assertTrue(comp.compare(1, 2) < 0); assertTrue(comp.compare(1, 1) == 0); @@ -55,7 +55,7 @@ public class ComparatorUtilsTest { @Test public void max() { - final Comparator reversed = + Comparator reversed = ComparatorUtils.reversedComparator(ComparatorUtils.naturalComparator()); assertEquals(Integer.valueOf(10), ComparatorUtils.max(1, 10, null)); @@ -67,21 +67,21 @@ public class ComparatorUtilsTest { try { ComparatorUtils.max(1, null, null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } try { ComparatorUtils.max(null, 10, null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @Test public void min() { - final Comparator reversed = + Comparator reversed = ComparatorUtils.reversedComparator(ComparatorUtils.naturalComparator()); assertEquals(Integer.valueOf(1), ComparatorUtils.min(1, 10, null)); @@ -93,21 +93,21 @@ public class ComparatorUtilsTest { try { ComparatorUtils.min(1, null, null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } try { ComparatorUtils.min(null, 10, null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @Test public void nullLowComparator() { - final Comparator comp = ComparatorUtils.nullLowComparator(null); + Comparator comp = ComparatorUtils.nullLowComparator(null); assertTrue(comp.compare(null, 10) < 0); assertTrue(comp.compare(null, null) == 0); assertTrue(comp.compare(10, null) > 0); @@ -115,7 +115,7 @@ public class ComparatorUtilsTest { @Test public void nullHighComparator() { - final Comparator comp = ComparatorUtils.nullHighComparator(null); + Comparator comp = ComparatorUtils.nullHighComparator(null); assertTrue(comp.compare(null, 10) > 0); assertTrue(comp.compare(null, null) == 0); assertTrue(comp.compare(10, null) < 0); diff --git a/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java b/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java index 5dcfcea1f..697caac18 100644 --- a/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java @@ -110,7 +110,7 @@ public class FactoryUtilsTest { @Test public void testPrototypeFactoryPublicCopyConstructor() throws Exception { final Mock1 proto = new Mock1(6); - final Factory factory = FactoryUtils.prototypeFactory(proto); + Factory factory = FactoryUtils.prototypeFactory(proto); assertNotNull(factory); final Object created = factory.create(); assertTrue(proto != created); diff --git a/src/test/java/org/apache/commons/collections4/FluentIterableTest.java b/src/test/java/org/apache/commons/collections4/FluentIterableTest.java index c1d9de0af..8c8addc87 100644 --- a/src/test/java/org/apache/commons/collections4/FluentIterableTest.java +++ b/src/test/java/org/apache/commons/collections4/FluentIterableTest.java @@ -71,7 +71,7 @@ public class FluentIterableTest { @Before public void setUp() { - final Collection collectionA = new ArrayList<>(); + Collection collectionA = new ArrayList<>(); collectionA.add(1); collectionA.add(2); collectionA.add(2); @@ -84,7 +84,7 @@ public class FluentIterableTest { collectionA.add(4); iterableA = collectionA; - final Collection collectionB = new LinkedList<>(); + Collection collectionB = new LinkedList<>(); collectionB.add(5L); collectionB.add(4L); collectionB.add(4L); @@ -129,14 +129,14 @@ public class FluentIterableTest { try { FluentIterable.of(it).toList(); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @Test public void appendElements() { - final FluentIterable it = FluentIterable.of(iterableA).append(10, 20, 30); + FluentIterable it = FluentIterable.of(iterableA).append(10, 20, 30); assertEquals(IterableUtils.size(iterableA) + 3, IterableUtils.size(it)); assertTrue(IterableUtils.contains(it, 1)); assertTrue(IterableUtils.contains(it, 10)); @@ -144,14 +144,14 @@ public class FluentIterableTest { assertTrue(IterableUtils.contains(it, 30)); assertFalse(IterableUtils.contains(it, 40)); - final FluentIterable empty = FluentIterable.of(emptyIterable).append(); + FluentIterable empty = FluentIterable.of(emptyIterable).append(); assertTrue(IterableUtils.isEmpty(empty)); } @Test public void appendIterable() { - final List listB = Arrays.asList(10, 20, 30); - final FluentIterable it = FluentIterable.of(iterableA).append(listB); + List listB = Arrays.asList(10, 20, 30); + FluentIterable it = FluentIterable.of(iterableA).append(listB); assertEquals(IterableUtils.size(iterableA) + listB.size(), IterableUtils.size(it)); assertTrue(IterableUtils.contains(it, 1)); assertTrue(IterableUtils.contains(it, 10)); @@ -162,8 +162,8 @@ public class FluentIterableTest { @Test public void collate() { - final List result = FluentIterable.of(iterableOdd).collate(iterableEven).toList(); - final List combinedList = new ArrayList<>(); + List result = FluentIterable.of(iterableOdd).collate(iterableEven).toList(); + List combinedList = new ArrayList<>(); CollectionUtils.addAll(combinedList, iterableOdd); CollectionUtils.addAll(combinedList, iterableEven); Collections.sort(combinedList); @@ -172,7 +172,7 @@ public class FluentIterableTest { try { FluentIterable.of(iterableOdd).collate(null).toList(); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -185,7 +185,7 @@ public class FluentIterableTest { .collate(iterableEven, ComparatorUtils.naturalComparator()) .toList(); - final List combinedList = new ArrayList<>(); + List combinedList = new ArrayList<>(); CollectionUtils.addAll(combinedList, iterableOdd); CollectionUtils.addAll(combinedList, iterableEven); Collections.sort(combinedList); @@ -198,7 +198,7 @@ public class FluentIterableTest { @Test public void filter() { - final Predicate smallerThan3 = new Predicate() { + Predicate smallerThan3 = new Predicate() { @Override public boolean evaluate(final Integer object) { return object.intValue() < 3; @@ -215,7 +215,7 @@ public class FluentIterableTest { try { FluentIterable.of(iterableA).filter(null).toList(); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -223,7 +223,7 @@ public class FluentIterableTest { @Test public void forEach() { final AtomicInteger sum = new AtomicInteger(0); - final Closure closure = new Closure() { + Closure closure = new Closure() { @Override public void execute(final Integer input) { sum.addAndGet(input); @@ -232,7 +232,7 @@ public class FluentIterableTest { FluentIterable.of(iterableA).forEach(closure); int expectedSum = 0; - for (final Integer i : iterableA) { + for (Integer i : iterableA) { expectedSum += i; } assertEquals(expectedSum, sum.get()); @@ -240,7 +240,7 @@ public class FluentIterableTest { try { FluentIterable.of(iterableA).forEach((Closure) null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -253,7 +253,7 @@ public class FluentIterableTest { // limit larger than input result = FluentIterable.of(iterableA).limit(100).toList(); - final List expected = IterableUtils.toList(iterableA); + List expected = IterableUtils.toList(iterableA); assertEquals(expected.size(), result.size()); assertEquals(expected, result); @@ -268,7 +268,7 @@ public class FluentIterableTest { try { FluentIterable.of(iterableA).limit(-2).toList(); fail("expecting IllegalArgumentException"); - } catch (final IllegalArgumentException iae) { + } catch (IllegalArgumentException iae) { // expected } } @@ -276,7 +276,7 @@ public class FluentIterableTest { @Test public void reverse() { List result = FluentIterable.of(iterableA).reverse().toList(); - final List expected = IterableUtils.toList(iterableA); + List expected = IterableUtils.toList(iterableA); Collections.reverse(expected); assertEquals(expected, result); @@ -297,7 +297,7 @@ public class FluentIterableTest { // skip 0 elements result = FluentIterable.of(iterableA).skip(0).toList(); - final List expected = IterableUtils.toList(iterableA); + List expected = IterableUtils.toList(iterableA); assertEquals(expected.size(), result.size()); assertEquals(expected, result); @@ -308,14 +308,14 @@ public class FluentIterableTest { try { FluentIterable.of(iterableA).skip(-4).toList(); fail("expecting IllegalArgumentException"); - } catch (final IllegalArgumentException iae) { + } catch (IllegalArgumentException iae) { // expected } } @Test public void transform() { - final Transformer squared = new Transformer() { + Transformer squared = new Transformer() { @Override public Integer transform(final Integer object) { return object * object; @@ -332,7 +332,7 @@ public class FluentIterableTest { try { FluentIterable.of(iterableA).transform(null).toList(); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -350,18 +350,18 @@ public class FluentIterableTest { @Test public void unmodifiable() { - final FluentIterable iterable1 = FluentIterable.of(iterableA).unmodifiable(); - final Iterator it = iterable1.iterator(); + FluentIterable iterable1 = FluentIterable.of(iterableA).unmodifiable(); + Iterator it = iterable1.iterator(); assertEquals(1, it.next().intValue()); try { it.remove(); fail("expecting UnsupportedOperationException"); - } catch (final UnsupportedOperationException ise) { + } catch (UnsupportedOperationException ise) { // expected } // calling unmodifiable on an already unmodifiable iterable shall return the same instance - final FluentIterable iterable2 = iterable1.unmodifiable(); + FluentIterable iterable2 = iterable1.unmodifiable(); assertSame(iterable1, iterable2); } @@ -378,7 +378,7 @@ public class FluentIterableTest { try { FluentIterable.of(iterableOdd).zip((Iterable) null).toList(); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } @@ -393,7 +393,7 @@ public class FluentIterableTest { @Test public void asEnumeration() { Enumeration enumeration = FluentIterable.of(iterableB).asEnumeration(); - final List result = EnumerationUtils.toList(enumeration); + List result = EnumerationUtils.toList(enumeration); assertEquals(iterableB, result); enumeration = FluentIterable.empty().asEnumeration(); @@ -409,7 +409,7 @@ public class FluentIterableTest { try { FluentIterable.of(iterableEven).allMatch(null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -423,7 +423,7 @@ public class FluentIterableTest { try { FluentIterable.of(iterableEven).anyMatch(null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -439,7 +439,7 @@ public class FluentIterableTest { try { FluentIterable.of((Iterable) null).size(); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } assertEquals(0, FluentIterable.of(emptyIterable).size()); @@ -448,10 +448,10 @@ public class FluentIterableTest { @Test public void eval() { - final List listNumbers = new ArrayList<>(); + List listNumbers = new ArrayList<>(); listNumbers.addAll(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); - final FluentIterable iterable = FluentIterable.of(listNumbers).filter(EVEN); - final FluentIterable materialized = iterable.eval(); + FluentIterable iterable = FluentIterable.of(listNumbers).filter(EVEN); + FluentIterable materialized = iterable.eval(); listNumbers.addAll(Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20)); assertEquals(5, materialized.size()); @@ -493,7 +493,7 @@ public class FluentIterableTest { try { FluentIterable.of(iterableA).copyInto(null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -514,14 +514,14 @@ public class FluentIterableTest { try { FluentIterable.of(iterableEven).get(-1); fail("expecting IndexOutOfBoundsException"); - } catch (final IndexOutOfBoundsException ioe) { + } catch (IndexOutOfBoundsException ioe) { // expected } try { FluentIterable.of(iterableEven).get(IterableUtils.size(iterableEven)); fail("expecting IndexOutOfBoundsException"); - } catch (final IndexOutOfBoundsException ioe) { + } catch (IndexOutOfBoundsException ioe) { // expected } } @@ -529,14 +529,14 @@ public class FluentIterableTest { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void toArray() { - final Long[] arr = new Long[] {1L, 2L, 3L, 4L, 5L}; - final Long[] result = FluentIterable.of(arr).toArray(Long.class); + Long[] arr = new Long[] {1L, 2L, 3L, 4L, 5L}; + Long[] result = FluentIterable.of(arr).toArray(Long.class); assertNotNull(result); assertArrayEquals(arr, result); try { FluentIterable.of(arr).toArray((Class) String.class); - } catch (final ArrayStoreException ase) { + } catch (ArrayStoreException ase) { // expected } } diff --git a/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java b/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java index f2538f24d..33f18fbdf 100644 --- a/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/IterableUtilsTest.java @@ -62,7 +62,7 @@ public class IterableUtilsTest { @Before public void setUp() { - final Collection collectionA = new ArrayList<>(); + Collection collectionA = new ArrayList<>(); collectionA.add(1); collectionA.add(2); collectionA.add(2); @@ -75,7 +75,7 @@ public class IterableUtilsTest { collectionA.add(4); iterableA = collectionA; - final Collection collectionB = new LinkedList<>(); + Collection collectionB = new LinkedList<>(); collectionB.add(5L); collectionB.add(4L); collectionB.add(4L); @@ -123,7 +123,7 @@ public class IterableUtilsTest { try { IterableUtils.forEach(col, null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } @@ -161,7 +161,7 @@ public class IterableUtilsTest { try { IterableUtils.forEachButLast(col, null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } @@ -228,8 +228,8 @@ public class IterableUtilsTest { // Ensure that generic bounds accept valid parameters, but return // expected results // e.g. no longs in the "int" Iterable, and vice versa. - final Iterable iterableIntAsNumber = Arrays.asList(1, 2, 3, 4, 5); - final Iterable iterableLongAsNumber = Arrays.asList(1L, 2L, 3L, 4L, 5L); + Iterable iterableIntAsNumber = Arrays.asList(1, 2, 3, 4, 5); + Iterable iterableLongAsNumber = Arrays.asList(1L, 2L, 3L, 4L, 5L); assertEquals(0, IterableUtils.frequency(iterableIntAsNumber, 2L)); assertEquals(0, IterableUtils.frequency(iterableLongAsNumber, 2)); @@ -316,14 +316,14 @@ public class IterableUtilsTest { try { assertEquals(0, IterableUtils.countMatches(iterableA, null)); fail("predicate must not be null"); - } catch (final NullPointerException ex) { + } catch (NullPointerException ex) { // expected } try { assertEquals(0, IterableUtils.countMatches(null, null)); fail("predicate must not be null"); - } catch (final NullPointerException ex) { + } catch (NullPointerException ex) { // expected } } @@ -335,14 +335,14 @@ public class IterableUtilsTest { try { assertFalse(IterableUtils.matchesAny(null, null)); fail("predicate must not be null"); - } catch (final NullPointerException ex) { + } catch (NullPointerException ex) { // expected } try { assertFalse(IterableUtils.matchesAny(list, null)); fail("predicate must not be null"); - } catch (final NullPointerException ex) { + } catch (NullPointerException ex) { // expected } @@ -362,18 +362,18 @@ public class IterableUtilsTest { try { assertFalse(IterableUtils.matchesAll(null, null)); fail("predicate must not be null"); - } catch (final NullPointerException ex) { + } catch (NullPointerException ex) { // expected } try { assertFalse(IterableUtils.matchesAll(iterableA, null)); fail("predicate must not be null"); - } catch (final NullPointerException ex) { + } catch (NullPointerException ex) { // expected } - final Predicate lessThanFive = new Predicate() { + Predicate lessThanFive = new Predicate() { @Override public boolean evaluate(final Integer object) { return object < 5; @@ -381,7 +381,7 @@ public class IterableUtilsTest { }; assertTrue(IterableUtils.matchesAll(iterableA, lessThanFive)); - final Predicate lessThanFour = new Predicate() { + Predicate lessThanFour = new Predicate() { @Override public boolean evaluate(final Integer object) { return object < 4; @@ -407,7 +407,7 @@ public class IterableUtilsTest { @SuppressWarnings("unchecked") @Test public void partition() { - final List input = new ArrayList<>(); + List input = new ArrayList<>(); input.add(1); input.add(2); input.add(3); @@ -421,7 +421,7 @@ public class IterableUtilsTest { assertEquals(2, CollectionUtils.extractSingleton(partition).intValue()); // second partition contains 1, 3, and 4 - final Integer[] expected = {1, 3, 4}; + Integer[] expected = {1, 3, 4}; partition = partitions.get(1); Assert.assertArrayEquals(expected, partition.toArray()); @@ -437,7 +437,7 @@ public class IterableUtilsTest { try { IterableUtils.partition(input, (Predicate) null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -445,12 +445,12 @@ public class IterableUtilsTest { @SuppressWarnings("unchecked") @Test public void partitionMultiplePredicates() { - final List input = new ArrayList<>(); + List input = new ArrayList<>(); input.add(1); input.add(2); input.add(3); input.add(4); - final List> partitions = IterableUtils.partition(input, EQUALS_TWO, EVEN); + List> partitions = IterableUtils.partition(input, EQUALS_TWO, EVEN); // first partition contains 2 Collection partition = partitions.get(0); @@ -463,13 +463,13 @@ public class IterableUtilsTest { assertEquals(4, partition.iterator().next().intValue()); // third partition contains 1 and 3 - final Integer[] expected = {1, 3}; + Integer[] expected = {1, 3}; partition = partitions.get(2); Assert.assertArrayEquals(expected, partition.toArray()); try { IterableUtils.partition(input, EQUALS_TWO, null); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -515,7 +515,7 @@ public class IterableUtilsTest { @Test public void testToStringDelimiter() { - final Transformer transformer = new Transformer() { + Transformer transformer = new Transformer() { @Override public String transform(final Integer input) { return new Integer(input * 2).toString(); @@ -552,7 +552,7 @@ public class IterableUtilsTest { @Test public void testToStringWithNullArguments() { - final String result = IterableUtils.toString(null, new Transformer() { + String result = IterableUtils.toString(null, new Transformer() { @Override public String transform(final Integer input) { fail("not supposed to reach here"); diff --git a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java index acf44dc06..d31ea02ad 100644 --- a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java @@ -960,14 +960,14 @@ public class IteratorUtilsTest { try { IteratorUtils.collatedIterator(null, collectionOdd.iterator(), null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } try { IteratorUtils.collatedIterator(null, null, collectionEven.iterator()); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } @@ -978,7 +978,7 @@ public class IteratorUtilsTest { List result = IteratorUtils.toList(it); assertEquals(12, result.size()); - final List combinedList = new ArrayList<>(); + List combinedList = new ArrayList<>(); combinedList.addAll(collectionOdd); combinedList.addAll(collectionEven); Collections.sort(combinedList); @@ -1021,7 +1021,7 @@ public class IteratorUtilsTest { try { IteratorUtils.forEach(col.iterator(), null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } @@ -1051,7 +1051,7 @@ public class IteratorUtilsTest { try { IteratorUtils.forEachButLast(col.iterator(), null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } diff --git a/src/test/java/org/apache/commons/collections4/ListUtilsTest.java b/src/test/java/org/apache/commons/collections4/ListUtilsTest.java index 69747b7cf..fee64600e 100644 --- a/src/test/java/org/apache/commons/collections4/ListUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/ListUtilsTest.java @@ -128,7 +128,7 @@ public class ListUtilsTest { return o instanceof String; } }; - final List list = ListUtils.predicatedList(new ArrayList<>(), predicate); + List list = ListUtils.predicatedList(new ArrayList<>(), predicate); assertTrue("returned object should be a PredicatedList", list instanceof PredicatedList); try { ListUtils.predicatedList(new ArrayList<>(), null); @@ -339,20 +339,20 @@ public class ListUtilsTest { List lcs = ListUtils.longestCommonSubsequence(Collections.EMPTY_LIST, Collections.EMPTY_LIST); assertEquals(0, lcs.size()); - final List list1 = Arrays.asList('B', 'A', 'N', 'A', 'N', 'A'); - final List list2 = Arrays.asList('A', 'N', 'A', 'N', 'A', 'S'); + List list1 = Arrays.asList('B', 'A', 'N', 'A', 'N', 'A'); + List list2 = Arrays.asList('A', 'N', 'A', 'N', 'A', 'S'); lcs = ListUtils.longestCommonSubsequence(list1, list2); List expected = Arrays.asList('A', 'N', 'A', 'N', 'A'); assertEquals(expected, lcs); - final List list3 = Arrays.asList('A', 'T', 'A', 'N', 'A'); + List list3 = Arrays.asList('A', 'T', 'A', 'N', 'A'); lcs = ListUtils.longestCommonSubsequence(list1, list3); expected = Arrays.asList('A', 'A', 'N', 'A'); assertEquals(expected, lcs); - final List listZorro = Arrays.asList('Z', 'O', 'R', 'R', 'O'); + List listZorro = Arrays.asList('Z', 'O', 'R', 'R', 'O'); lcs = ListUtils.longestCommonSubsequence(list1, listZorro); assertTrue(lcs.isEmpty()); @@ -379,18 +379,18 @@ public class ListUtilsTest { String lcs = ListUtils.longestCommonSubsequence("", ""); assertEquals(0, lcs.length()); - final String banana = "BANANA"; - final String ananas = "ANANAS"; + String banana = "BANANA"; + String ananas = "ANANAS"; lcs = ListUtils.longestCommonSubsequence(banana, ananas); assertEquals("ANANA", lcs); - final String atana = "ATANA"; + String atana = "ATANA"; lcs = ListUtils.longestCommonSubsequence(banana, atana); assertEquals("AANA", lcs); - final String zorro = "ZORRO"; + String zorro = "ZORRO"; lcs = ListUtils.longestCommonSubsequence(banana, zorro); assertEquals(0, lcs.length()); diff --git a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java index f0e24fcf5..e6b9b840e 100644 --- a/src/test/java/org/apache/commons/collections4/MapUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/MapUtilsTest.java @@ -65,7 +65,7 @@ public class MapUtilsTest { @Test public void testPredicatedMap() { final Predicate p = getPredicate(); - final Map map = MapUtils.predicatedMap(new HashMap<>(), p, p); + Map map = MapUtils.predicatedMap(new HashMap<>(), p, p); assertTrue("returned object should be a PredicatedMap", map instanceof PredicatedMap); try { MapUtils.predicatedMap(null, p, p); @@ -1142,7 +1142,7 @@ public class MapUtilsTest { final Map inMap = new HashMap(); inMap.put("key1", "value1"); inMap.put("key2", "value2"); - final Map map = MapUtils.orderedMap(inMap); + Map map = MapUtils.orderedMap(inMap); assertTrue("returned object should be a OrderedMap", map instanceof OrderedMap); } diff --git a/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java b/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java index 4806ba04c..4e145592f 100644 --- a/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java @@ -44,7 +44,7 @@ public class MultiMapUtilsTest { try { map.put("key", "value"); fail("Should throw UnsupportedOperationException"); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } } @@ -55,7 +55,7 @@ public class MultiMapUtilsTest { try { map.put("key", "value"); fail("Should throw UnsupportedOperationException"); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } } @@ -91,14 +91,14 @@ public class MultiMapUtilsTest { public void testGetCollection() { assertNull(MultiMapUtils.getCollection(null, "key1")); - final String values[] = { "v1", "v2", "v3" }; + String values[] = { "v1", "v2", "v3" }; final MultiValuedMap map = new ArrayListValuedHashMap<>(); - for (final String val : values) { + for (String val : values) { map.put("key1", val); } - final Collection col = MultiMapUtils.getCollection(map, "key1"); - for (final String val : values) { + Collection col = MultiMapUtils.getCollection(map, "key1"); + for (String val : values) { assertTrue(col.contains(val)); } } @@ -107,15 +107,15 @@ public class MultiMapUtilsTest { public void testGetValuesAsList() { assertNull(MultiMapUtils.getValuesAsList(null, "key1")); - final String values[] = { "v1", "v2", "v3" }; + String values[] = { "v1", "v2", "v3" }; final MultiValuedMap map = new ArrayListValuedHashMap<>(); - for (final String val : values) { + for (String val : values) { map.put("key1", val); } - final List list = MultiMapUtils.getValuesAsList(map, "key1"); + List list = MultiMapUtils.getValuesAsList(map, "key1"); int i = 0; - for (final String val : list) { + for (String val : list) { assertTrue(val.equals(values[i++])); } } @@ -124,16 +124,16 @@ public class MultiMapUtilsTest { public void testGetValuesAsSet() { assertNull(MultiMapUtils.getValuesAsList(null, "key1")); - final String values[] = { "v1", "v2", "v3" }; + String values[] = { "v1", "v2", "v3" }; final MultiValuedMap map = new ArrayListValuedHashMap<>(); - for (final String val : values) { + for (String val : values) { map.put("key1", val); map.put("key1", val); } - final Set set = MultiMapUtils.getValuesAsSet(map, "key1"); + Set set = MultiMapUtils.getValuesAsSet(map, "key1"); assertEquals(3, set.size()); - for (final String val : values) { + for (String val : values) { assertTrue(set.contains(val)); } } @@ -142,16 +142,16 @@ public class MultiMapUtilsTest { public void testGetValuesAsBag() { assertNull(MultiMapUtils.getValuesAsBag(null, "key1")); - final String values[] = { "v1", "v2", "v3" }; + String values[] = { "v1", "v2", "v3" }; final MultiValuedMap map = new ArrayListValuedHashMap<>(); - for (final String val : values) { + for (String val : values) { map.put("key1", val); map.put("key1", val); } - final Bag bag = MultiMapUtils.getValuesAsBag(map, "key1"); + Bag bag = MultiMapUtils.getValuesAsBag(map, "key1"); assertEquals(6, bag.size()); - for (final String val : values) { + for (String val : values) { assertTrue(bag.contains(val)); assertEquals(2, bag.getCount(val)); } diff --git a/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java b/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java index a3ba0b7b3..e4a3fa030 100644 --- a/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java @@ -40,7 +40,7 @@ public class QueueUtilsTest { @Test public void testUnmodifiableQueue() { - final Queue queue = QueueUtils.unmodifiableQueue(new LinkedList<>()); + Queue queue = QueueUtils.unmodifiableQueue(new LinkedList<>()); assertTrue("Returned object should be an UnmodifiableQueue.", queue instanceof UnmodifiableQueue); try { QueueUtils.unmodifiableQueue(null); @@ -54,7 +54,7 @@ public class QueueUtilsTest { @Test public void testPredicatedQueue() { - final Queue queue = QueueUtils.predicatedQueue(new LinkedList<>(), truePredicate); + Queue queue = QueueUtils.predicatedQueue(new LinkedList<>(), truePredicate); assertTrue("Returned object should be a PredicatedQueue.", queue instanceof PredicatedQueue); try { QueueUtils.predicatedQueue(null, truePredicate); @@ -72,7 +72,7 @@ public class QueueUtilsTest { @Test public void testTransformedQueue() { - final Queue queue = QueueUtils.transformingQueue(new LinkedList<>(), nopTransformer); + Queue queue = QueueUtils.transformingQueue(new LinkedList<>(), nopTransformer); assertTrue("Returned object should be an TransformedQueue.", queue instanceof TransformedQueue); try { QueueUtils.transformingQueue(null, nopTransformer); @@ -90,7 +90,7 @@ public class QueueUtilsTest { @Test public void testEmptyQueue() { - final Queue queue = QueueUtils.emptyQueue(); + Queue queue = QueueUtils.emptyQueue(); assertTrue("Returned object should be an UnmodifiableQueue.", queue instanceof UnmodifiableQueue); assertTrue("Returned queue is not empty.", queue.isEmpty()); diff --git a/src/test/java/org/apache/commons/collections4/SetUtilsTest.java b/src/test/java/org/apache/commons/collections4/SetUtilsTest.java index a743e2ede..bff420372 100644 --- a/src/test/java/org/apache/commons/collections4/SetUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/SetUtilsTest.java @@ -68,7 +68,7 @@ public class SetUtilsTest { return o instanceof String; } }; - final Set set = SetUtils.predicatedSet(new HashSet<>(), predicate); + Set set = SetUtils.predicatedSet(new HashSet<>(), predicate); assertTrue("returned object should be a PredicatedSet", set instanceof PredicatedSet); try { SetUtils.predicatedSet(new HashSet<>(), null); @@ -126,8 +126,8 @@ public class SetUtilsTest { @Test public void testNewIdentityHashSet() { - final Set set = SetUtils.newIdentityHashSet(); - final String a = new String("a"); + Set set = SetUtils.newIdentityHashSet(); + String a = new String("a"); set.add(a); set.add(new String("b")); set.add(a); @@ -154,14 +154,14 @@ public class SetUtilsTest { try { SetUtils.union(setA, null); fail("Expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } try { SetUtils.union(null, setA); fail("Expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -172,7 +172,7 @@ public class SetUtilsTest { assertEquals(2, set.size()); assertTrue(set.contains(1)); assertTrue(set.contains(2)); - for (final Integer i : setB) { + for (Integer i : setB) { assertFalse(set.contains(i)); } @@ -182,14 +182,14 @@ public class SetUtilsTest { try { SetUtils.difference(setA, null); fail("Expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } try { SetUtils.difference(null, setA); fail("Expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -212,14 +212,14 @@ public class SetUtilsTest { try { SetUtils.intersection(setA, null); fail("Expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } try { SetUtils.intersection(null, setA); fail("Expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } @@ -242,14 +242,14 @@ public class SetUtilsTest { try { SetUtils.disjunction(setA, null); fail("Expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } try { SetUtils.disjunction(null, setA); fail("Expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } } diff --git a/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java b/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java index 7f78a9516..13d881bc5 100644 --- a/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java @@ -247,7 +247,7 @@ public class TransformerUtilsTest { assertEquals("A", TransformerUtils.ifTransformer(TruePredicate.truePredicate(), a, b).transform(null)); assertEquals("B", TransformerUtils.ifTransformer(FalsePredicate.falsePredicate(), a, b).transform(null)); - final Predicate lessThanFivePredicate = new Predicate() { + Predicate lessThanFivePredicate = new Predicate() { @Override public boolean evaluate(final Integer value) { return value < 5; @@ -258,7 +258,7 @@ public class TransformerUtilsTest { assertEquals("B", TransformerUtils.ifTransformer(lessThanFivePredicate, a, b).transform(5)); // if tests - final Predicate equalsAPredicate = EqualPredicate.equalPredicate("A"); + Predicate equalsAPredicate = EqualPredicate.equalPredicate("A"); assertEquals("C", TransformerUtils.ifTransformer(equalsAPredicate, c).transform("A")); assertEquals("B", TransformerUtils.ifTransformer(equalsAPredicate, c).transform("B")); diff --git a/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java b/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java index f6a252660..21dd3354e 100644 --- a/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java +++ b/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java @@ -32,7 +32,7 @@ public class TrieUtilsTest { @Test public void testUnmodifiableTrie() { - final Trie trie = TrieUtils.unmodifiableTrie(new PatriciaTrie<>()); + Trie trie = TrieUtils.unmodifiableTrie(new PatriciaTrie<>()); assertTrue("Returned object should be an UnmodifiableTrie.", trie instanceof UnmodifiableTrie); try { diff --git a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java index d50cc7179..cc4f7aaa3 100644 --- a/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java +++ b/src/test/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap2Test.java @@ -153,7 +153,7 @@ public class DualTreeBidiMap2Test, V extends Comparable< */ @Override public String[] ignoredTests() { - final String recursiveTest = "DualTreeBidiMap2Test.bulkTestInverseMap.bulkTestInverseMap"; + String recursiveTest = "DualTreeBidiMap2Test.bulkTestInverseMap.bulkTestInverseMap"; if (IBMJDK16) { final String preSub = "DualTreeBidiMap2Test.bulkTestSubMap."; diff --git a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java index 5aaa5f6c9..6960043fd 100644 --- a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java @@ -671,7 +671,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { resetFull(); elements = getOtherElements(); - for (final Object element : elements) { + for (Object element : elements) { assertTrue("Full collection shouldn't contain element", !getCollection().contains(element)); } @@ -861,7 +861,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { resetEmpty(); final E[] elements = getFullElements(); - for (final E element : elements) { + for (E element : elements) { assertTrue("Shouldn't remove nonexistent element", !getCollection().remove(element)); verify(); } @@ -869,7 +869,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { final E[] other = getOtherElements(); resetFull(); - for (final E element : other) { + for (E element : other) { assertTrue("Shouldn't remove nonexistent other element", !getCollection().remove(element)); verify(); } @@ -939,7 +939,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { verify(); assertTrue("Collection should shrink after removeAll", getCollection().size() < size); - for (final E element : all) { + for (E element : all) { assertTrue("Collection shouldn't contain removed element", !getCollection().contains(element)); } } @@ -991,7 +991,7 @@ public abstract class AbstractCollectionTest extends AbstractObjectTest { getConfirmed().retainAll(elements.subList(min, max)); verify(); - for (final E element : getCollection()) { + for (E element : getCollection()) { assertTrue("Collection only contains retained element", elements.subList(min, max).contains(element)); } } diff --git a/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java b/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java index 12344c4ff..0c8c5a803 100644 --- a/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java +++ b/src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionBuilderTest.java @@ -39,7 +39,7 @@ public class PredicatedCollectionBuilderTest { */ @Test public void addPass() { - final PredicatedCollection.Builder builder = PredicatedCollection.notNullBuilder(); + PredicatedCollection.Builder builder = PredicatedCollection.notNullBuilder(); builder.add("test"); Assert.assertEquals(builder.createPredicatedList().size(), 1); } @@ -49,7 +49,7 @@ public class PredicatedCollectionBuilderTest { */ @Test public void addFail() { - final PredicatedCollection.Builder builder = PredicatedCollection.notNullBuilder(); + PredicatedCollection.Builder builder = PredicatedCollection.notNullBuilder(); builder.add((String) null); Assert.assertTrue(builder.createPredicatedList().isEmpty()); @@ -61,27 +61,27 @@ public class PredicatedCollectionBuilderTest { */ @Test public void addAllPass() { - final PredicatedCollection.Builder builder = PredicatedCollection.notNullBuilder(); + PredicatedCollection.Builder builder = PredicatedCollection.notNullBuilder(); builder.addAll(Arrays.asList("test1", null, "test2")); Assert.assertEquals(builder.createPredicatedList().size(), 2); } @Test public void createPredicatedCollectionWithNotNullPredicate() { - final PredicatedCollection.Builder builder = PredicatedCollection.notNullBuilder(); + PredicatedCollection.Builder builder = PredicatedCollection.notNullBuilder(); builder.add("test1"); builder.add((String) null); - final List predicatedList = builder.createPredicatedList(); + List predicatedList = builder.createPredicatedList(); checkPredicatedCollection1(predicatedList); - final Set predicatedSet = builder.createPredicatedSet(); + Set predicatedSet = builder.createPredicatedSet(); checkPredicatedCollection1(predicatedSet); - final Bag predicatedBag = builder.createPredicatedBag(); + Bag predicatedBag = builder.createPredicatedBag(); checkPredicatedCollection1(predicatedBag); - final Queue predicatedQueue = builder.createPredicatedQueue(); + Queue predicatedQueue = builder.createPredicatedQueue(); checkPredicatedCollection1(predicatedQueue); } @@ -94,30 +94,30 @@ public class PredicatedCollectionBuilderTest { try { collection.add(null); Assert.fail("Expecting IllegalArgumentException for failing predicate!"); - } catch (final IllegalArgumentException iae) { + } catch (IllegalArgumentException iae) { // expected } } @Test public void createPredicatedCollectionWithPredicate() { - final OddPredicate p = new OddPredicate(); - final PredicatedCollection.Builder builder = PredicatedCollection.builder(p); + OddPredicate p = new OddPredicate(); + PredicatedCollection.Builder builder = PredicatedCollection.builder(p); builder.add(1); builder.add(2); builder.add(3); - final List predicatedList = builder.createPredicatedList(); + List predicatedList = builder.createPredicatedList(); checkPredicatedCollection2(predicatedList); - final Set predicatedSet = builder.createPredicatedSet(); + Set predicatedSet = builder.createPredicatedSet(); checkPredicatedCollection2(predicatedSet); - final Bag predicatedBag = builder.createPredicatedBag(); + Bag predicatedBag = builder.createPredicatedBag(); checkPredicatedCollection2(predicatedBag); - final Queue predicatedQueue = builder.createPredicatedQueue(); + Queue predicatedQueue = builder.createPredicatedQueue(); checkPredicatedCollection2(predicatedQueue); } @@ -127,7 +127,7 @@ public class PredicatedCollectionBuilderTest { try { collection.add(4); Assert.fail("Expecting IllegalArgumentException for failing predicate!"); - } catch (final IllegalArgumentException iae) { + } catch (IllegalArgumentException iae) { } Assert.assertEquals(2, collection.size()); diff --git a/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java b/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java index 81d848119..11cbd2780 100644 --- a/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/comparators/TransformingComparatorTest.java @@ -61,9 +61,9 @@ public class TransformingComparatorTest extends AbstractComparatorTest } public void testEquals() { - final Transformer t1 = TransformerUtils.nopTransformer(); - final TransformingComparator comp1 = new TransformingComparator<>(t1); - final TransformingComparator comp2 = new TransformingComparator<>(t1, comp1); + Transformer t1 = TransformerUtils.nopTransformer(); + TransformingComparator comp1 = new TransformingComparator<>(t1); + TransformingComparator comp2 = new TransformingComparator<>(t1, comp1); // Checks the contract: equals-hashcode on comp1 and comp2 assertTrue("Contract failed: equals-hashcode", diff --git a/src/test/java/org/apache/commons/collections4/iterators/BoundedIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/BoundedIteratorTest.java index 7cf637280..0d868cb3c 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/BoundedIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/BoundedIteratorTest.java @@ -66,7 +66,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testBounded() { - final Iterator iter = new BoundedIterator<>(testList.iterator(), 2, 4); + Iterator iter = new BoundedIterator<>(testList.iterator(), 2, 4); assertTrue(iter.hasNext()); assertEquals("c", iter.next()); @@ -81,7 +81,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -92,7 +92,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testSameAsDecorated() { - final Iterator iter = new BoundedIterator<>(testList.iterator(), 0, + Iterator iter = new BoundedIterator<>(testList.iterator(), 0, testList.size()); assertTrue(iter.hasNext()); @@ -114,7 +114,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -125,12 +125,12 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testEmptyBounded() { - final Iterator iter = new BoundedIterator<>(testList.iterator(), 3, 0); + Iterator iter = new BoundedIterator<>(testList.iterator(), 3, 0); assertFalse(iter.hasNext()); try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -143,7 +143,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { try { new BoundedIterator<>(testList.iterator(), -1, 4); fail("Expected IllegalArgumentException."); - } catch (final IllegalArgumentException iae) { /* Success case */ + } catch (IllegalArgumentException iae) { /* Success case */ } } @@ -156,7 +156,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { try { new BoundedIterator<>(testList.iterator(), 3, -1); fail("Expected IllegalArgumentException."); - } catch (final IllegalArgumentException iae) { /* Success case */ + } catch (IllegalArgumentException iae) { /* Success case */ } } @@ -167,12 +167,12 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testOffsetGreaterThanSize() { - final Iterator iter = new BoundedIterator<>(testList.iterator(), 10, 4); + Iterator iter = new BoundedIterator<>(testList.iterator(), 10, 4); assertFalse(iter.hasNext()); try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -184,7 +184,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testMaxGreaterThanSize() { - final Iterator iter = new BoundedIterator<>(testList.iterator(), 1, 10); + Iterator iter = new BoundedIterator<>(testList.iterator(), 1, 10); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -203,7 +203,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -213,13 +213,13 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveWithoutCallingNext() { - final List testListCopy = new ArrayList<>(testList); - final Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); try { iter.remove(); fail("Expected IllegalStateException."); - } catch (final IllegalStateException ise) { /* Success case */ + } catch (IllegalStateException ise) { /* Success case */ } } @@ -229,8 +229,8 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveCalledTwice() { - final List testListCopy = new ArrayList<>(testList); - final Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -239,7 +239,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { try { iter.remove(); fail("Expected IllegalStateException."); - } catch (final IllegalStateException ise) { /* Success case */ + } catch (IllegalStateException ise) { /* Success case */ } } @@ -249,8 +249,8 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveFirst() { - final List testListCopy = new ArrayList<>(testList); - final Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -271,7 +271,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -281,8 +281,8 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveMiddle() { - final List testListCopy = new ArrayList<>(testList); - final Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -303,7 +303,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -313,8 +313,8 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveLast() { - final List testListCopy = new ArrayList<>(testList); - final Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new BoundedIterator<>(testListCopy.iterator(), 1, 5); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -331,7 +331,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } iter.remove(); @@ -341,7 +341,7 @@ public class BoundedIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -351,20 +351,20 @@ public class BoundedIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveUnsupported() { - final Iterator mockIterator = new AbstractIteratorDecorator(testList.iterator()) { + Iterator mockIterator = new AbstractIteratorDecorator(testList.iterator()) { @Override public void remove() { throw new UnsupportedOperationException(); } }; - final Iterator iter = new BoundedIterator<>(mockIterator, 1, 5); + Iterator iter = new BoundedIterator<>(mockIterator, 1, 5); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); try { iter.remove(); fail("Expected UnsupportedOperationException."); - } catch (final UnsupportedOperationException usoe) { /* Success case */ + } catch (UnsupportedOperationException usoe) { /* Success case */ } } } diff --git a/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java b/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java index 05aca000d..1f6005256 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/IteratorEnumerationTest.java @@ -30,8 +30,8 @@ import junit.framework.TestCase; public class IteratorEnumerationTest extends TestCase { public void testEnumeration() { - final Iterator iterator = Arrays.asList("a", "b", "c").iterator(); - final IteratorEnumeration enumeration = new IteratorEnumeration<>(iterator); + Iterator iterator = Arrays.asList("a", "b", "c").iterator(); + IteratorEnumeration enumeration = new IteratorEnumeration<>(iterator); assertEquals(iterator, enumeration.getIterator()); @@ -44,7 +44,7 @@ public class IteratorEnumerationTest extends TestCase { try { enumeration.nextElement(); fail("NoSuchElementException expected"); - } catch (final NoSuchElementException e) { + } catch (NoSuchElementException e) { // expected } } diff --git a/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java index 455d9d482..3876861cf 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/PeekingIteratorTest.java @@ -70,14 +70,14 @@ public class PeekingIteratorTest extends AbstractIteratorTest { @Test public void testEmpty() { - final Iterator it = makeEmptyIterator(); + Iterator it = makeEmptyIterator(); assertFalse(it.hasNext()); } @Test @SuppressWarnings("unchecked") public void testSinglePeek() { - final PeekingIterator it = makeObject(); + PeekingIterator it = makeObject(); assertEquals("a", it.peek()); assertEquals("a", it.element()); validate(it, (E[]) testArray); @@ -85,7 +85,7 @@ public class PeekingIteratorTest extends AbstractIteratorTest { @Test public void testMultiplePeek() { - final PeekingIterator it = makeObject(); + PeekingIterator it = makeObject(); assertEquals("a", it.peek()); assertEquals("a", it.peek()); assertEquals("a", it.next()); @@ -102,7 +102,7 @@ public class PeekingIteratorTest extends AbstractIteratorTest { @Test public void testIteratorExhausted() { - final PeekingIterator it = makeObject(); + PeekingIterator it = makeObject(); it.next(); it.next(); it.next(); @@ -112,14 +112,14 @@ public class PeekingIteratorTest extends AbstractIteratorTest { try { it.element(); fail(); - } catch (final NoSuchElementException e) { + } catch (NoSuchElementException e) { // expected } } @Test public void testIllegalRemove() { - final PeekingIterator it = makeObject(); + PeekingIterator it = makeObject(); it.next(); it.remove(); // supported @@ -129,13 +129,13 @@ public class PeekingIteratorTest extends AbstractIteratorTest { try { it.remove(); fail(); - } catch (final IllegalStateException e) { + } catch (IllegalStateException e) { // expected } } private void validate(final Iterator iter, final E... items) { - for (final E x : items) { + for (E x : items) { assertTrue(iter.hasNext()); assertEquals(x, iter.next()); } diff --git a/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java index 0cb9ba647..e8119f3f0 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/PermutationIteratorTest.java @@ -73,11 +73,11 @@ public class PermutationIteratorTest extends AbstractIteratorTest list = new ArrayList<>(); + List list = new ArrayList<>(); for (int j = 0; j < i; j++) { list.add(j); } - final Iterator> it = new PermutationIterator<>(list); + Iterator> it = new PermutationIterator<>(list); int count = 0; while (it.hasNext()) { it.next(); @@ -92,12 +92,12 @@ public class PermutationIteratorTest extends AbstractIteratorTest perm1 = new ArrayList<>(); - final List perm2 = new ArrayList<>(); - final List perm3 = new ArrayList<>(); - final List perm4 = new ArrayList<>(); - final List perm5 = new ArrayList<>(); - final List perm6 = new ArrayList<>(); + List perm1 = new ArrayList<>(); + List perm2 = new ArrayList<>(); + List perm3 = new ArrayList<>(); + List perm4 = new ArrayList<>(); + List perm5 = new ArrayList<>(); + List perm6 = new ArrayList<>(); perm1.add('A'); perm2.add('A'); @@ -120,11 +120,11 @@ public class PermutationIteratorTest extends AbstractIteratorTest> results = new ArrayList<>(); + List> results = new ArrayList<>(); - final PermutationIterator it = makeObject(); + PermutationIterator it = makeObject(); while (it.hasNext()) { - final List next = it.next(); + List next = it.next(); results.add(next); } //3! permutation for 3 elements @@ -141,12 +141,12 @@ public class PermutationIteratorTest extends AbstractIteratorTest> resultsList = new ArrayList<>(); - final Set> resultsSet = new HashSet<>(); + List> resultsList = new ArrayList<>(); + Set> resultsSet = new HashSet<>(); - final PermutationIterator it = makeObject(); + PermutationIterator it = makeObject(); while (it.hasNext()) { - final List permutation = it.next(); + List permutation = it.next(); resultsList.add(permutation); resultsSet.add(permutation); } @@ -156,24 +156,24 @@ public class PermutationIteratorTest extends AbstractIteratorTest> resultsList = new ArrayList<>(); + List> resultsList = new ArrayList<>(); - final PermutationIterator it = makeObject(); + PermutationIterator it = makeObject(); while (it.hasNext()) { - final List permutation = it.next(); + List permutation = it.next(); resultsList.add(permutation); } //asking for another permutation should throw an exception try { it.next(); fail(); - } catch (final NoSuchElementException e) { + } catch (NoSuchElementException e) { // expected } } public void testPermutatorHasMore() { - final PermutationIterator it = makeObject(); + PermutationIterator it = makeObject(); for (int i = 0; i < 6; i++) { assertTrue(it.hasNext()); it.next(); @@ -182,11 +182,11 @@ public class PermutationIteratorTest extends AbstractIteratorTest it = makeEmptyIterator(); + PermutationIterator it = makeEmptyIterator(); // there is one permutation for an empty set: 0! = 1 assertTrue(it.hasNext()); - final List nextPermutation = it.next(); + List nextPermutation = it.next(); assertEquals(0, nextPermutation.size()); assertFalse(it.hasNext()); diff --git a/src/test/java/org/apache/commons/collections4/iterators/PushbackIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/PushbackIteratorTest.java index ad30e8d99..3b7a9c0e0 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/PushbackIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/PushbackIteratorTest.java @@ -68,7 +68,7 @@ public class PushbackIteratorTest extends AbstractIteratorTest { @Test public void testNormalIteration() { - final PushbackIterator iter = makeObject(); + PushbackIterator iter = makeObject(); assertEquals("a", iter.next()); assertEquals("b", iter.next()); assertEquals("c", iter.next()); @@ -78,7 +78,7 @@ public class PushbackIteratorTest extends AbstractIteratorTest { @Test @SuppressWarnings("unchecked") public void testImmediatePushback() { - final PushbackIterator iter = makeObject(); + PushbackIterator iter = makeObject(); iter.pushback((E) "x"); assertEquals("x", iter.next()); assertEquals("a", iter.next()); @@ -88,7 +88,7 @@ public class PushbackIteratorTest extends AbstractIteratorTest { @Test @SuppressWarnings("unchecked") public void testDelayedPushback() { - final PushbackIterator iter = makeObject(); + PushbackIterator iter = makeObject(); assertEquals("a", iter.next()); iter.pushback((E) "x"); assertEquals("x", iter.next()); @@ -99,7 +99,7 @@ public class PushbackIteratorTest extends AbstractIteratorTest { @Test @SuppressWarnings("unchecked") public void testMultiplePushback() { - final PushbackIterator iter = makeObject(); + PushbackIterator iter = makeObject(); assertEquals("a", iter.next()); iter.pushback((E) "x"); iter.pushback((E) "y"); diff --git a/src/test/java/org/apache/commons/collections4/iterators/SkippingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/SkippingIteratorTest.java index c0ebf416d..052201ad6 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/SkippingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/SkippingIteratorTest.java @@ -66,7 +66,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testSkipping() { - final Iterator iter = new SkippingIterator<>(testList.iterator(), 2); + Iterator iter = new SkippingIterator<>(testList.iterator(), 2); assertTrue(iter.hasNext()); assertEquals("c", iter.next()); @@ -83,7 +83,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -94,7 +94,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testSameAsDecorated() { - final Iterator iter = new SkippingIterator<>(testList.iterator(), 0); + Iterator iter = new SkippingIterator<>(testList.iterator(), 0); assertTrue(iter.hasNext()); assertEquals("a", iter.next()); @@ -115,7 +115,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -126,12 +126,12 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testOffsetGreaterThanSize() { - final Iterator iter = new SkippingIterator<>(testList.iterator(), 10); + Iterator iter = new SkippingIterator<>(testList.iterator(), 10); assertFalse(iter.hasNext()); try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -144,7 +144,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { try { new SkippingIterator<>(testList.iterator(), -1); fail("Expected IllegalArgumentException."); - } catch (final IllegalArgumentException iae) { /* Success case */ + } catch (IllegalArgumentException iae) { /* Success case */ } } @@ -154,13 +154,13 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveWithoutCallingNext() { - final List testListCopy = new ArrayList<>(testList); - final Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 1); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 1); try { iter.remove(); fail("Expected IllegalStateException."); - } catch (final IllegalStateException ise) { /* Success case */ + } catch (IllegalStateException ise) { /* Success case */ } } @@ -170,8 +170,8 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveCalledTwice() { - final List testListCopy = new ArrayList<>(testList); - final Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 1); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 1); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); @@ -180,7 +180,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { try { iter.remove(); fail("Expected IllegalStateException."); - } catch (final IllegalStateException ise) { /* Success case */ + } catch (IllegalStateException ise) { /* Success case */ } } @@ -190,8 +190,8 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveFirst() { - final List testListCopy = new ArrayList<>(testList); - final Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 4); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 4); assertTrue(iter.hasNext()); assertEquals("e", iter.next()); @@ -208,7 +208,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -218,8 +218,8 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveMiddle() { - final List testListCopy = new ArrayList<>(testList); - final Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 3); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 3); assertTrue(iter.hasNext()); assertEquals("d", iter.next()); @@ -238,7 +238,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -248,8 +248,8 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveLast() { - final List testListCopy = new ArrayList<>(testList); - final Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 5); + List testListCopy = new ArrayList<>(testList); + Iterator iter = new SkippingIterator<>(testListCopy.iterator(), 5); assertTrue(iter.hasNext()); assertEquals("f", iter.next()); @@ -260,7 +260,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } iter.remove(); @@ -270,7 +270,7 @@ public class SkippingIteratorTest extends AbstractIteratorTest { try { iter.next(); fail("Expected NoSuchElementException."); - } catch (final NoSuchElementException nsee) { /* Success case */ + } catch (NoSuchElementException nsee) { /* Success case */ } } @@ -280,20 +280,20 @@ public class SkippingIteratorTest extends AbstractIteratorTest { */ @Test public void testRemoveUnsupported() { - final Iterator mockIterator = new AbstractIteratorDecorator(testList.iterator()) { + Iterator mockIterator = new AbstractIteratorDecorator(testList.iterator()) { @Override public void remove() { throw new UnsupportedOperationException(); } }; - final Iterator iter = new SkippingIterator<>(mockIterator, 1); + Iterator iter = new SkippingIterator<>(mockIterator, 1); assertTrue(iter.hasNext()); assertEquals("b", iter.next()); try { iter.remove(); fail("Expected UnsupportedOperationException."); - } catch (final UnsupportedOperationException usoe) { /* Success case */ + } catch (UnsupportedOperationException usoe) { /* Success case */ } } } diff --git a/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java index 59d3eb31b..104acf28e 100644 --- a/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java +++ b/src/test/java/org/apache/commons/collections4/iterators/ZippingIteratorTest.java @@ -100,7 +100,7 @@ public class ZippingIteratorTest extends AbstractIteratorTest { final ZippingIterator iter = new ZippingIterator<>(odds.iterator(), evens.iterator()); for (int i = 0, j = 0; i < 20; i++) { assertTrue(iter.hasNext()); - final int val = iter.next(); + int val = iter.next(); if (i % 2 == 0) { assertEquals(odds.get(j).intValue(), val); } else { diff --git a/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java b/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java index 5285674de..bb6741faa 100644 --- a/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java @@ -472,7 +472,7 @@ public abstract class AbstractListTest extends AbstractCollectionTest { final List list1 = getCollection(); final List list2 = getConfirmed(); - for (final E element : list2) { + for (E element : list2) { assertEquals("indexOf should return correct result", list1.indexOf(element), list2.indexOf(element)); verify(); 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 1207dc861..01b5e2fc7 100644 --- a/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java @@ -463,11 +463,11 @@ public class SetUniqueListTest extends AbstractListTest { public void testSubListIsUnmodifiable() { resetFull(); - final List subList = getCollection().subList(1, 3); + List subList = getCollection().subList(1, 3); try { subList.remove(0); fail("subList should be unmodifiable"); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { // expected } } 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 5b0dba903..b077b7a2a 100644 --- a/src/test/java/org/apache/commons/collections4/list/TreeListTest.java +++ b/src/test/java/org/apache/commons/collections4/list/TreeListTest.java @@ -273,20 +273,20 @@ public class TreeListTest extends AbstractListTest { // when initializing the TreeList with another collection for (int size = 1; size < 1000; size++) { - final List other = new ArrayList<>(size); + List other = new ArrayList<>(size); for (int i = 0; i < size; i++) { other.add(i); } - final TreeList l = new TreeList<>(other); - final ListIterator it = l.listIterator(); + TreeList l = new TreeList<>(other); + ListIterator it = l.listIterator(); int i = 0; while (it.hasNext()) { - final Integer val = it.next(); + Integer val = it.next(); assertEquals(i++, val.intValue()); } while (it.hasPrevious()) { - final Integer val = it.previous(); + Integer val = it.previous(); assertEquals(--i, val.intValue()); } } @@ -301,28 +301,28 @@ public class TreeListTest extends AbstractListTest { // to simulate different cases in addAll, do different runs where // the number of elements already in the list and being added by addAll differ - final int size = 1000; + int size = 1000; for (int i = 0; i < 100; i++) { - final List other = new ArrayList<>(size); + List other = new ArrayList<>(size); for (int j = i; j < size; j++) { other.add(j); } - final TreeList l = new TreeList<>(); + TreeList l = new TreeList<>(); for (int j = 0; j < i; j++) { l.add(j); } l.addAll(other); - final ListIterator it = l.listIterator(); + ListIterator it = l.listIterator(); int cnt = 0; while (it.hasNext()) { - final Integer val = it.next(); + Integer val = it.next(); assertEquals(cnt++, val.intValue()); } while (it.hasPrevious()) { - final Integer val = it.previous(); + Integer val = it.previous(); assertEquals(--cnt, val.intValue()); } } 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 50c09af92..ccd1fc3fb 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java @@ -624,14 +624,14 @@ public abstract class AbstractMapTest extends AbstractObjectTest { final Object[] keys = getSampleKeys(); resetEmpty(); - for (final Object key : keys) { + for (Object key : keys) { assertTrue("Map must not contain key when map is empty", !getMap().containsKey(key)); } verify(); resetFull(); - for (final Object key : keys) { + for (Object key : keys) { assertTrue("Map must contain key for a mapping in the map. " + "Missing: " + key, getMap().containsKey(key)); } 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 86a9bb93d..7a33ae409 100644 --- a/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/AbstractSortedMapTest.java @@ -90,7 +90,7 @@ public abstract class AbstractSortedMapTest extends AbstractMapTest public void testLastKey() { final SortedMap sm = makeFullMap(); K obj = null; - for (final K k : sm.keySet()) { + for (K k : sm.keySet()) { obj = k; } assertSame(obj, sm.lastKey()); 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 ff9fc1b2a..fb6ee9939 100644 --- a/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java @@ -74,42 +74,42 @@ public class LRUMapTest extends AbstractOrderedMapTest { try { new LRUMap(0); fail("maxSize must be positive"); - } catch(final IllegalArgumentException ex) { + } catch(IllegalArgumentException ex) { // expected } try { new LRUMap(-1, 12, 0.75f, false); fail("maxSize must be positive"); - } catch(final IllegalArgumentException ex) { + } catch(IllegalArgumentException ex) { // expected } try { new LRUMap(10, -1); fail("initialSize must not be negative"); - } catch(final IllegalArgumentException ex) { + } catch(IllegalArgumentException ex) { // expected } try { new LRUMap(10, 12); fail("initialSize must not be larger than maxSize"); - } catch(final IllegalArgumentException ex) { + } catch(IllegalArgumentException ex) { // expected } try { new LRUMap(10, -1, 0.75f, false); fail("initialSize must not be negative"); - } catch(final IllegalArgumentException ex) { + } catch(IllegalArgumentException ex) { // expected } try { new LRUMap(10, 12, 0.75f, false); fail("initialSize must not be larger than maxSize"); - } catch(final IllegalArgumentException ex) { + } catch(IllegalArgumentException ex) { // expected } } @@ -280,7 +280,7 @@ public class LRUMapTest extends AbstractOrderedMapTest { Iterator vit = null; resetEmpty(); - final LRUMap lruMap = (LRUMap) map; + LRUMap lruMap = (LRUMap) map; lruMap.put(keys[0], values[0]); lruMap.put(keys[1], values[1]); 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 b0238c6e6..a79227b40 100644 --- a/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/ListOrderedMapTest.java @@ -386,13 +386,13 @@ public class ListOrderedMapTest extends AbstractOrderedMapTest { } public void testCOLLECTIONS_474_nullValues () { - final Object key1 = new Object(); - final Object key2 = new Object(); - final HashMap hmap = new HashMap<>(); + Object key1 = new Object(); + Object key2 = new Object(); + HashMap hmap = new HashMap<>(); hmap.put(key1, null); hmap.put(key2, null); assertEquals("Should have two elements", 2, hmap.size()); - final ListOrderedMap listMap = new ListOrderedMap<>(); + ListOrderedMap listMap = new ListOrderedMap<>(); listMap.put(key1, null); listMap.put(key2, null); assertEquals("Should have two elements", 2, listMap.size()); @@ -400,13 +400,13 @@ public class ListOrderedMapTest extends AbstractOrderedMapTest { } public void testCOLLECTIONS_474_nonNullValues () { - final Object key1 = new Object(); - final Object key2 = new Object(); - final HashMap hmap = new HashMap<>(); + Object key1 = new Object(); + Object key2 = new Object(); + HashMap hmap = new HashMap<>(); hmap.put(key1, "1"); hmap.put(key2, "2"); assertEquals("Should have two elements", 2, hmap.size()); - final ListOrderedMap listMap = new ListOrderedMap<>(); + ListOrderedMap listMap = new ListOrderedMap<>(); listMap.put(key1, "3"); listMap.put(key2, "4"); assertEquals("Should have two elements", 2, listMap.size()); diff --git a/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java b/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java index 5f63f02fe..64310d389 100644 --- a/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/MultiValueMapTest.java @@ -152,11 +152,10 @@ public class MultiValueMapTest extends AbstractObjectTest { public void testIterator() { final MultiValueMap map = createTestMap(); @SuppressWarnings("unchecked") - final Collection values = new ArrayList<>((Collection) map.values()); - final Iterator> iterator = map.iterator(); + Iterator> iterator = map.iterator(); while (iterator.hasNext()) { - final Map.Entry entry = iterator.next(); + Map.Entry entry = iterator.next(); assertTrue(map.containsValue(entry.getKey(), entry.getValue())); assertTrue(values.contains(entry.getValue())); assertTrue(values.remove(entry.getValue())); @@ -393,24 +392,24 @@ public class MultiValueMapTest extends AbstractObjectTest { } public void testUnsafeDeSerialization() throws Exception { - final MultiValueMap map1 = MultiValueMap.multiValueMap(new HashMap(), ArrayList.class); + MultiValueMap map1 = MultiValueMap.multiValueMap(new HashMap(), ArrayList.class); byte[] bytes = serialize(map1); Object result = deserialize(bytes); assertEquals(map1, result); - final MultiValueMap map2 = MultiValueMap.multiValueMap(new HashMap(), (Class) String.class); + MultiValueMap map2 = MultiValueMap.multiValueMap(new HashMap(), (Class) String.class); bytes = serialize(map2); try { result = deserialize(bytes); fail("unsafe clazz accepted when de-serializing MultiValueMap"); - } catch (final UnsupportedOperationException ex) { + } catch (UnsupportedOperationException ex) { // expected } } private byte[] serialize(final Object object) throws IOException { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - final ObjectOutputStream oos = new ObjectOutputStream(baos); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(object); oos.close(); @@ -419,8 +418,8 @@ public class MultiValueMapTest extends AbstractObjectTest { } private Object deserialize(final byte[] data) throws IOException, ClassNotFoundException { - final ByteArrayInputStream bais = new ByteArrayInputStream(data); - final ObjectInputStream iis = new ObjectInputStream(bais); + ByteArrayInputStream bais = new ByteArrayInputStream(data); + ObjectInputStream iis = new ObjectInputStream(bais); return iis.readObject(); } 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 6e42b8469..8da6831ec 100644 --- a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java +++ b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java @@ -241,7 +241,7 @@ public class PassiveExpiringMapTest extends AbstractMapTest { try { Thread.sleep(2 * timeout); - } catch (final InterruptedException e) { + } catch (InterruptedException e) { fail(); } diff --git a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java index 78e8d175b..41d92f7ca 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java @@ -206,7 +206,6 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes public void testMultipleValues() { final MultiValuedMap map = makeFullMap(); @SuppressWarnings("unchecked") - final Collection col = map.get((K) "one"); assertTrue(col.contains("uno")); assertTrue(col.contains("un")); @@ -230,8 +229,8 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes } resetEmpty(); final MultiValuedMap map = getMap(); - final Collection col1 = map.get((K) "one"); - final Collection col2 = map.get((K) "one"); + Collection col1 = map.get((K) "one"); + Collection col2 = map.get((K) "one"); assertTrue(col1.isEmpty()); assertTrue(col2.isEmpty()); assertEquals(0, map.size()); @@ -276,7 +275,6 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes resetFull(); final MultiValuedMap map = getMap(); @SuppressWarnings("unchecked") - final Iterator it = map.get((K) "one").iterator(); while (it.hasNext()) { it.next(); @@ -288,7 +286,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes assertFalse(map.containsValue("uno")); assertFalse(map.containsValue("un")); assertEquals(4, map.size()); - final Collection coll = map.remove("one"); + Collection coll = map.remove("one"); assertNotNull(coll); assertEquals(0, coll.size()); } @@ -356,7 +354,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes return; } final MultiValuedMap map = makeFullMap(); - final Collection values = map.values(); + Collection values = map.values(); values.remove("uno"); values.remove("un"); assertFalse(map.containsKey("one")); @@ -390,10 +388,10 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes public void testEntriesCollectionIterator() { final MultiValuedMap map = makeFullMap(); - final Collection values = new ArrayList<>(map.values()); - final Iterator> iterator = map.entries().iterator(); + Collection values = new ArrayList<>(map.values()); + Iterator> iterator = map.entries().iterator(); while (iterator.hasNext()) { - final Map.Entry entry = iterator.next(); + Map.Entry entry = iterator.next(); assertTrue(map.containsMapping(entry.getKey(), entry.getValue())); assertTrue(values.contains(entry.getValue())); if (isRemoveSupported()) { @@ -598,7 +596,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes try { map.putAll((K) "A", null); fail("expecting NullPointerException"); - } catch (final NullPointerException npe) { + } catch (NullPointerException npe) { // expected } @@ -640,8 +638,8 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes } public void testKeysMultiSet() { - final MultiValuedMap map = makeFullMap(); - final MultiSet keyMultiSet = map.keys(); + MultiValuedMap map = makeFullMap(); + MultiSet keyMultiSet = map.keys(); assertEquals(2, keyMultiSet.getCount("one")); assertEquals(2, keyMultiSet.getCount("two")); assertEquals(2, keyMultiSet.getCount("three")); @@ -649,13 +647,13 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes } public void testKeysBagIterator() { - final MultiValuedMap map = makeFullMap(); - final Collection col = new ArrayList<>(); - final Iterator it = map.keys().iterator(); + MultiValuedMap map = makeFullMap(); + Collection col = new ArrayList<>(); + Iterator it = map.keys().iterator(); while (it.hasNext()) { col.add(it.next()); } - final Bag bag = new HashBag<>(col); + Bag bag = new HashBag<>(col); assertEquals(2, bag.getCount("one")); assertEquals(2, bag.getCount("two")); assertEquals(2, bag.getCount("three")); @@ -664,9 +662,9 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes @SuppressWarnings("unchecked") public void testKeysBagContainsAll() { - final MultiValuedMap map = makeFullMap(); - final MultiSet keyMultiSet = map.keys(); - final Collection col = (Collection) Arrays.asList("one", "two", "three", "one", "two", "three"); + MultiValuedMap map = makeFullMap(); + MultiSet keyMultiSet = map.keys(); + Collection col = (Collection) Arrays.asList("one", "two", "three", "one", "two", "three"); assertTrue(keyMultiSet.containsAll(col)); } @@ -678,7 +676,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes resetFull(); mapCol = getMap().asMap(); - final Collection col = mapCol.get("one"); + Collection col = mapCol.get("one"); assertNotNull(col); assertTrue(col.contains("un")); assertTrue(col.contains("uno")); @@ -689,7 +687,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes return; } resetFull(); - final Map> mapCol = getMap().asMap(); + Map> mapCol = getMap().asMap(); mapCol.remove("one"); assertFalse(getMap().containsKey("one")); assertEquals(4, getMap().size()); @@ -703,8 +701,8 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes resetFull(); mapIt = getMap().mapIterator(); while (mapIt.hasNext()) { - final K key = mapIt.next(); - final V value = mapIt.getValue(); + K key = mapIt.next(); + V value = mapIt.getValue(); assertTrue(getMap().containsMapping(key, value)); } } @@ -714,7 +712,7 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes return; } resetFull(); - final MapIterator mapIt = getMap().mapIterator(); + MapIterator mapIt = getMap().mapIterator(); while (mapIt.hasNext()) { mapIt.next(); mapIt.remove(); @@ -725,12 +723,12 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes @SuppressWarnings("unchecked") public void testMapIteratorUnsupportedSet() { resetFull(); - final MapIterator mapIt = getMap().mapIterator(); + MapIterator mapIt = getMap().mapIterator(); mapIt.next(); try { mapIt.setValue((V) "some value"); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } } @@ -1077,8 +1075,8 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes @Override @SuppressWarnings("unchecked") public K[] getSampleKeys() { - final K[] samplekeys = AbstractMultiValuedMapTest.this.getSampleKeys(); - final Object[] finalKeys = new Object[3]; + K[] samplekeys = AbstractMultiValuedMapTest.this.getSampleKeys(); + Object[] finalKeys = new Object[3]; for (int i = 0; i < 3; i++) { finalKeys[i] = samplekeys[i * 2]; } @@ -1088,11 +1086,11 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes @Override @SuppressWarnings("unchecked") public Collection[] getSampleValues() { - final boolean isSetValuedMap = AbstractMultiValuedMapTest.this.getMap() instanceof SetValuedMap; - final V[] sampleValues = AbstractMultiValuedMapTest.this.getSampleValues(); - final Collection[] colArr = new Collection[3]; + boolean isSetValuedMap = AbstractMultiValuedMapTest.this.getMap() instanceof SetValuedMap; + V[] sampleValues = AbstractMultiValuedMapTest.this.getSampleValues(); + Collection[] colArr = new Collection[3]; for(int i = 0; i < 3; i++) { - final Collection coll = Arrays.asList(sampleValues[i*2], sampleValues[i*2 + 1]); + Collection coll = Arrays.asList(sampleValues[i*2], sampleValues[i*2 + 1]); colArr[i] = isSetValuedMap ? new HashSet<>(coll) : coll; } return colArr; @@ -1101,11 +1099,11 @@ public abstract class AbstractMultiValuedMapTest extends AbstractObjectTes @Override @SuppressWarnings("unchecked") public Collection[] getNewSampleValues() { - final boolean isSetValuedMap = AbstractMultiValuedMapTest.this.getMap() instanceof SetValuedMap; - final Object[] sampleValues = { "ein", "ek", "zwei", "duey", "drei", "teen" }; - final Collection[] colArr = new Collection[3]; + boolean isSetValuedMap = AbstractMultiValuedMapTest.this.getMap() instanceof SetValuedMap; + Object[] sampleValues = { "ein", "ek", "zwei", "duey", "drei", "teen" }; + Collection[] colArr = new Collection[3]; for (int i = 0; i < 3; i++) { - final Collection coll = Arrays.asList((V) sampleValues[i * 2], (V) sampleValues[i * 2 + 1]); + Collection coll = Arrays.asList((V) sampleValues[i * 2], (V) sampleValues[i * 2 + 1]); colArr[i] = isSetValuedMap ? new HashSet<>(coll) : coll; } return colArr; diff --git a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java index 260947c5a..57b38f60f 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java @@ -51,7 +51,7 @@ public class ArrayListValuedHashMapTest extends AbstractMultiValuedMapTest public void testListValuedMapAdd() { final ListValuedMap listMap = makeObject(); assertTrue(listMap.get((K) "whatever") instanceof List); - final List list = listMap.get((K) "A"); + List list = listMap.get((K) "A"); list.add((V) "a1"); assertEquals(1, listMap.size()); assertTrue(listMap.containsKey("A")); @@ -60,7 +60,7 @@ public class ArrayListValuedHashMapTest extends AbstractMultiValuedMapTest @SuppressWarnings("unchecked") public void testListValuedMapAddViaListIterator() { final ListValuedMap listMap = makeObject(); - final ListIterator listIt = listMap.get((K) "B").listIterator(); + ListIterator listIt = listMap.get((K) "B").listIterator(); assertFalse(listIt.hasNext()); listIt.add((V) "b1"); listIt.add((V) "b2"); @@ -74,7 +74,7 @@ public class ArrayListValuedHashMapTest extends AbstractMultiValuedMapTest @SuppressWarnings("unchecked") public void testListValuedMapRemove() { final ListValuedMap listMap = makeObject(); - final List list = listMap.get((K) "A"); + List list = listMap.get((K) "A"); list.add((V) "a1"); list.add((V) "a2"); list.add((V) "a3"); @@ -110,8 +110,8 @@ public class ArrayListValuedHashMapTest extends AbstractMultiValuedMapTest @SuppressWarnings({ "unchecked", "rawtypes" }) public void testEqualsHashCodeContract() { - final MultiValuedMap map1 = makeObject(); - final MultiValuedMap map2 = makeObject(); + MultiValuedMap map1 = makeObject(); + MultiValuedMap map2 = makeObject(); map1.put("a", "a1"); map1.put("a", "a2"); @@ -127,8 +127,8 @@ public class ArrayListValuedHashMapTest extends AbstractMultiValuedMapTest @SuppressWarnings({ "unchecked", "rawtypes" }) public void testListValuedMapEqualsHashCodeContract() { - final ListValuedMap map1 = makeObject(); - final ListValuedMap map2 = makeObject(); + ListValuedMap map1 = makeObject(); + ListValuedMap map2 = makeObject(); map1.put("a", "a1"); map1.put("a", "a2"); diff --git a/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java index 2a46641e4..74558310f 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java @@ -57,7 +57,7 @@ public class HashSetValuedHashMapTest extends AbstractMultiValuedMapTest setMap = makeObject(); assertTrue(setMap.get((K) "whatever") instanceof Set); - final Set set = setMap.get((K) "A"); + Set set = setMap.get((K) "A"); assertTrue(set.add((V) "a1")); assertTrue(set.add((V) "a2")); assertFalse(set.add((V) "a1")); @@ -70,7 +70,7 @@ public class HashSetValuedHashMapTest extends AbstractMultiValuedMapTest setMap = makeObject(); assertTrue(setMap.get((K) "whatever") instanceof Set); - final Set set = setMap.get((K) "A"); + Set set = setMap.get((K) "A"); assertTrue(set.add((V) "a1")); assertTrue(set.add((V) "a2")); assertFalse(set.add((V) "a1")); @@ -90,12 +90,12 @@ public class HashSetValuedHashMapTest extends AbstractMultiValuedMapTest setMap = makeObject(); assertTrue(setMap.get((K) "whatever") instanceof Set); - final Set set = setMap.get((K) "A"); + Set set = setMap.get((K) "A"); set.add((V) "a1"); set.add((V) "a2"); set.add((V) "a1"); - final Iterator it = set.iterator(); + Iterator it = set.iterator(); while (it.hasNext()) { it.next(); it.remove(); @@ -106,8 +106,8 @@ public class HashSetValuedHashMapTest extends AbstractMultiValuedMapTest extends AbstractMultiValuedMapT public void testKeyTransformedMap() { final Object[] els = new Object[] { "1", "3", "5", "7", "2", "4", "6" }; - final MultiValuedMap map = TransformedMultiValuedMap.transformingMap( + MultiValuedMap map = TransformedMultiValuedMap.transformingMap( new ArrayListValuedHashMap(), (Transformer) TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER, null); @@ -67,7 +67,7 @@ public class TransformedMultiValuedMapTest extends AbstractMultiValuedMapT assertEquals(true, map.get((K) Integer.valueOf((String) els[i])).contains(els[i])); } - final Collection coll = map.remove(els[0]); + Collection coll = map.remove(els[0]); assertNotNull(coll); assertEquals(0, coll.size()); assertEquals(true, map.remove(Integer.valueOf((String) els[0])).contains(els[0])); @@ -77,7 +77,7 @@ public class TransformedMultiValuedMapTest extends AbstractMultiValuedMapT public void testValueTransformedMap() { final Object[] els = new Object[] { "1", "3", "5", "7", "2", "4", "6" }; - final MultiValuedMap map = TransformedMultiValuedMap.transformingMap( + MultiValuedMap map = TransformedMultiValuedMap.transformingMap( new ArrayListValuedHashMap(), null, (Transformer) TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER); assertEquals(0, map.size()); diff --git a/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java index 22e76ce6e..ad2d77607 100644 --- a/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java +++ b/src/test/java/org/apache/commons/collections4/multimap/UnmodifiableMultiValuedMapTest.java @@ -85,179 +85,179 @@ public class UnmodifiableMultiValuedMapTest extends AbstractMultiValuedMap try { UnmodifiableMultiValuedMap.unmodifiableMultiValuedMap(null); fail("map must not be null"); - } catch (final NullPointerException e) { + } catch (NullPointerException e) { // expected } } @SuppressWarnings("unchecked") public void testAddException() { - final MultiValuedMap map = makeObject(); + MultiValuedMap map = makeObject(); try { map.put((K) "one", (V) "uno"); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } } @SuppressWarnings("unchecked") public void testUnmodifiableEntries() { resetFull(); - final Collection> entries = getMap().entries(); + Collection> entries = getMap().entries(); try { entries.clear(); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } - final Iterator> it = entries.iterator(); - final Entry entry = it.next(); + Iterator> it = entries.iterator(); + Entry entry = it.next(); try { it.remove(); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } try { entry.setValue((V) "three"); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } } @SuppressWarnings("unchecked") public void testUnmodifiableMapIterator() { resetFull(); - final MapIterator mapIt = getMap().mapIterator(); + MapIterator mapIt = getMap().mapIterator(); try { mapIt.remove(); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } try { mapIt.setValue((V) "three"); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } } @SuppressWarnings("unchecked") public void testUnmodifiableKeySet() { resetFull(); - final Set keySet = getMap().keySet(); + Set keySet = getMap().keySet(); try { keySet.add((K) "four"); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } try { keySet.remove("four"); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } try { keySet.clear(); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } - final Iterator it = keySet.iterator(); + Iterator it = keySet.iterator(); try { it.remove(); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } } @SuppressWarnings("unchecked") public void testUnmodifiableValues() { resetFull(); - final Collection values = getMap().values(); + Collection values = getMap().values(); try { values.add((V) "four"); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } try { values.remove("four"); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } try { values.clear(); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } - final Iterator it = values.iterator(); + Iterator it = values.iterator(); try { it.remove(); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } } @SuppressWarnings("unchecked") public void testUnmodifiableAsMap() { resetFull(); - final Map> mapCol = getMap().asMap(); + Map> mapCol = getMap().asMap(); try { mapCol.put((K) "four", (Collection) Arrays.asList("four")); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } try { mapCol.remove("four"); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } try { mapCol.clear(); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } try { mapCol.clear(); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } } @SuppressWarnings("unchecked") public void testUnmodifiableKeys() { resetFull(); - final MultiSet keys = getMap().keys(); + MultiSet keys = getMap().keys(); try { keys.add((K) "four"); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } try { keys.remove("four"); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } try { keys.clear(); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } - final Iterator it = keys.iterator(); + Iterator it = keys.iterator(); try { it.remove(); fail(); - } catch (final UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { } } diff --git a/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java index da3383700..3d49d612e 100644 --- a/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/AbstractQueueTest.java @@ -72,7 +72,7 @@ public abstract class AbstractQueueTest extends AbstractCollectionTest { public void verify() { super.verify(); final Iterator iterator1 = getCollection().iterator(); - for (final E e : getConfirmed()) { + for (E e : getConfirmed()) { assertTrue(iterator1.hasNext()); final Object o1 = iterator1.next(); final Object o2 = e; diff --git a/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java b/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java index e38ade456..ac5187435 100644 --- a/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java +++ b/src/test/java/org/apache/commons/collections4/queue/CircularFifoQueueTest.java @@ -48,7 +48,7 @@ public class CircularFifoQueueTest extends AbstractQueueTest { public void verify() { super.verify(); final Iterator iterator1 = getCollection().iterator(); - for (final E e : getConfirmed()) { + for (E e : getConfirmed()) { assertTrue(iterator1.hasNext()); final Object o1 = iterator1.next(); final Object o2 = e; diff --git a/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java b/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java index 88bb25af0..f2795ec59 100644 --- a/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/sequence/SequencesComparatorTest.java @@ -130,7 +130,7 @@ public class SequencesComparatorTest { final ExecutionVisitor ev = new ExecutionVisitor<>(); for (int i = 0; i < shadokSentences.size(); ++i) { - for (final List shadokSentence : shadokSentences) { + for (List shadokSentence : shadokSentences) { ev.setList(shadokSentences.get(i)); new SequencesComparator<>(shadokSentences.get(i), shadokSentence).getScript().visit(ev); diff --git a/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java b/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java index 089b919fa..cea912a38 100644 --- a/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java +++ b/src/test/java/org/apache/commons/collections4/set/AbstractSetTest.java @@ -62,7 +62,7 @@ public abstract class AbstractSetTest extends AbstractCollectionTest { assertEquals("Sets should have equal hashCodes", getConfirmed().hashCode(), getCollection().hashCode()); final Collection set = makeConfirmedCollection(); - for (final E element : getCollection()) { + for (E element : getCollection()) { assertTrue("Set.iterator should only return unique elements", set.add(element)); } } diff --git a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java index 2660b12f6..88919a372 100755 --- a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java +++ b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java @@ -331,7 +331,7 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { public void testPrefixMapSizes() { // COLLECTIONS-525 - final PatriciaTrie aTree = new PatriciaTrie<>(); + PatriciaTrie aTree = new PatriciaTrie<>(); aTree.put("点评", "测试"); aTree.put("书评", "测试"); assertTrue(aTree.prefixMap("点").containsKey("点评")); @@ -370,7 +370,7 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { } public void testPrefixMapClear() { - final Trie trie = new PatriciaTrie<>(); + Trie trie = new PatriciaTrie<>(); trie.put("Anna", 1); trie.put("Anael", 2); trie.put("Analu", 3); @@ -378,7 +378,7 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { trie.put("Andrea", 5); trie.put("Andres", 6); trie.put("Anatole", 7); - final SortedMap prefixMap = trie.prefixMap("And"); + SortedMap prefixMap = trie.prefixMap("And"); assertEquals(new HashSet<>(Arrays.asList("Andrea", "Andreas", "Andres")), prefixMap.keySet()); assertEquals(Arrays.asList(5, 4, 6), new ArrayList<>(prefixMap.values())); @@ -391,8 +391,8 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { } public void testPrefixMapClearNothing() { - final Trie trie = new PatriciaTrie<>(); - final SortedMap prefixMap = trie.prefixMap("And"); + Trie trie = new PatriciaTrie<>(); + SortedMap prefixMap = trie.prefixMap("And"); assertEquals(new HashSet(), prefixMap.keySet()); assertEquals(new ArrayList(0), new ArrayList<>(prefixMap.values())); @@ -405,7 +405,7 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { } public void testPrefixMapClearUsingRemove() { - final Trie trie = new PatriciaTrie<>(); + Trie trie = new PatriciaTrie<>(); trie.put("Anna", 1); trie.put("Anael", 2); trie.put("Analu", 3); @@ -413,11 +413,11 @@ public class PatriciaTrieTest extends AbstractSortedMapTest { trie.put("Andrea", 5); trie.put("Andres", 6); trie.put("Anatole", 7); - final SortedMap prefixMap = trie.prefixMap("And"); + SortedMap prefixMap = trie.prefixMap("And"); assertEquals(new HashSet<>(Arrays.asList("Andrea", "Andreas", "Andres")), prefixMap.keySet()); assertEquals(Arrays.asList(5, 4, 6), new ArrayList<>(prefixMap.values())); - final Set keys = new HashSet<>(prefixMap.keySet()); + Set keys = new HashSet<>(prefixMap.keySet()); for (final String key : keys) { prefixMap.remove(key); }