Package com.storedobject.common
Class CustomMethodInvoker
java.lang.Object
com.storedobject.common.CustomMethodInvoker
- All Implemented Interfaces:
MethodInvoker
- Direct Known Subclasses:
StyledMethodInvoker
An abstract base class that provides a customizable method invocation framework
with support for caching the return type of the invoked method and handling
attribute name assignment. This class implements the
MethodInvoker interface
and provides additional capabilities while delegating core behaviors to the interface.- Author:
- Syam
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for the CustomMethodInvoker class.CustomMethodInvoker(String attributeName) Constructs a new instance of CustomMethodInvoker with the specified attribute name. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the name of an attribute associated with this method.Class<?> Determines the return type of the `invoke` method defined in the implementing class.Invokes a method on the provided object with an optional logging behavior for errors.
-
Constructor Details
-
CustomMethodInvoker
public CustomMethodInvoker()Default constructor for the CustomMethodInvoker class. Initializes a new instance with a null attribute name. This constructor delegates to the parameterized constructor to ensure a consistent initialization process. -
CustomMethodInvoker
Constructs a new instance of CustomMethodInvoker with the specified attribute name.- Parameters:
attributeName- the name of the attribute to be associated with the method invoker, or null if no attribute name is specified.
-
-
Method Details
-
getAttributeName
Description copied from interface:MethodInvokerRetrieves the name of an attribute associated with this method.- Specified by:
getAttributeNamein interfaceMethodInvoker- Returns:
- a string representing the attribute name, or null if no attribute name is defined.
-
getReturnType
Description copied from interface:MethodInvokerDetermines the return type of the `invoke` method defined in the implementing class. If the `invoke` method cannot be located or an exception occurs, defaults to returningString.class.- Specified by:
getReturnTypein interfaceMethodInvoker- Returns:
- the
Classobject representing the return type of the `invoke` method orString.classif the method is not found or an error occurs.
-
invoke
Description copied from interface:MethodInvokerInvokes a method on the provided object with an optional logging behavior for errors.- Specified by:
invokein interfaceMethodInvoker- Parameters:
object- the object on which the method is to be invokedlogError- a boolean flag indicating whether errors during invocation should be logged- Returns:
- the result of the method invocation, or null if the invocation fails
-