net.jqwik.engine.properties.arbitraries.exhaustive.WithNullExhaustiveGenerator Maven / Gradle / Ivy
The newest version!
package net.jqwik.engine.properties.arbitraries.exhaustive;
import java.util.*;
import net.jqwik.api.*;
import org.jspecify.annotations.*;
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();
}
};
}
}