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

net.jqwik.engine.properties.arbitraries.ArbitraryCollect Maven / Gradle / Ivy

The newest version!
package net.jqwik.engine.properties.arbitraries;

import java.util.*;
import java.util.function.*;

import net.jqwik.api.*;
import net.jqwik.api.support.*;

import org.jspecify.annotations.*;

public class ArbitraryCollect implements Arbitrary> {

	private final Arbitrary elementArbitrary;
	private final Predicate> until;

	public ArbitraryCollect(Arbitrary elementArbitrary, Predicate> until) {
		this.elementArbitrary = elementArbitrary;
		this.until = until;
	}

	@Override
	public RandomGenerator> generator(final int genSize) {
		return elementArbitrary.generator(genSize).collect(until);
	}

	@Override
	public EdgeCases> edgeCases(int maxEdgeCases) {
		return EdgeCases.none();
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		ArbitraryCollect that = (ArbitraryCollect) o;
		if (!elementArbitrary.equals(that.elementArbitrary)) return false;
		return LambdaSupport.areEqual(until, that.until);
	}

	@Override
	public int hashCode() {
		return HashCodeSupport.hash(elementArbitrary, until.getClass());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy