net.jqwik.engine.properties.arbitraries.exhaustive.WithNullExhaustiveGenerator Maven / Gradle / Ivy
package net.jqwik.engine.properties.arbitraries.exhaustive;
import java.util.*;
import net.jqwik.api.*;
public class WithNullExhaustiveGenerator implements ExhaustiveGenerator {
private final ExhaustiveGenerator base;
public WithNullExhaustiveGenerator(ExhaustiveGenerator base) {
this.base = base;
}
@Override
public long maxCount() {
return base.maxCount() + 1;
}
@Override
public Iterator iterator() {
return new Iterator() {
boolean nullDelivered = false;
Iterator iterator = base.iterator();
@Override
public boolean hasNext() {
if (!nullDelivered) {
return true;
}
return iterator.hasNext();
}
@Override
public T next() {
if (!nullDelivered) {
nullDelivered = true;
return null;
}
return iterator.next();
}
};
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy