net.jqwik.engine.properties.shrinking.MappedValueShrinkingSequence Maven / Gradle / Ivy
package net.jqwik.engine.properties.shrinking;
import java.util.function.*;
import net.jqwik.api.*;
public class MappedValueShrinkingSequence implements ShrinkingSequence {
private final ShrinkingSequence toMap;
private final Function mapper;
public MappedValueShrinkingSequence(ShrinkingSequence toMap, Function mapper) {
this.toMap = toMap;
this.mapper = mapper;
}
@Override
public boolean next(Runnable count, Consumer> falsifiedReporter) {
return toMap.next(count, tResult -> falsifiedReporter.accept(tResult.map(shrinkable -> shrinkable.map(mapper))));
}
@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 toMap.current().map(shrinkable -> shrinkable.map(mapper));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy