net.jqwik.engine.properties.arbitraries.exhaustive.MappedExhaustiveGenerator Maven / Gradle / Ivy
package net.jqwik.engine.properties.arbitraries.exhaustive;
import java.util.*;
import java.util.function.*;
import net.jqwik.api.*;
public class MappedExhaustiveGenerator implements ExhaustiveGenerator {
private final ExhaustiveGenerator toMap;
private final Function mapper;
public MappedExhaustiveGenerator(ExhaustiveGenerator toMap, Function mapper) {this.toMap = toMap;
this.mapper = mapper;
}
@Override
public long maxCount() {
return toMap.maxCount();
}
@Override
public Iterator iterator() {
final Iterator mappedIterator = toMap.iterator();
return new Iterator() {
@Override
public boolean hasNext() {
return mappedIterator.hasNext();
}
@Override
public U next() {
return mapper.apply(mappedIterator.next());
}
};
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy