net.jqwik.engine.properties.shrinking.ChooseValueShrinkable Maven / Gradle / Ivy
package net.jqwik.engine.properties.shrinking;
import java.util.*;
import java.util.stream.*;
import net.jqwik.api.*;
public class ChooseValueShrinkable extends AbstractShrinkable {
private final List values;
public ChooseValueShrinkable(T value, List values) {
super(value);
this.values = values;
}
@Override
public ShrinkingDistance distance() {
return ShrinkingDistance.of(values.indexOf(value()));
}
@Override
public Set> shrinkCandidatesFor(Shrinkable shrinkable) {
int index = values.indexOf(shrinkable.value());
if (index == 0) {
return Collections.emptySet();
}
return values.subList(0, index) //
.stream() //
.map(value -> new ChooseValueShrinkable<>(value, values)) //
.collect(Collectors.toSet());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy