Package com.storedobject.common
Class StyledMethodInvoker
java.lang.Object
com.storedobject.common.CustomMethodInvoker
com.storedobject.common.StyledMethodInvoker
- All Implemented Interfaces:
MethodInvoker
An abstract class that facilitates invocation of methods while allowing for
the use of a styled builder for result processing. This class extends the
CustomMethodInvoker and provides additional abstraction for creating
and populating a StyledBuilder.
The StyledMethodInvoker is responsible for:
- Overriding the default return type of the method invocation toStyledBuilder. - Defining the contracts for creating aStyledBuilderand building it with a given object.
- Author:
- Syam
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StyledBuilderbuild(Object object, StyledBuilder builder) Builds and populates aStyledBuilderinstance using the given object and builder.abstract StyledBuilderCreates and returns a new instance ofStyledBuilder.Class<?> Determines the return type of the `invoke` method defined in the implementing class.final StyledBuilderInvokes a method on the provided object.Methods inherited from class com.storedobject.common.CustomMethodInvoker
getAttributeName, invoke
-
Constructor Details
-
StyledMethodInvoker
public StyledMethodInvoker()Constructs a new instance ofStyledMethodInvoker. This constructor initializes the object without any parameters. Being part of an abstract class, it serves as a base for subclass implementations that define specific behavior for creating and populating aStyledBuilder.
-
-
Method Details
-
invoke
Description copied from interface:MethodInvokerInvokes a method on the provided object.- Parameters:
object- the object on which the method is to be invoked- Returns:
- the result of the method invocation, or null if the invocation fails
-
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- Overrides:
getReturnTypein classCustomMethodInvoker- Returns:
- the
Classobject representing the return type of the `invoke` method orString.classif the method is not found or an error occurs.
-
createBuilder
Creates and returns a new instance ofStyledBuilder. This method should be implemented by subclasses to provide the specific logic for creating a newStyledBuilderinstance, which can then be used in conjunction with other methods likebuild(Object, StyledBuilder)for further processing.- Returns:
- A new instance of
StyledBuilder.
-
build
Builds and populates aStyledBuilderinstance using the given object and builder. This method is abstract and must be implemented by the subclass to define the actual logic for how theStyledBuilderis constructed and modified.- Parameters:
object- The object to be used for building or populating theStyledBuilder. This may act as the source of data or context for the builder.builder- TheStyledBuilderinstance that will be populated or modified. This builder is expected to have been created beforehand, often usingcreateBuilder().- Returns:
- A fully constructed and modified
StyledBuilderinstance, ready for use or further processing.
-