Interface MethodAccessor<T extends Executable>
- Type Parameters:
T- the type of the underlying executable, either a method or constructor.
- All Superinterfaces:
BaseAccessor<T>
- All Known Implementing Classes:
BareAccessorFactory.BareConstructorAccessor,BareAccessorFactory.BareMethodAccessor,MethodHandleAccessorFactory.MethodHandleConstructorAccessor,MethodHandleAccessorFactory.MethodHandleMethodAccessor
An accessor which wraps a java.lang.reflect Method and makes it much easier to invoke it.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescription<V> @NotNull Result<V> invoke()Invokes the underlying method using the instance the reflexion object used to create this accessor is bound to (if the method is not static).<V> @NotNull Result<V> Invokes the underlying method using the given instance.<V> @NotNull Result<V> Invokes the underlying method using the given instance.<V> @NotNull Result<V> invokeWithArgs(@NotNull Object... args) Invokes the underlying method using the instance the reflexion object used to create this accessor is bound to (if the method is not static).Methods inherited from interface dev.derklaro.reflexion.BaseAccessor
getMember, getReflexion
-
Method Details
-
invoke
Invokes the underlying method using the instance the reflexion object used to create this accessor is bound to (if the method is not static). This method never throws an exception all exceptions are given back to the caller in the returned result instance.This method invokes the wrapped method without any arguments.
- Type Parameters:
V- the type of values returned by the wrapped method.- Returns:
- the result instance of the invocation, either holding the result of the method or any exception thrown.
-
invoke
Invokes the underlying method using the given instance. This method never throws an exception all exceptions are given back to the caller in the returned result instance.This method invokes the wrapped method without any arguments. The given instance should be present in case the method is not static, and the associated reflexion instance has no instance bound to it. If an instance is given in case the method is static, the instance will be ignored silently.
- Type Parameters:
V- the type of values returned by the wrapped method.- Parameters:
instance- the instance to invoke the wrapped method on.- Returns:
- the result instance of the invocation, either holding the result of the method or any exception thrown.
-
invokeWithArgs
Invokes the underlying method using the instance the reflexion object used to create this accessor is bound to (if the method is not static). This method never throws an exception all exceptions are given back to the caller in the returned result instance.- Type Parameters:
V- the type of values returned by the wrapped method.- Parameters:
args- the arguments to use on when invoking the wrapped method.- Returns:
- the result instance of the invocation, either holding the result of the method or any exception thrown.
-
invoke
@NotNull <V> @NotNull Result<V> invoke(@Nullable @Nullable Object instance, @NotNull @NotNull Object... args) Invokes the underlying method using the given instance. This method never throws an exception all exceptions are given back to the caller in the returned result instance.The given instance should be present in case the method is not static, and the associated reflexion instance has no instance bound to it. If an instance is given in case the method is static, the instance will be ignored silently.
- Type Parameters:
V- the type of values returned by the wrapped method.- Parameters:
instance- the instance to invoke the wrapped method on.args- the arguments to use on when invoking the wrapped method.- Returns:
- the result instance of the invocation, either holding the result of the method or any exception thrown.
-