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

public final class Lambdas extends Object
Helper class for creating instances of "functional interfaces".
  • 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 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