From a7b074875f241d98877de51a93717d56cf2d19e4 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Mon, 6 Jul 2015 22:46:02 +1000 Subject: Fix the warnings from the previous commit --- src/main/java/au/id/zancanaro/javacheck/Generator.java | 4 ++-- src/main/java/au/id/zancanaro/javacheck/Generators.java | 1 + src/main/java/au/id/zancanaro/javacheck/ShrinkTree.java | 8 ++++---- src/main/java/au/id/zancanaro/javacheck/junit/PropertyError.java | 2 ++ .../id/zancanaro/javacheck/object/ObjectGenerationException.java | 2 ++ .../java/au/id/zancanaro/javacheck/object/ObjectGenerator.java | 4 ++-- src/main/java/au/id/zancanaro/javacheck/object/UseGenerator.java | 2 +- .../au/id/zancanaro/javacheck/state/CommandListGenerator.java | 2 +- .../java/au/id/zancanaro/javacheck/state/GeneratedCommand.java | 2 +- 9 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src/main/java/au/id/zancanaro/javacheck') diff --git a/src/main/java/au/id/zancanaro/javacheck/Generator.java b/src/main/java/au/id/zancanaro/javacheck/Generator.java index 8642e8b..d87e894 100644 --- a/src/main/java/au/id/zancanaro/javacheck/Generator.java +++ b/src/main/java/au/id/zancanaro/javacheck/Generator.java @@ -68,7 +68,7 @@ public interface Generator { static Generator> tuple(Generator... generators) { return (random, size) -> { @SuppressWarnings("unchecked") - ShrinkTree[] result = (ShrinkTree[]) new ShrinkTree[generators.length]; + ShrinkTree[] result = (ShrinkTree[]) new ShrinkTree[generators.length]; int index = 0; for (Generator generator : generators) { result[index++] = generator.generate(random, size).map(Function.identity()); @@ -93,7 +93,7 @@ public interface Generator { static Generator> list(int count, Generator generator) { return (random, size) -> { @SuppressWarnings("unchecked") - ShrinkTree[] result = (ShrinkTree[]) new ShrinkTree[count]; + ShrinkTree[] result = (ShrinkTree[]) new ShrinkTree[count]; for (int i = 0; i < count; ++i) { result[i] = generator.generate(random, size); } diff --git a/src/main/java/au/id/zancanaro/javacheck/Generators.java b/src/main/java/au/id/zancanaro/javacheck/Generators.java index 4c8e02e..af8f8ad 100644 --- a/src/main/java/au/id/zancanaro/javacheck/Generators.java +++ b/src/main/java/au/id/zancanaro/javacheck/Generators.java @@ -45,6 +45,7 @@ public final class Generators { } @SafeVarargs + @SuppressWarnings("varargs") public static Generator elements(T... elements) { return elements(Arrays.asList(elements)); } diff --git a/src/main/java/au/id/zancanaro/javacheck/ShrinkTree.java b/src/main/java/au/id/zancanaro/javacheck/ShrinkTree.java index 6e21f27..ddef800 100644 --- a/src/main/java/au/id/zancanaro/javacheck/ShrinkTree.java +++ b/src/main/java/au/id/zancanaro/javacheck/ShrinkTree.java @@ -56,17 +56,17 @@ public class ShrinkTree { public static Stream[]> promoteChildren(ShrinkTree[] trees) { return IntStream.range(0, trees.length) .mapToObj(index -> trees[index].getChildren().map(child -> - IntStream.range(0, trees.length) + (ShrinkTree[]) IntStream.range(0, trees.length) .mapToObj(i -> (i == index ? child : trees[i])) .toArray(ShrinkTree[]::new))) - .flatMap(x -> x) - .map(x -> (ShrinkTree[]) x); + .flatMap(x -> x); } + @SuppressWarnings("unchecked") public static Stream[]> removeChildren(ShrinkTree[] trees) { return IntStream.range(0, trees.length) .mapToObj(index -> - IntStream.range(0, trees.length) + (ShrinkTree[]) IntStream.range(0, trees.length) .filter(i -> i != index) .mapToObj(i -> trees[i]) .toArray(ShrinkTree[]::new)); diff --git a/src/main/java/au/id/zancanaro/javacheck/junit/PropertyError.java b/src/main/java/au/id/zancanaro/javacheck/junit/PropertyError.java index 4f02a56..620b3d1 100644 --- a/src/main/java/au/id/zancanaro/javacheck/junit/PropertyError.java +++ b/src/main/java/au/id/zancanaro/javacheck/junit/PropertyError.java @@ -7,6 +7,8 @@ import java.util.List; @SuppressWarnings("WeakerAccess") public class PropertyError extends AssertionError { + private static final long serialVersionUID = 1L; + public PropertyError(String methodName, long seed, ShrinkResult shrunk) { super(shrunk.thrown.getMessage() == null ? String.format("%s(%s)%n\tSeed: %s%n\tVisited: %s; Depth: %s", diff --git a/src/main/java/au/id/zancanaro/javacheck/object/ObjectGenerationException.java b/src/main/java/au/id/zancanaro/javacheck/object/ObjectGenerationException.java index 444de32..3006e78 100644 --- a/src/main/java/au/id/zancanaro/javacheck/object/ObjectGenerationException.java +++ b/src/main/java/au/id/zancanaro/javacheck/object/ObjectGenerationException.java @@ -1,6 +1,8 @@ package au.id.zancanaro.javacheck.object; public class ObjectGenerationException extends RuntimeException { + private static final long serialVersionUID = 1L; + public ObjectGenerationException(String message) { super(message); } diff --git a/src/main/java/au/id/zancanaro/javacheck/object/ObjectGenerator.java b/src/main/java/au/id/zancanaro/javacheck/object/ObjectGenerator.java index a31d990..f518a56 100644 --- a/src/main/java/au/id/zancanaro/javacheck/object/ObjectGenerator.java +++ b/src/main/java/au/id/zancanaro/javacheck/object/ObjectGenerator.java @@ -77,9 +77,9 @@ public class ObjectGenerator implements Generator { @Override public ShrinkTree generate(Random random, int size) { - Generator[] parameters = new Generator[constructorGenerators.size()]; + Generator[] parameters = new Generator[constructorGenerators.size()]; parameters = constructorGenerators.toArray(parameters); - Generator[] fields = new Generator[fieldGenerators.size()]; + Generator[] fields = new Generator[fieldGenerators.size()]; fields = fieldGenerators.values().toArray(fields); return Generator.tuple(Generator.tuple(parameters), Generator.tuple(fields)) .generate(random, size) diff --git a/src/main/java/au/id/zancanaro/javacheck/object/UseGenerator.java b/src/main/java/au/id/zancanaro/javacheck/object/UseGenerator.java index f62d978..188416f 100644 --- a/src/main/java/au/id/zancanaro/javacheck/object/UseGenerator.java +++ b/src/main/java/au/id/zancanaro/javacheck/object/UseGenerator.java @@ -10,5 +10,5 @@ import java.lang.annotation.Target; @Target({ElementType.FIELD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) public @interface UseGenerator { - Class value(); + Class> value(); } diff --git a/src/main/java/au/id/zancanaro/javacheck/state/CommandListGenerator.java b/src/main/java/au/id/zancanaro/javacheck/state/CommandListGenerator.java index 0eb1793..0aa693d 100644 --- a/src/main/java/au/id/zancanaro/javacheck/state/CommandListGenerator.java +++ b/src/main/java/au/id/zancanaro/javacheck/state/CommandListGenerator.java @@ -45,7 +45,7 @@ public class CommandListGenerator implements Generator> { public ShrinkTree> generate(Random random, int size) { int count = random.nextInt(size); @SuppressWarnings("unchecked") - ShrinkTree>[] commandTrees = (ShrinkTree>[]) new ShrinkTree[count]; + ShrinkTree>[] commandTrees = (ShrinkTree>[]) new ShrinkTree[count]; S state = initialState; for (int i = 0; i < count; ++i) { commandTrees[i] = commandGenerator(i, state).generate(random, size); diff --git a/src/main/java/au/id/zancanaro/javacheck/state/GeneratedCommand.java b/src/main/java/au/id/zancanaro/javacheck/state/GeneratedCommand.java index 85f6fdd..6da9bf2 100644 --- a/src/main/java/au/id/zancanaro/javacheck/state/GeneratedCommand.java +++ b/src/main/java/au/id/zancanaro/javacheck/state/GeneratedCommand.java @@ -28,7 +28,7 @@ public class GeneratedCommand { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - GeneratedCommand that = (GeneratedCommand) o; + GeneratedCommand that = (GeneratedCommand) o; return !(args != null ? !args.equals(that.args) : that.args != null) && !(command != null ? !command.equals(that.command) : that.command != null); -- cgit v1.2.3