net.jqwik.engine.providers.OptionalArbitraryProvider Maven / Gradle / Ivy
package net.jqwik.engine.providers;
import java.util.*;
import java.util.stream.*;
import net.jqwik.api.*;
import net.jqwik.api.providers.*;
public class OptionalArbitraryProvider implements ArbitraryProvider {
@Override
public boolean canProvideFor(TypeUsage targetType) {
return targetType.isOfType(Optional.class);
}
@Override
public Set> provideFor(TypeUsage targetType, SubtypeProvider subtypeProvider) {
TypeUsage innerType = targetType.getTypeArguments().get(0);
return subtypeProvider.apply(innerType).stream() //
.map(Arbitrary::optional)
.collect(Collectors.toSet());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy