From 9582007123799dab2f1ddb38aa8654c26867da3f Mon Sep 17 00:00:00 2001 From: aherbert Date: Fri, 4 Nov 2022 15:40:26 +0000 Subject: [PATCH] Make Hasher test classes package-private --- .../collections4/bloomfilter/ArrayHasher.java | 11 +++++++---- .../bloomfilter/IncrementingHasher.java | 4 +--- .../collections4/bloomfilter/NullHasher.java | 14 +++++++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/ArrayHasher.java b/src/test/java/org/apache/commons/collections4/bloomfilter/ArrayHasher.java index babd13d2c..32a421eb0 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/ArrayHasher.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/ArrayHasher.java @@ -22,10 +22,10 @@ import java.util.function.IntPredicate; /** * A Testing Hasher that returns the array values % shape.getNumberOfBits(). * - * @since 4.5 + *

To be used for testing only.

*/ -public final class ArrayHasher implements Hasher { - final int[] values; +final class ArrayHasher implements Hasher { + private final int[] values; ArrayHasher(final int... values) { this.values = values; @@ -39,6 +39,7 @@ public final class ArrayHasher implements Hasher { @Override public IndexProducer uniqueIndices(Shape shape) { + Objects.requireNonNull(shape, "shape"); return new Producer(shape); } @@ -51,8 +52,10 @@ public final class ArrayHasher implements Hasher { @Override public boolean forEachIndex(IntPredicate consumer) { + Objects.requireNonNull(consumer, "consumer"); + int pos = 0; - for (int i=0; iKrisch and Mitzenmacher. * *

To be used for testing only.

- * - * @since 4.5 */ -class IncrementingHasher implements Hasher { +final class IncrementingHasher implements Hasher { /** * The initial hash value. diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/NullHasher.java b/src/test/java/org/apache/commons/collections4/bloomfilter/NullHasher.java index 537c60d28..ba49f04e9 100644 --- a/src/test/java/org/apache/commons/collections4/bloomfilter/NullHasher.java +++ b/src/test/java/org/apache/commons/collections4/bloomfilter/NullHasher.java @@ -22,23 +22,30 @@ import java.util.function.IntPredicate; /** * A Hasher that returns no values. * - * @since 4.5 + *

To be used for testing only.

*/ -public final class NullHasher implements Hasher { +final class NullHasher implements Hasher { /** * The instance of the Null Hasher. */ - public static final NullHasher INSTANCE = new NullHasher(); + static final NullHasher INSTANCE = new NullHasher(); private static final IndexProducer PRODUCER = new IndexProducer() { @Override public boolean forEachIndex(IntPredicate consumer) { + Objects.requireNonNull(consumer, "consumer"); return true; } + + @Override + public int[] asIndexArray() { + return new int[0]; + } }; private NullHasher() { + // No instances } @Override @@ -49,6 +56,7 @@ public final class NullHasher implements Hasher { @Override public IndexProducer uniqueIndices(Shape shape) { + Objects.requireNonNull(shape, "shape"); return PRODUCER; } }