From 1d26ffda9302433fda227c5724d2f5cd499b0148 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sun, 26 Jan 2020 17:23:41 -0500 Subject: [PATCH] Remove redundant generic type arguments. --- .../bloomfilter/CountingBloomFilter.java | 12 +++++----- .../bloomfilter/HasherBloomFilter.java | 4 ++-- .../bloomfilter/hasher/DynamicHasher.java | 4 ++-- .../bloomfilter/hasher/StaticHasher.java | 2 +- .../bag/TransformedSortedBagTest.java | 2 +- .../bloomfilter/AbstractBloomFilterTest.java | 2 +- .../bloomfilter/CountingBloomFilterTest.java | 24 +++++++++---------- .../hasher/CommonComparatorTest.java | 4 ++-- .../hasher/DeepComparatorTest.java | 4 ++-- .../bloomfilter/hasher/StaticHasherTest.java | 2 +- 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilter.java b/src/main/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilter.java index e8dc80db3..c4dceb11f 100644 --- a/src/main/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilter.java +++ b/src/main/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilter.java @@ -61,8 +61,8 @@ public class CountingBloomFilter extends AbstractBloomFilter { public CountingBloomFilter(Hasher hasher, Shape shape) { super(shape); verifyHasher(hasher); - counts = new TreeMap(); - Set idxs = new HashSet(); + counts = new TreeMap<>(); + Set idxs = new HashSet<>(); hasher.getBits(shape).forEachRemaining((IntConsumer) idxs::add); idxs.stream().forEach(idx -> counts.put(idx, 1)); } @@ -74,7 +74,7 @@ public class CountingBloomFilter extends AbstractBloomFilter { */ public CountingBloomFilter(Shape shape) { super(shape); - this.counts = new TreeMap(); + this.counts = new TreeMap<>(); } /** @@ -111,7 +111,7 @@ public class CountingBloomFilter extends AbstractBloomFilter { */ public Stream> getCounts() { return counts.entrySet().stream() - .map(e -> new AbstractMap.SimpleEntry(e.getKey(), e.getValue())); + .map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), e.getValue())); } @Override @@ -200,7 +200,7 @@ public class CountingBloomFilter extends AbstractBloomFilter { */ public void remove(Hasher hasher) { verifyHasher( hasher ); - Set lst = new HashSet(); + Set lst = new HashSet<>(); hasher.getBits(getShape()).forEachRemaining( (Consumer)lst::add ); remove(lst.stream()); } @@ -262,7 +262,7 @@ public class CountingBloomFilter extends AbstractBloomFilter { @Override public int andCardinality(BloomFilter other) { if (other instanceof CountingBloomFilter) { - Set result = new HashSet( counts.keySet()); + Set result = new HashSet<>( counts.keySet()); result.retainAll( ((CountingBloomFilter)other).counts.keySet() ); return result.size(); } diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/HasherBloomFilter.java b/src/main/java/org/apache/commons/collections4/bloomfilter/HasherBloomFilter.java index fb2722ada..3c0fb8c31 100644 --- a/src/main/java/org/apache/commons/collections4/bloomfilter/HasherBloomFilter.java +++ b/src/main/java/org/apache/commons/collections4/bloomfilter/HasherBloomFilter.java @@ -112,7 +112,7 @@ public class HasherBloomFilter extends AbstractBloomFilter { @Override public void merge(Hasher hasher) { verifyHasher(hasher); - IteratorChain iter = new IteratorChain(this.hasher.getBits(getShape()), + IteratorChain iter = new IteratorChain<>(this.hasher.getBits(getShape()), hasher.getBits(getShape())); this.hasher = new StaticHasher(iter, getShape()); } @@ -125,7 +125,7 @@ public class HasherBloomFilter extends AbstractBloomFilter { @Override public boolean contains(Hasher hasher) { verifyHasher(hasher); - Set set = new TreeSet(); + Set set = new TreeSet<>(); hasher.getBits(getShape()).forEachRemaining((IntConsumer) idx -> { set.add(idx); }); diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/DynamicHasher.java b/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/DynamicHasher.java index aa607791e..59e813c68 100644 --- a/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/DynamicHasher.java +++ b/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/DynamicHasher.java @@ -46,7 +46,7 @@ public class DynamicHasher implements Hasher { * @param buffers the byte buffers that will be hashed. */ public DynamicHasher(HashFunction function, List buffers) { - this.buffers = new ArrayList(buffers); + this.buffers = new ArrayList<>(buffers); this.function = function; } @@ -143,7 +143,7 @@ public class DynamicHasher implements Hasher { */ public Builder(HashFunction function) { this.function = function; - this.buffers = new ArrayList(); + this.buffers = new ArrayList<>(); } diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/StaticHasher.java b/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/StaticHasher.java index ccc6c83de..b14cf4095 100644 --- a/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/StaticHasher.java +++ b/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/StaticHasher.java @@ -79,7 +79,7 @@ public final class StaticHasher implements Hasher { */ public StaticHasher(Iterator iter, Shape shape) { this.shape = shape; - Set workingValues = new TreeSet(); + Set workingValues = new TreeSet<>(); iter.forEachRemaining( idx -> { if (idx >= this.shape.getNumberOfBits()) { diff --git a/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java b/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java index a3949ef0e..65b1ce1df 100644 --- a/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java +++ b/src/test/java/org/apache/commons/collections4/bag/TransformedSortedBagTest.java @@ -64,7 +64,7 @@ public class TransformedSortedBagTest extends AbstractSortedBagTest { } public void testTransformedBag_decorateTransform() { - final TreeBag originalBag = new TreeBag(); + final TreeBag originalBag = new TreeBag<>(); final Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"}; for (final Object el : els) { originalBag.add((T) el); diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java index a1d10af00..8d2935d12 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java @@ -377,7 +377,7 @@ public abstract class AbstractBloomFilterTest { AbstractBloomFilter filter = createEmptyFilter(shape); assertFalse(filter.isFull()); - List values = new ArrayList(shape.getNumberOfBits()); + List values = new ArrayList<>(shape.getNumberOfBits()); for (int i = 0; i < shape.getNumberOfBits(); i++) { values.add(i); } diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilterTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilterTest.java index c74dab924..527acf403 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilterTest.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilterTest.java @@ -72,7 +72,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest { */ @Test public void ConstructorTest_Map_CountsTest() { - Map map = new HashMap(); + Map map = new HashMap<>(); for (int i =0;i<17;i++) { map.put( i, 1 ); @@ -137,7 +137,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest { assertEquals(Integer.valueOf(2), bf.getCounts().map(Map.Entry::getValue).max(Integer::compare).get()); assertEquals(Integer.valueOf(1), bf.getCounts().map(Map.Entry::getValue).min(Integer::compare).get()); - Map m = new HashMap(); + Map m = new HashMap<>(); bf.getCounts().forEach(e -> m.put(e.getKey(), e.getValue())); for (int i=0;i<29;i++) { @@ -177,7 +177,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest { assertEquals(Integer.valueOf(2), bf.getCounts().map(Map.Entry::getValue).max(Integer::compare).get()); assertEquals(Integer.valueOf(1), bf.getCounts().map(Map.Entry::getValue).min(Integer::compare).get()); - Map m = new HashMap(); + Map m = new HashMap<>(); bf.getCounts().forEach(e -> m.put(e.getKey(), e.getValue())); for (int i=0;i<29;i++) { @@ -217,7 +217,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest { assertEquals(Integer.valueOf(2), bf.getCounts().map(Map.Entry::getValue).max(Integer::compare).get()); assertEquals(Integer.valueOf(1), bf.getCounts().map(Map.Entry::getValue).min(Integer::compare).get()); - Map m = new HashMap(); + Map m = new HashMap<>(); bf.getCounts().forEach(e -> m.put(e.getKey(), e.getValue())); for (int i=0;i<29;i++) { @@ -243,7 +243,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest { CountingBloomFilter bf = createFilter(hasher, shape); - Map map = new HashMap(); + Map map = new HashMap<>(); bf.getCounts().forEach( e -> map.put( e.getKey(), e.getValue())); map.put(1, Integer.MAX_VALUE ); @@ -276,7 +276,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest { 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - Map map = new HashMap(); + Map map = new HashMap<>(); for (int i=1;i map2 = new HashMap(); + Map map2 = new HashMap<>(); bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue())); for (int i = 11; i map = new HashMap(); + Map map = new HashMap<>(); for (int i=1;i map2 = new HashMap(); + Map map2 = new HashMap<>(); bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue())); for (int i = 11; i map = new HashMap(); + Map map = new HashMap<>(); bf.getCounts().forEach( e -> map.put( e.getKey(), e.getValue())); map.remove(1); @@ -381,7 +381,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest { 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - Map map = new HashMap(); + Map map = new HashMap<>(); for (int i=1;i map2 = new HashMap(); + Map map2 = new HashMap<>(); bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue())); for (int i = 11; i result = new TreeSet( + TreeSet result = new TreeSet<>( HashFunctionIdentity.COMMON_COMPARATOR); - List collection = new ArrayList(); + List collection = new ArrayList<>(); collection .add(new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED, ProcessType.CYCLIC, 0)); diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/hasher/DeepComparatorTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/hasher/DeepComparatorTest.java index d25adede0..f1534e28b 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/hasher/DeepComparatorTest.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/hasher/DeepComparatorTest.java @@ -127,8 +127,8 @@ public class DeepComparatorTest { @Test public void testSortOrder() { // in this test the signature is the position in the final collection for the ID - TreeSet result = new TreeSet(HashFunctionIdentity.DEEP_COMPARATOR); - List collection = new ArrayList(); + TreeSet result = new TreeSet<>(HashFunctionIdentity.DEEP_COMPARATOR); + List collection = new ArrayList<>(); collection .add(new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED, ProcessType.CYCLIC, 0)); diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/hasher/StaticHasherTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/hasher/StaticHasherTest.java index 29e038de7..034bf8aeb 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/hasher/StaticHasherTest.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/hasher/StaticHasherTest.java @@ -325,7 +325,7 @@ public class StaticHasherTest { */ @Test public void testIsEmpty() { - List lst = new ArrayList(); + List lst = new ArrayList<>(); StaticHasher hasher = new StaticHasher(lst.iterator(), shape);