net.jqwik.engine.properties.arbitraries.randomized.CollectGenerator Maven / Gradle / Ivy
package net.jqwik.engine.properties.arbitraries.randomized;
import java.util.*;
import java.util.function.*;
import net.jqwik.api.*;
import net.jqwik.engine.properties.shrinking.*;
public class CollectGenerator implements RandomGenerator> {
private final RandomGenerator elementGenerator;
private final Predicate> until;
public CollectGenerator(RandomGenerator elementGenerator, Predicate> until) {
this.elementGenerator = elementGenerator;
this.until = until;
}
@Override
public Shrinkable> next(Random random) {
List base = new ArrayList<>();
List> shrinkables = new ArrayList<>();
while (!until.test(base)) {
Shrinkable shrinkable = elementGenerator.next(random);
base.add(shrinkable.value());
shrinkables.add(shrinkable);
}
return new CollectShrinkable<>(shrinkables, until);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy