Package com.storedobject.common
Interface MethodInvoker
- All Known Implementing Classes:
CustomMethodInvoker,SerialNumberMethodInvoker,SimpleMethodInvoker,StoredObjectUtility.MethodList,StyledMethodInvoker
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A functional interface designed for invoking a method on a given object.
It provides additional utility methods for obtaining information about the method
and formatting the result.
- Author:
- Syam
-
Method Summary
Modifier and TypeMethodDescriptionfunction()Creates aFunctionthat applies theinvokemethod to a given object.function(boolean logError) Creates aFunctionthat applies theinvokemethod to a given object, with an optional logging behavior for errors during method invocation.default StringRetrieves the name of an attribute associated with this method.default Class<?> Determines the return type of the `invoke` method defined in the implementing class.default MethodgetTail()Retrieves the tail method associated with the implementation.Invokes a method on the provided object.default ObjectInvokes a method on the provided object with an optional logging behavior for errors.string()Creates aFunctionthat takes anObjectas input and converts the result of invoking a method on the object into aString.string(boolean logError) Creates aFunctionthat takes anObjectas input, applies theinvokemethod to the input object with an optional logging behavior for errors, and converts the result into aString.
-
Method Details
-
getAttributeName
Retrieves the name of an attribute associated with this method.- Returns:
- a string representing the attribute name, or null if no attribute name is defined.
-
getTail
Retrieves the tail method associated with the implementation. The tail method typically represents an additional or final processing method in the context of the functional interface's behavior.- Returns:
- the
Methodinstance representing the tail method, ornullif no such method is defined.
-
invoke
-
getReturnType
Determines 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.- Returns:
- the
Classobject representing the return type of the `invoke` method orString.classif the method is not found or an error occurs.
-
invoke
Invokes a method on the provided object with an optional logging behavior for errors.- 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
-
function
Creates aFunctionthat applies theinvokemethod to a given object. This version of thefunction()method does not log errors during invocation.- Returns:
- a
Functionthat takes anObjectas input and produces a result by invoking theinvokemethod on the input object without logging errors.
-
function
Creates aFunctionthat applies theinvokemethod to a given object, with an optional logging behavior for errors during method invocation.- Parameters:
logError- a boolean flag indicating whether errors during invocation should be logged- Returns:
- a
Functionthat takes anObjectas input and produces a result by invoking theinvokemethod on the input object, with error logging behavior determined by thelogErrorparameter
-
string
Creates aFunctionthat takes anObjectas input and converts the result of invoking a method on the object into aString. This method does not log errors during the invocation process.- Returns:
- a
Functionthat applies theinvokemethod to a given object, converts the result to aString, and does not log errors during the process.
-
string
Creates aFunctionthat takes anObjectas input, applies theinvokemethod to the input object with an optional logging behavior for errors, and converts the result into aString.- Parameters:
logError- a boolean flag indicating whether errors during invocation should be logged- Returns:
- a
Functionthat applies theinvokemethod to the input object, converts the result to aString, with error logging behavior determined by thelogErrorparameter
-