Record Class ReflectionExecutor
java.lang.Object
java.lang.Record
pro.verron.officestamper.core.ReflectionExecutor
- Record Components:
object- the object on which to invoke the method.method- the method to invoke.
- All Implemented Interfaces:
org.springframework.expression.MethodExecutor
public record ReflectionExecutor(Object object, Method method)
extends Record
implements org.springframework.expression.MethodExecutor
A record encapsulating an object and a method, and providing functionality to execute the method on the given object
using reflection. This record implements the
MethodExecutor interface and serves as a mechanism to invoke methods
dynamically.-
Constructor Summary
ConstructorsConstructorDescriptionReflectionExecutor(Object object, Method method) Creates an instance of aReflectionExecutorrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.org.springframework.expression.TypedValueexecute(org.springframework.expression.EvaluationContext context, Object target, @Nullable Object... arguments) Executes the provided method on the given object using the specified arguments.final inthashCode()Returns a hash code value for this object.method()Returns the value of themethodrecord component.object()Returns the value of theobjectrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ReflectionExecutor
-
-
Method Details
-
execute
public org.springframework.expression.TypedValue execute(org.springframework.expression.EvaluationContext context, Object target, @Nullable Object... arguments) throws org.springframework.expression.AccessException Executes the provided method on the given object using the specified arguments. This method utilizes reflection to invoke the target method dynamically.- Specified by:
executein interfaceorg.springframework.expression.MethodExecutor- Parameters:
context- the evaluation context in which this execution occurs.target- the target object on which the method should be invoked.arguments- the arguments to be passed to the method during invocation.- Returns:
- a TypedValue wrapping the result of the invoked method.
- Throws:
org.springframework.expression.AccessException- if the method cannot be accessed or invoked, or if an error occurs during invocation.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
object
-
method
-