Skip to content
Permalink
Browse files
Use diamond operator
  • Loading branch information
aherbert committed Aug 16, 2021
1 parent 2648f67 commit f20d09c8e6a4d6349a688de4427cb70d1ce89ce4
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
@@ -154,7 +154,7 @@ void testUniformNextDouble(UniformRandomProvider generator) {
@ParameterizedTest
@MethodSource("getList")
void testUniformNextIntRandomWalk(UniformRandomProvider generator) {
final Callable<Boolean> nextMethod = new Callable<Boolean>() {
final Callable<Boolean> nextMethod = new Callable<>() {
@Override
public Boolean call() throws Exception {
return generator.nextInt() >= 0;
@@ -167,7 +167,7 @@ public Boolean call() throws Exception {
@ParameterizedTest
@MethodSource("getList")
void testUniformNextLongRandomWalk(UniformRandomProvider generator) {
final Callable<Boolean> nextMethod = new Callable<Boolean>() {
final Callable<Boolean> nextMethod = new Callable<>() {
@Override
public Boolean call() throws Exception {
return generator.nextLong() >= 0;
@@ -180,7 +180,7 @@ public Boolean call() throws Exception {
@ParameterizedTest
@MethodSource("getList")
void testUniformNextBooleanRandomWalk(UniformRandomProvider generator) {
final Callable<Boolean> nextMethod = new Callable<Boolean>() {
final Callable<Boolean> nextMethod = new Callable<>() {
@Override
public Boolean call() throws Exception {
return generator.nextBoolean();
@@ -367,7 +367,7 @@ private void checkRandomWalk(UniformRandomProvider generator,
private void checkNextIntegerInRange(final UniformRandomProvider generator,
final int max,
int sampleSize) {
final Callable<Integer> nextMethod = new Callable<Integer>() {
final Callable<Integer> nextMethod = new Callable<>() {
@Override
public Integer call() throws Exception {
return generator.nextInt(max);
@@ -387,7 +387,7 @@ public Integer call() throws Exception {
private void checkNextLongInRange(final UniformRandomProvider generator,
long max,
int sampleSize) {
final Callable<Long> nextMethod = new Callable<Long>() {
final Callable<Long> nextMethod = new Callable<>() {
@Override
public Long call() throws Exception {
return generator.nextLong(max);
@@ -406,7 +406,7 @@ public Long call() throws Exception {
private void checkNextFloat(final UniformRandomProvider generator,
int sampleSize) {
final int max = 1234;
final Callable<Integer> nextMethod = new Callable<Integer>() {
final Callable<Integer> nextMethod = new Callable<>() {
@Override
public Integer call() throws Exception {
return (int) (max * generator.nextFloat());
@@ -425,7 +425,7 @@ public Integer call() throws Exception {
private void checkNextDouble(final UniformRandomProvider generator,
int sampleSize) {
final int max = 578;
final Callable<Integer> nextMethod = new Callable<Integer>() {
final Callable<Integer> nextMethod = new Callable<>() {
@Override
public Integer call() throws Exception {
return (int) (max * generator.nextDouble());
@@ -32,13 +32,13 @@ class CollectionSamplerTest {

@Test
void testSampleTrivial() {
final ArrayList<String> list = new ArrayList<String>();
final ArrayList<String> list = new ArrayList<>();
list.add("Apache");
list.add("Commons");
list.add("RNG");

final CollectionSampler<String> sampler =
new CollectionSampler<String>(RandomSource.MWC_256.create(),
new CollectionSampler<>(RandomSource.MWC_256.create(),
list);
final String word = sampler.sample();
for (String w : list) {
@@ -53,8 +53,8 @@ void testSampleTrivial() {
void testSamplePrecondition() {
// Must fail for empty collection.
Assertions.assertThrows(IllegalArgumentException.class,
() -> new CollectionSampler<String>(RandomSource.SPLIT_MIX_64.create(0L),
new ArrayList<String>()));
() -> new CollectionSampler<>(RandomSource.SPLIT_MIX_64.create(0L),
new ArrayList<>()));
}

/**
@@ -66,7 +66,7 @@ void testSharedStateSampler() {
final UniformRandomProvider rng2 = RandomSource.SPLIT_MIX_64.create(0L);
final List<String> list = Arrays.asList("Apache", "Commons", "RNG");
final CollectionSampler<String> sampler1 =
new CollectionSampler<String>(rng1, list);
new CollectionSampler<>(rng1, list);
final CollectionSampler<String> sampler2 = sampler1.withUniformRandomProvider(rng2);
RandomAssert.assertProduceSameSequence(sampler1, sampler2);
}
@@ -86,7 +86,7 @@ void testPrecondition6() {
// Empty Map<T, Double> not allowed
Assertions.assertThrows(IllegalArgumentException.class,
() -> new DiscreteProbabilityCollectionSampler<>(rng,
new HashMap<Double, Double>()));
new HashMap<>()));
}

@Test
@@ -70,7 +70,7 @@ private static void check(long sampleSize,
final long[] observed = new long[numBins];

// For storing chi2 larger than the critical value.
final List<Double> failedStat = new ArrayList<Double>();
final List<Double> failedStat = new ArrayList<>();
try {
for (int i = 0; i < numTests; i++) {
Arrays.fill(observed, 0);
@@ -384,7 +384,7 @@ private static List<Number> makeList(int n, UniformRandomProvider generator) {
private void checkNextIntegerInRange(final UniformRandomProvider rng,
final int max,
int sampleSize) {
final Callable<Integer> nextMethod = new Callable<Integer>() {
final Callable<Integer> nextMethod = new Callable<>() {
@Override
public Integer call() throws Exception {
return rng.nextInt(max);
@@ -25,14 +25,14 @@
class NoOpConverterTest {
@Test
void testNoOpIntegerCoversion() {
final NoOpConverter<Integer> converter = new NoOpConverter<Integer>();
final NoOpConverter<Integer> converter = new NoOpConverter<>();
final Integer in = 123;
Assertions.assertSame(in, converter.convert(in));
}

@Test
void testNoOpLongArrayCoversion() {
final NoOpConverter<long[]> converter = new NoOpConverter<long[]>();
final NoOpConverter<long[]> converter = new NoOpConverter<>();
final long[] in = {123L, 456L, Long.MAX_VALUE};
Assertions.assertSame(in, converter.convert(in));
}
@@ -28,7 +28,7 @@ void testComposedCoversion() {
final Int2Long int2Long = new Int2Long();
final Long2LongArray long2LongArray = new Long2LongArray(3);
final SeedConverterComposer<Integer, Long, long[]> composer =
new SeedConverterComposer<Integer, Long, long[]>(int2Long, long2LongArray);
new SeedConverterComposer<>(int2Long, long2LongArray);
final Integer in = 123;
final Object out = composer.convert(in);
Assertions.assertTrue(out instanceof long[], "Bad type conversion");
@@ -31,7 +31,7 @@
class SeedFactoryTest {
@Test
void testCreateLong() {
final Map<Long, Integer> values = new HashMap<Long, Integer>();
final Map<Long, Integer> values = new HashMap<>();

final int n = 100000;
for (int i = 0; i < n; i++) {
@@ -50,7 +50,7 @@ void testCreateLong() {

@Test
void testCreateLongArray() {
final Map<Long, Integer> values = new HashMap<Long, Integer>();
final Map<Long, Integer> values = new HashMap<>();

final int n = 100000;
final long[] array = SeedFactory.createLongArray(n);
@@ -70,7 +70,7 @@ void testCreateLongArray() {

@Test
void testCreateIntArray() {
final Map<Long, Integer> values = new HashMap<Long, Integer>();
final Map<Long, Integer> values = new HashMap<>();

for (int i = 0; i < 50000; i++) {
final int[] a = SeedFactory.createIntArray(2);

0 comments on commit f20d09c

Please sign in to comment.