All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jqwik.engine.properties.arbitraries.exhaustive.WithNullExhaustiveGenerator Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show 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();
			}
		};
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy