Class TransformerPerformer
java.lang.Object
de.craftsblock.craftsnet.api.transformers.TransformerPerformer
The TransformerPerformer class is responsible for performing transformations on method arguments based on provided annotations. It serves as a central component in the transformation process within the CraftsNet API.
Transformations are essential for converting and validating input data before it is processed by various methods.
This class facilitates the application of transformers defined by annotations such as Transformer and TransformerCollection,
allowing for dynamic and customizable data processing.
- Since:
- 3.0.3-SNAPSHOT
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTransformerPerformer(@NotNull CraftsNet craftsNet, @Nullable Pattern validator, int argsOffset) Constructor for TransformerPerformer.TransformerPerformer(@NotNull CraftsNet craftsNet, @Nullable Pattern validator, int argsOffset, @Nullable TransformerErrorCallback callback) Constructor for TransformerPerformer. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the transformer cache.intGets the arguments offset.booleanhasTransformers(Object obj) Checks whether transformers are present in a method or class.Object[]Performs transformations on method arguments.voidsetValidator(@Nullable Pattern validator) Updates the validator which is used to load the group names from.
-
Constructor Details
-
TransformerPerformer
public TransformerPerformer(@NotNull @NotNull CraftsNet craftsNet, @Nullable @Nullable Pattern validator, int argsOffset) Constructor for TransformerPerformer.- Parameters:
craftsNet- The CraftsNet instance which instantiates thisvalidator- The pattern used for validation.argsOffset- The offset for arguments.
-
TransformerPerformer
public TransformerPerformer(@NotNull @NotNull CraftsNet craftsNet, @Nullable @Nullable Pattern validator, int argsOffset, @Nullable @Nullable TransformerErrorCallback callback) Constructor for TransformerPerformer.- Parameters:
craftsNet- The CraftsNet instance which instantiates thisvalidator- The pattern used for validation.argsOffset- The offset for arguments.callback- The callback responsible for handling transformer exception.
-
-
Method Details
-
setValidator
Updates the validator which is used to load the group names from.- Parameters:
validator- The new validator.
-
perform
Performs transformations on method arguments.- Parameters:
handler- The handler on which the performer should be performedmethod- The method to perform transformations on.args- The arguments containing the transform targets.- Returns:
- An array of transformed arguments.
- Throws:
NoSuchMethodException- if the transformer method could not be found.InstantiationException- if no new instance of the Transformable can be created.IllegalAccessException- if access to the constructor of Transformable or access to the method Transformable.transform(String) is restricted.IOException- if an I/O error occurs.InvocationTargetException- if the underlying method throws an exception.Exception
-
hasTransformers
Checks whether transformers are present in a method or class.- Parameters:
obj- The method or the handler which contains the information about the transformers.- Returns:
trueif there are transformers present,falseotherwise
-
clearCache
public void clearCache()Clears the transformer cache. -
getArgsOffset
public int getArgsOffset()Gets the arguments offset.- Returns:
- The arguments offset.
-