Class TransformerPerformer

java.lang.Object
de.craftsblock.craftsnet.api.transformers.TransformerPerformer

public class TransformerPerformer extends Object

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 Details

    • TransformerPerformer

      public TransformerPerformer(@NotNull @NotNull CraftsNet craftsNet, @Nullable @Nullable Pattern validator, int argsOffset)
      Constructor for TransformerPerformer.
      Parameters:
      craftsNet - The CraftsNet instance which instantiates this
      validator - 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 this
      validator - The pattern used for validation.
      argsOffset - The offset for arguments.
      callback - The callback responsible for handling transformer exception.
  • Method Details

    • setValidator

      public void setValidator(@Nullable @Nullable Pattern validator)
      Updates the validator which is used to load the group names from.
      Parameters:
      validator - The new validator.
    • perform

      public Object[] perform(Handler handler, Method method, Object[] args) throws Exception
      Performs transformations on method arguments.
      Parameters:
      handler - The handler on which the performer should be performed
      method - 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

      public boolean hasTransformers(Object obj)
      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:
      true if there are transformers present, false otherwise
    • clearCache

      public void clearCache()
      Clears the transformer cache.
    • getArgsOffset

      public int getArgsOffset()
      Gets the arguments offset.
      Returns:
      The arguments offset.