public class LambdaFactory
extends java.lang.Object
LambdaMetafactory.metafactory(java.lang.invoke.MethodHandles.Lookup, String, MethodType, MethodType, MethodHandle, MethodType).
| 构造器和说明 |
|---|
LambdaFactory() |
| 限定符和类型 | 方法和说明 |
|---|---|
static com.hervian.lambda.Lambda |
create(java.lang.reflect.Method method)
creates a Lambda with the same access rights as a Method with setAccessible()==true.
|
static <T> T |
create(java.lang.reflect.Method method,
java.lang.Class<T> interfaceClass,
java.lang.String signatatureName)
Similar to
create(Method), except that this factory method returns a dynamically generated
implementation of the argument provided interface. |
static com.hervian.lambda.Lambda |
create(java.lang.reflect.Method method,
java.lang.invoke.MethodHandles.Lookup lookup)
Same as
create(Method) but with an extra parameter that allows for more fine grained configuration of the access rights
of the generated Lambda implementation. |
static <T> T |
create(java.lang.reflect.Method method,
java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.Class<T> interfaceClass,
java.lang.String signatatureName)
Same as
create(Method, Class, String), but with an additional parameter in the form of a Lookup object. |
static <T> T |
createLambda(java.lang.reflect.Method method,
java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.Class<T> interfaceClass,
java.lang.String signatatureName,
boolean createSpecial) |
static com.hervian.lambda.Lambda |
createSpecial(java.lang.reflect.Method method)
Same as
create(Method) except that this method returns a Lambda that will not be subject to dynamic method dispatch. |
static <T> T |
createSpecial(java.lang.reflect.Method method,
java.lang.Class<T> interfaceClass,
java.lang.String signatatureName)
Same as
create(Method) except that this method returns a Lambda that will not be subject to dynamic method dispatch. |
static com.hervian.lambda.Lambda |
createSpecial(java.lang.reflect.Method method,
java.lang.invoke.MethodHandles.Lookup lookup)
Same as
create(Method, java.lang.invoke.MethodHandles.Lookup) except that this method returns a Lambda that will not be subject to dynamic method dispatch. |
static <T> T |
createSpecial(java.lang.reflect.Method method,
java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.Class<T> interfaceClass,
java.lang.String signatatureName) |
public static com.hervian.lambda.Lambda create(java.lang.reflect.Method method)
throws java.lang.Throwable
method - A Method object which defines what to invoke.java.lang.Throwablepublic static com.hervian.lambda.Lambda createSpecial(java.lang.reflect.Method method)
throws java.lang.Throwable
create(Method) except that this method returns a Lambda that will not be subject to dynamic method dispatch.
Example:
Let class A implement a method called 'someMethod'. And let class B extend A and override 'someMethod'.
Then, calling createSpecial(Method) with a Method object referring to A.someMethod, will return a Lambda
that calls A.someMethod, even when invoked with B as the instance.
java.lang.Throwablepublic static com.hervian.lambda.Lambda create(java.lang.reflect.Method method,
java.lang.invoke.MethodHandles.Lookup lookup)
throws java.lang.Throwable
create(Method) but with an extra parameter that allows for more fine grained configuration of the access rights
of the generated Lambda implementation.
The lookup's access rights reflect the class, which created it.
To access private methods of a class using this constructor, the Lookup must either have been created in the given class,
or the Method must have setAccessible()==true. Create a Lookup like this: MethodHandles.lookup().method - A Method object which defines what to invoke.lookup - A Lookup describing the access rights of the generated Lambda. Create a Lookup like this: MethodHandles.lookup().java.lang.Throwablepublic static com.hervian.lambda.Lambda createSpecial(java.lang.reflect.Method method,
java.lang.invoke.MethodHandles.Lookup lookup)
throws java.lang.Throwable
create(Method, java.lang.invoke.MethodHandles.Lookup) except that this method returns a Lambda that will not be subject to dynamic method dispatch.
See createSpecial(Method)java.lang.Throwablepublic static <T> T create(java.lang.reflect.Method method,
java.lang.Class<T> interfaceClass,
java.lang.String signatatureName)
throws java.lang.Throwable
create(Method), except that this factory method returns a dynamically generated
implementation of the argument provided interface.
The provided signatureName must identify a method, whose arguments corresponds to the Method. (If the Method
is a non-static method the interface method's first parameter must be an Object, and the subsequent parameters
must match the Method.)
Example:
Method method = MyClass.class.getDeclaredMethod("myStaticMethod", int.class, int.class);
IntBinaryOperator sam = LambdaFactory.create(method, IntBinaryOperator.class, "applyAsInt");
int result = sam.applyAsInt(3, 11);
method - A Method object which defines what to invoke.interfaceClass - The interface, which the dynamically generated class shall implement.signatatureName - The name of an abstract method from the interface, which the dynamically create class shall implement.java.lang.Throwablepublic static <T> T createSpecial(java.lang.reflect.Method method,
java.lang.Class<T> interfaceClass,
java.lang.String signatatureName)
throws java.lang.Throwable
create(Method) except that this method returns a Lambda that will not be subject to dynamic method dispatch.
See createSpecial(Method)java.lang.Throwablepublic static <T> T create(java.lang.reflect.Method method,
java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.Class<T> interfaceClass,
java.lang.String signatatureName)
throws java.lang.Throwable
create(Method, Class, String), but with an additional parameter in the form of a Lookup object.
See create(Method, java.lang.invoke.MethodHandles.Lookup) for a description of the Lookup parameter.method - lookup - interfaceClass - signatatureName - java.lang.Throwablepublic static <T> T createSpecial(java.lang.reflect.Method method,
java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.Class<T> interfaceClass,
java.lang.String signatatureName)
throws java.lang.Throwable
java.lang.Throwablepublic static <T> T createLambda(java.lang.reflect.Method method,
java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.Class<T> interfaceClass,
java.lang.String signatatureName,
boolean createSpecial)
throws java.lang.Throwable
java.lang.ThrowableCopyright © 2018. All Rights Reserved.