public class LambdaFactory extends Object
| Modifier and Type | Method and Description |
|---|---|
<T> T |
createLambda(String code,
TypeReference<T> typeReference)
Creates lambda from the given code.
|
<T> T |
createLambdaUnchecked(String code,
TypeReference<T> type)
Convenience wrapper for
createLambda(String, TypeReference)
which throws unchecked exception instead of checked one. |
static LambdaFactory |
get()
Returns a LambdaFactory instance with default configuration.
|
static LambdaFactory |
get(LambdaFactoryConfiguration configuration)
Returns a LambdaFactory instance with the given configuration.
|
public static LambdaFactory get()
JavaCompilerNotFoundException - if the library cannot find any java compilerpublic static LambdaFactory get(LambdaFactoryConfiguration configuration)
JavaCompilerNotFoundException - if the library cannot find any java compiler and it's not provided
in the configurationpublic <T> T createLambda(String code, TypeReference<T> typeReference) throws LambdaCreationException
T - type of the lambda you want to getcode - source of the lambda as you would write it in Java expression {TYPE} lambda = ({CODE});typeReference - a subclass of TypeReference class with the generic argument representing the type of the lambda
, for example new TypeReference<Function<Integer,Integer>>(){}; LambdaCreationException - when anything goes wrong (no other exceptions are thrown including runtimes),
if the exception was caused by compilation failure it will contain a CompilationDetails instance describing thempublic <T> T createLambdaUnchecked(String code, TypeReference<T> type)
createLambda(String, TypeReference)
which throws unchecked exception instead of checked one.createLambda(String, TypeReference)Copyright © 2016. All rights reserved.