Class Lambdas
java.lang.Object
com.pholser.junit.quickcheck.generator.Lambdas
Helper class for creating instances of "functional interfaces".
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,U> T makeLambda(Class<T> lambdaType, Generator<U> returnValueGenerator, GenerationStatus status) Creates an instance of a given "functional interface" type, whose single abstract method returns values of the type produced by the given generator.
-
Constructor Details
-
Lambdas
private Lambdas()
-
-
Method Details
-
makeLambda
public static <T,U> T makeLambda(Class<T> lambdaType, Generator<U> returnValueGenerator, GenerationStatus status) Creates an instance of a given "functional interface" type, whose single abstract method returns values of the type produced by the given generator. The arguments to the lambda's single method will be used to seed a random generator that will be used to generate the return value of that method.
junit-quickcheck uses this to create random values for property parameters whose type is determined to be a functional interface. Custom generators for functional interface types can use this also.
- Type Parameters:
T- the functional interface type tokenU- the type of the generated return value of the functional interface method- Parameters:
lambdaType- a functional interface type tokenreturnValueGenerator- a generator for the return type of the functional interface's single methodstatus- an object to be passed along to the generator that will produce the functional interface's method return value- Returns:
- an instance of the functional interface type, whose single method will return a generated value
- Throws:
IllegalArgumentException- iflambdaTypeis not a functional interface type
-