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

net.jqwik.engine.properties.UniquenessChecker Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
package net.jqwik.engine.properties;

import java.util.*;
import java.util.stream.*;

import net.jqwik.api.*;

public class UniquenessChecker {

	public static  boolean checkShrinkableUniqueIn(Collection> extractors, Shrinkable shrinkable, List> shrinkables) {
		if (extractors.isEmpty()) {
			return true;
		}
		T value = shrinkable.value();
		List elements = shrinkables.stream().map(Shrinkable::value).collect(Collectors.toList());
		return checkValueUniqueIn(extractors, value, elements);
	}

	public static  boolean checkValueUniqueIn(Collection> extractors, T value, Collection elements) {
		for (FeatureExtractor extractor : extractors) {
			if (!extractor.isUniqueIn(value, elements)) {
				return false;
			}
		}
		return true;
	}

	public static  boolean checkUniquenessOfShrinkables(Collection> extractors, List> shrinkables) {
		if (extractors.isEmpty()) {
			return true;
		}
		List elements = shrinkables.stream().map(Shrinkable::value).collect(Collectors.toList());
		return checkUniquenessOfValues(extractors, elements);
	}

	public static  boolean checkUniquenessOfValues(Collection> extractors, Collection elements) {
		for (FeatureExtractor extractor : extractors) {
			if (!extractor.areUnique(elements)) {
				return false;
			}
		}
		return true;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy