summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@zancanaro.id.au>2015-07-06 22:46:02 +1000
committerCarlo Zancanaro <carlo@zancanaro.id.au>2015-07-06 22:46:02 +1000
commita7b074875f241d98877de51a93717d56cf2d19e4 (patch)
tree7b5397d3955cbe6bc6a6a2669f9191b657e48591 /src/main
parent2348f721ba7475b65afeefb108012c564e5653ce (diff)
Fix the warnings from the previous commit
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/au/id/zancanaro/javacheck/Generator.java4
-rw-r--r--src/main/java/au/id/zancanaro/javacheck/Generators.java1
-rw-r--r--src/main/java/au/id/zancanaro/javacheck/ShrinkTree.java8
-rw-r--r--src/main/java/au/id/zancanaro/javacheck/junit/PropertyError.java2
-rw-r--r--src/main/java/au/id/zancanaro/javacheck/object/ObjectGenerationException.java2
-rw-r--r--src/main/java/au/id/zancanaro/javacheck/object/ObjectGenerator.java4
-rw-r--r--src/main/java/au/id/zancanaro/javacheck/object/UseGenerator.java2
-rw-r--r--src/main/java/au/id/zancanaro/javacheck/state/CommandListGenerator.java2
-rw-r--r--src/main/java/au/id/zancanaro/javacheck/state/GeneratedCommand.java2
9 files changed, 16 insertions, 11 deletions
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<T> {
static <T> Generator<List<T>> tuple(Generator<? extends T>... generators) {
return (random, size) -> {
@SuppressWarnings("unchecked")
- ShrinkTree<T>[] result = (ShrinkTree<T>[]) new ShrinkTree[generators.length];
+ ShrinkTree<T>[] result = (ShrinkTree<T>[]) new ShrinkTree<?>[generators.length];
int index = 0;
for (Generator<? extends T> generator : generators) {
result[index++] = generator.generate(random, size).map(Function.identity());
@@ -93,7 +93,7 @@ public interface Generator<T> {
static <T> Generator<List<T>> list(int count, Generator<T> generator) {
return (random, size) -> {
@SuppressWarnings("unchecked")
- ShrinkTree<T>[] result = (ShrinkTree<T>[]) new ShrinkTree[count];
+ ShrinkTree<T>[] result = (ShrinkTree<T>[]) 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 <T> Generator<T> 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<T> {
public static <T> Stream<ShrinkTree<T>[]> promoteChildren(ShrinkTree<? super T>[] trees) {
return IntStream.range(0, trees.length)
.mapToObj(index -> trees[index].getChildren().map(child ->
- IntStream.range(0, trees.length)
+ (ShrinkTree<T>[]) IntStream.range(0, trees.length)
.mapToObj(i -> (i == index ? child : trees[i]))
.toArray(ShrinkTree[]::new)))
- .flatMap(x -> x)
- .map(x -> (ShrinkTree<T>[]) x);
+ .flatMap(x -> x);
}
+ @SuppressWarnings("unchecked")
public static <T> Stream<ShrinkTree<T>[]> removeChildren(ShrinkTree<? super T>[] trees) {
return IntStream.range(0, trees.length)
.mapToObj(index ->
- IntStream.range(0, trees.length)
+ (ShrinkTree<T>[]) 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<T> implements Generator<T> {
@Override
public ShrinkTree<T> 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<? extends Generator> value();
+ Class<? extends Generator<?>> 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<S> implements Generator<CommandList<S>> {
public ShrinkTree<CommandList<S>> generate(Random random, int size) {
int count = random.nextInt(size);
@SuppressWarnings("unchecked")
- ShrinkTree<GeneratedCommand<S, ?, ?>>[] commandTrees = (ShrinkTree<GeneratedCommand<S, ?, ?>>[]) new ShrinkTree[count];
+ ShrinkTree<GeneratedCommand<S, ?, ?>>[] commandTrees = (ShrinkTree<GeneratedCommand<S, ?, ?>>[]) 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<S, A, R> {
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);