Class SimpleInvokeFactory<F,T>
java.lang.Object
ru.progrm_jarvis.javacommons.invoke.SimpleInvokeFactory<F,T>
- Type Parameters:
F- type of functional interface implementedT- type of target value
- All Implemented Interfaces:
InvokeFactory<F,T>
Simple implementation of
InvokeFactory.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MethodTypeImplemented functional interfaceprotected StringName of the functional interface's functional methodprotected MethodTypeSignature of the functional interface's functional methodprotected LookupFactoryUsed lookup factoryprotected Function<MethodHandles.Lookup,MethodHandle> Factory creating implementation method handle using the given lookupprotected @Nullable ObjectTargetTarget class containing the implementation method -
Method Summary
Modifier and TypeMethodDescriptionBinds the method call to the specified instance.create()Creates the implementation of the functional interface.implementing(@NonNull MethodType functionalInterface, @NonNull String functionalMethodName, @NonNull MethodType functionalMethodSignature) Specifies the functional interface implemented.static <F,T> @NotNull InvokeFactory<F, T> Creates a new simpleinvoke factory.toString()unbound()Unbinds the method call from instance (making it static).using(@NonNull LookupFactory lookupFactory) Specifies the lookup factory to be used for creation of lookupvia(@NonNull Class<? extends T> targetClass, @NonNull Function<MethodHandles.Lookup, MethodHandle> methodHandleCreator) Specifies the target class with function which will be used to create a relatedMethodHandle.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ru.progrm_jarvis.javacommons.invoke.InvokeFactory
createUnsafely, implementing, implementing, via, via
-
Field Details
-
lookupFactory
Used lookup factory -
functionalInterface
Implemented functional interface -
functionalMethodSignature
Signature of the functional interface's functional method -
functionalMethodName
Name of the functional interface's functional method -
methodHandleCreator
Factory creating implementation method handle using the given lookup -
targetClass
Target class containing the implementation method -
target
Target
-
-
Method Details
-
newInstance
Creates a new simpleinvoke factory.- Type Parameters:
F- type of functional interface implementedT- type of target value- Returns:
- created invoke factory
-
using
Description copied from interface:InvokeFactorySpecifies the lookup factory to be used for creation of lookup- Specified by:
usingin interfaceInvokeFactory<F,T> - Parameters:
lookupFactory- lookup factory to be used for creation of lookup- Returns:
- this invoke factory
-
implementing
public InvokeFactory<F,T> implementing(@NonNull @NonNull MethodType functionalInterface, @NonNull @NonNull String functionalMethodName, @NonNull @NonNull MethodType functionalMethodSignature) Description copied from interface:InvokeFactorySpecifies the functional interface implemented.- Specified by:
implementingin interfaceInvokeFactory<F,T> - Parameters:
functionalInterface- type of the implemented functional interface (always has return type and no parameters)functionalMethodName- name of the implemented functional methodfunctionalMethodSignature- signature of the implemented functional method- Returns:
- this invoke factory
-
via
public InvokeFactory<F,T> via(@NonNull @NonNull Class<? extends T> targetClass, @NonNull @NonNull Function<MethodHandles.Lookup, MethodHandle> methodHandleCreator) Description copied from interface:InvokeFactorySpecifies the target class with function which will be used to create a relatedMethodHandle.- Specified by:
viain interfaceInvokeFactory<F,T> - Parameters:
targetClass- class to whom the method-handle relatesmethodHandleCreator- function creating aMethodHandleusing the given lookup- Returns:
- this invoke factory
- See Also:
-
boundTo
Description copied from interface:InvokeFactoryBinds the method call to the specified instance.- Specified by:
boundToin interfaceInvokeFactory<F,T> - Parameters:
target- instance of the target class to use for non-static invocation ornullto unbound (make the call static)- Returns:
- this invoke factory
-
unbound
Description copied from interface:InvokeFactoryUnbinds the method call from instance (making it static).- Specified by:
unboundin interfaceInvokeFactory<F,T> - Returns:
- this invoke factory
-
create
Description copied from interface:InvokeFactoryCreates the implementation of the functional interface.- Specified by:
createin interfaceInvokeFactory<F,T> - Returns:
- implemented functional interface
- Throws:
IllegalStateException- if any of the required factory properties has not been setThrowable- if an exception occurs while creating an implementation of the functional interface
-
toString
-