From a50de1a86670e11bc2f0935c32695b3f907a94b9 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 1 Jun 2018 15:51:35 +0200 Subject: [PATCH] jetCheck: add wildcards where appropriate --- .../jetbrains/jetCheck/BoundedIntDistribution.java | 2 +- .../src/org/jetbrains/jetCheck/DataStructure.java | 2 +- .../jetbrains/jetCheck/GenerativeDataStructure.java | 2 +- jetCheck/src/org/jetbrains/jetCheck/Generator.java | 12 ++++++------ .../org/jetbrains/jetCheck/ReplayDataStructure.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/jetCheck/src/org/jetbrains/jetCheck/BoundedIntDistribution.java b/jetCheck/src/org/jetbrains/jetCheck/BoundedIntDistribution.java index badcda1d8388..532963dbcd3f 100644 --- a/jetCheck/src/org/jetbrains/jetCheck/BoundedIntDistribution.java +++ b/jetCheck/src/org/jetbrains/jetCheck/BoundedIntDistribution.java @@ -9,7 +9,7 @@ public class BoundedIntDistribution implements IntDistribution { private final int max; private final ToIntFunction producer; - public BoundedIntDistribution(int min, int max, ToIntFunction producer) { + BoundedIntDistribution(int min, int max, ToIntFunction producer) { if (min > max) throw new IllegalArgumentException(min + ">" + max); this.min = min; this.max = max; diff --git a/jetCheck/src/org/jetbrains/jetCheck/DataStructure.java b/jetCheck/src/org/jetbrains/jetCheck/DataStructure.java index 9acf9518cf33..8e37a807dfbc 100644 --- a/jetCheck/src/org/jetbrains/jetCheck/DataStructure.java +++ b/jetCheck/src/org/jetbrains/jetCheck/DataStructure.java @@ -33,5 +33,5 @@ public interface DataStructure { T generateNonShrinkable(@NotNull Generator generator); /** @see Generator#suchThat */ - T generateConditional(@NotNull Generator generator, @NotNull Predicate condition); + T generateConditional(@NotNull Generator generator, @NotNull Predicate condition); } diff --git a/jetCheck/src/org/jetbrains/jetCheck/GenerativeDataStructure.java b/jetCheck/src/org/jetbrains/jetCheck/GenerativeDataStructure.java index 9b51810604ad..d5222c480ddf 100644 --- a/jetCheck/src/org/jetbrains/jetCheck/GenerativeDataStructure.java +++ b/jetCheck/src/org/jetbrains/jetCheck/GenerativeDataStructure.java @@ -37,7 +37,7 @@ class GenerativeDataStructure extends AbstractDataStructure { } @Override - public T generateConditional(@NotNull Generator generator, @NotNull Predicate condition) { + public T generateConditional(@NotNull Generator generator, @NotNull Predicate condition) { for (int i = 0; i < 100; i++) { GenerativeDataStructure structure = subStructure(generator, childSizeHint()); T value = generator.getGeneratorFunction().apply(structure); diff --git a/jetCheck/src/org/jetbrains/jetCheck/Generator.java b/jetCheck/src/org/jetbrains/jetCheck/Generator.java index 3cbfa46425fb..736a8ad1d019 100644 --- a/jetCheck/src/org/jetbrains/jetCheck/Generator.java +++ b/jetCheck/src/org/jetbrains/jetCheck/Generator.java @@ -53,7 +53,7 @@ public class Generator { * Invokes "this" generator, and then applies the given function to transform the generated value in any way. * The function should not depend on anything besides its argument. */ - public Generator map(@NotNull Function fun) { + public Generator map(@NotNull Function fun) { return from(data -> fun.apply(myFunction.apply(data))); } @@ -62,7 +62,7 @@ public class Generator { * depends on the generated value. * The function should not depend on anything besides its argument. */ - public Generator flatMap(@NotNull Function> fun) { + public Generator flatMap(@NotNull Function> fun) { return from(data -> { T value = data.generate(this); Generator result = fun.apply(value); @@ -95,7 +95,7 @@ public class Generator { * (e.g. {@code integers().suchThat(i -> i > 0 && i <= 10)} * where the condition would be {@code true} in just 10 of about 4 billion times). In such cases, please consider changing the generator instead of using {@code suchThat}. */ - public Generator suchThat(@NotNull Predicate condition) { + public Generator suchThat(@NotNull Predicate condition) { return from(data -> data.generateConditional(this, condition)); } @@ -126,7 +126,7 @@ public class Generator { } /** Delegates to one of the given generators with equal probability */ - public static Generator anyOf(List> alternatives) { + public static Generator anyOf(List> alternatives) { if (alternatives.isEmpty()) throw new IllegalArgumentException("No alternatives to choose from"); return from(data -> { int index = data.generateNonShrinkable(integers(0, alternatives.size() - 1)); @@ -148,7 +148,7 @@ public class Generator { } /** Gets the data from two generators and invokes the given function to produce a result based on the two generated values. */ - public static Generator zipWith(Generator gen1, Generator gen2, BiFunction zip) { + public static Generator zipWith(Generator gen1, Generator gen2, BiFunction zip) { return from(data -> zip.apply(data.generate(gen1), data.generate(gen2))); } @@ -162,7 +162,7 @@ public class Generator { * @return the generator returned from the passed function */ @NotNull - public static Generator recursive(@NotNull Function, Generator> createGenerator) { + public static Generator recursive(@NotNull Function, ? extends Generator> createGenerator) { AtomicReference> ref = new AtomicReference<>(); Generator result = from(data -> ref.get().getGeneratorFunction().apply(data)); ref.set(createGenerator.apply(result)); diff --git a/jetCheck/src/org/jetbrains/jetCheck/ReplayDataStructure.java b/jetCheck/src/org/jetbrains/jetCheck/ReplayDataStructure.java index eaf9a94228e6..410fdbec708e 100644 --- a/jetCheck/src/org/jetbrains/jetCheck/ReplayDataStructure.java +++ b/jetCheck/src/org/jetbrains/jetCheck/ReplayDataStructure.java @@ -41,7 +41,7 @@ class ReplayDataStructure extends AbstractDataStructure { } @Override - public T generateConditional(@NotNull Generator generator, @NotNull Predicate condition) { + public T generateConditional(@NotNull Generator generator, @NotNull Predicate condition) { T value = generate(generator); if (!condition.test(value)) throw new CannotRestoreValue(); return value;