net.jqwik.api.FalsificationResult Maven / Gradle / Ivy
package net.jqwik.api;
import java.util.*;
import java.util.function.*;
import org.apiguardian.api.*;
import static org.apiguardian.api.API.Status.*;
/**
* @deprecated To be removed in 1.4
*/
@Deprecated
@API(status = DEPRECATED, since = "1.3.3")
public class FalsificationResult implements Comparable> {
private final Shrinkable shrinkable;
private final Status status;
private final Throwable throwable;
public enum Status {
FALSIFIED, VERIFIED, FILTERED_OUT
}
public static FalsificationResult falsified(Shrinkable shrinkable) {
return FalsificationResult.falsified(shrinkable, null);
}
public static FalsificationResult falsified(Shrinkable shrinkable, Throwable throwable) {
return new FalsificationResult<>(shrinkable, Status.FALSIFIED, throwable);
}
public static FalsificationResult notFalsified(Shrinkable shrinkable) {
return new FalsificationResult<>(shrinkable, Status.VERIFIED, null);
}
public static FalsificationResult filtered(Shrinkable shrinkable) {
return new FalsificationResult<>(shrinkable, Status.FILTERED_OUT, null);
}
private FalsificationResult(Shrinkable shrinkable, Status status, Throwable throwable) {
this.shrinkable = shrinkable;
this.status = status;
this.throwable = throwable;
}
public Shrinkable shrinkable() {
return shrinkable;
}
public T value() {
return shrinkable.value();
}
public ShrinkingDistance distance() {
return shrinkable.distance();
}
public Status status() {
return status;
}
public Optional throwable() {
return Optional.ofNullable(throwable);
}
@Override
public int compareTo(FalsificationResult other) {
return shrinkable.compareTo(other.shrinkable);
}
public FalsificationResult filter(Predicate filter) {
return new FalsificationResult<>(shrinkable.filter(filter), status, throwable);
}
public FalsificationResult map(Function, Shrinkable> mapper) {
return new FalsificationResult<>(mapper.apply(this.shrinkable()), status, throwable);
}
@Override
public String toString() {
return "FalsificationResult{" +
"shrinkable.value()=" + shrinkable.value() +
", status=" + status +
", throwable=" + throwable +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy