com.pholser.junit.quickcheck.generator
Class Lambdas

java.lang.Object
  extended by com.pholser.junit.quickcheck.generator.Lambdas

public final class Lambdas
extends Object

Helper class for creating instances of "functional interfaces".


Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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 perturb a random generator that will be used to generate the return value of that method.

junit-quickcheck uses this to create random values for theory parameters whose type is determined to be a "functional interface" (an interface with a single abstract method that does not override a method from Object. Custom generators for functional interface types can use this also.

Type Parameters:
T - the functional interface type token
U - the type of the generated return value of the functional interface method
Parameters:
lambdaType - a functional interface type token
returnValueGenerator - a generator for the return type of the functional interface's single method
status - 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 - if lambdaType is not a functional interface type


Copyright © 2013. All Rights Reserved.