Skip to content

Commit 283de5b

Browse files
committed
Sonar fix: use method reference
1 parent ff8609c commit 283de5b

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

commons-rng-core/src/test/java/org/apache/commons/rng/core/ProvidersList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ public final class ProvidersList {
171171
LIST.addAll(LIST64);
172172
// Dynamically identify the sub-type RNGs
173173
LIST.stream()
174-
.filter(rng -> rng instanceof JumpableUniformRandomProvider)
174+
.filter(JumpableUniformRandomProvider.class::isInstance)
175175
.forEach(rng -> LIST_JUMP.add((JumpableUniformRandomProvider) rng));
176176
LIST.stream()
177-
.filter(rng -> rng instanceof SplittableUniformRandomProvider)
177+
.filter(SplittableUniformRandomProvider.class::isInstance)
178178
.forEach(rng -> LIST_SPLIT.add((SplittableUniformRandomProvider) rng));
179179
} catch (final Exception e) {
180180
// CHECKSTYLE: stop Regexp

commons-rng-core/src/test/java/org/apache/commons/rng/core/source64/XoRoShiRo128PlusPlusTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,6 @@ void testLongJump() {
119119
@Test
120120
void testNextOutputThrows() {
121121
final XoRoShiRo128PlusPlus rng = new XoRoShiRo128PlusPlus(SEED);
122-
Assertions.assertThrows(UnsupportedOperationException.class, () -> rng.nextOutput());
122+
Assertions.assertThrows(UnsupportedOperationException.class, rng::nextOutput);
123123
}
124124
}

commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/ZigguratNormalizedGaussianSamplerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ void testInfiniteLoop() {
3535

3636
// Infinite loop (in v1.1).
3737
final ZigguratNormalizedGaussianSampler sampler = new ZigguratNormalizedGaussianSampler(bad);
38-
Assertions.assertThrows(StackOverflowError.class,
39-
() -> sampler.sample());
38+
Assertions.assertThrows(StackOverflowError.class, sampler::sample);
4039
}
4140

4241
/**

commons-rng-simple/src/test/java/org/apache/commons/rng/simple/ProvidersCommonParametricTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void testCreateMethodThrowsWithIncorrectArguments(ProvidersList.Data data) {
119119
} else {
120120
// Try no arguments for a provider that does require them
121121
Assertions.assertThrows(IllegalArgumentException.class,
122-
() -> originalSource.create(),
122+
originalSource::create,
123123
() -> "Source requires arguments: " + originalSource);
124124
}
125125
}

commons-rng-simple/src/test/java/org/apache/commons/rng/simple/internal/RandomSourceInternalParametricTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,6 @@ void testCreateSeedBytes(RandomSourceInternal randomSourceInternal) {
215215

216216
final Integer expected = EXPECTED_SEED_BYTES.get(randomSourceInternal);
217217
Assertions.assertNotNull(expected, () -> "Missing expected seed byte size: " + randomSourceInternal);
218-
Assertions.assertEquals(expected.intValue(), size, () -> randomSourceInternal.toString());
218+
Assertions.assertEquals(expected.intValue(), size, randomSourceInternal::toString);
219219
}
220220
}

0 commit comments

Comments
 (0)