net.jqwik.engine.properties.shrinking.ShrinkableSet Maven / Gradle / Ivy
package net.jqwik.engine.properties.shrinking;
import java.util.*;
import java.util.stream.*;
import net.jqwik.api.*;
import net.jqwik.engine.properties.*;
public class ShrinkableSet extends ShrinkableContainer, E> {
public ShrinkableSet(Collection> elements, int minSize, int maxSize, Collection> uniquenessExtractors) {
this(new ArrayList<>(elements), minSize, maxSize, uniquenessExtractors);
}
private ShrinkableSet(List> elements, int minSize, int maxSize, Collection> uniquenessExtractors) {
super(elements, minSize, maxSize, uniquenessExtractors);
}
@Override
public Stream>> shrink() {
return super.shrink().filter(shrinkableSet -> shrinkableSet.value().size() >= minSize);
}
@Override
protected boolean hasReallyGrown(Shrinkable> grownShrinkable) {
return grownShrinkable.value().size() > elements.size();
}
@Override
Collector> containerCollector() {
return Collectors.toSet();
}
@Override
Shrinkable> createShrinkable(List> shrunkElements) {
return new ShrinkableSet<>(shrunkElements, minSize, maxSize, uniquenessExtractors);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy