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

net.jqwik.engine.properties.shrinking.CollectShrinkable Maven / Gradle / Ivy

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

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

import net.jqwik.api.*;

public class CollectShrinkable implements Shrinkable> {
	private final List value;
	private final List> elements;
	private final Predicate> until;

	public CollectShrinkable(List> elements, Predicate> until) {
		this.value = createValue(elements);
		this.elements = elements;
		this.until = until;
	}

	@Override
	public List value() {
		return value;
	}

	private List createValue(List> elements) {
		return elements
				   .stream()
				   .map(Shrinkable::value)
				   .collect(Collectors.toList());
	}

	@Override
	public ShrinkingSequence> shrink(Falsifier> falsifier) {
		return new CollectShrinkingSequence<>(elements, until, falsifier);
	}

	@Override
	public ShrinkingDistance distance() {
		return ShrinkingDistance.forCollection(elements);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy