net.jqwik.engine.properties.shrinking.MappedShrinkingSequence Maven / Gradle / Ivy
package net.jqwik.engine.properties.shrinking;
import java.util.function.*;
import net.jqwik.api.*;
public class MappedShrinkingSequence implements ShrinkingSequence {
private final ShrinkingSequence toMap;
private final Function, FalsificationResult> mapper;
public MappedShrinkingSequence(ShrinkingSequence toMap, Function, FalsificationResult> mapper) {this.toMap = toMap;
this.mapper = mapper;
}
@Override
public boolean next(Runnable count, Consumer> uReporter) {
Consumer> tReporter = tResult -> uReporter.accept(mapper.apply(tResult));
return toMap.next(count, tReporter);
}
@Override
public void init(FalsificationResult initialCurrent) {
FalsificationResult toMapCurrent = toMap.current();
if (toMapCurrent != null) {
toMap.init(FalsificationResult.falsified(toMapCurrent.shrinkable(), initialCurrent.throwable().orElse(null)));
}
}
@Override
public FalsificationResult current() {
return mapper.apply(toMap.current());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy