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

net.jqwik.engine.properties.shrinking.ChooseValueShrinkable 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.stream.*;

import net.jqwik.api.*;

public class ChooseValueShrinkable extends AbstractShrinkable {

	private final List values;

	public ChooseValueShrinkable(T value, List values) {
		super(value);
		this.values = values;
	}

	@Override
	public ShrinkingDistance distance() {
		return ShrinkingDistance.of(values.indexOf(value()));
	}

	@Override
	public Set> shrinkCandidatesFor(Shrinkable shrinkable) {
		int index = values.indexOf(shrinkable.value());
		if (index == 0) {
			return Collections.emptySet();
		}
		return values.subList(0, index) //
					 .stream() //
					 .map(value -> new ChooseValueShrinkable<>(value, values)) //
					 .collect(Collectors.toSet());
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy