Record Class TransformTokenAction

java.lang.Object
java.lang.Record
net.luis.utils.io.token.rule.actions.TransformTokenAction
Record Components:
transformer - The transformer to apply to tokens
All Implemented Interfaces:
TokenAction

public record TransformTokenAction(@NotNull TokenTransformer transformer) extends Record implements TokenAction
Token action that transforms the tokens using a transformer.
The transformer is applied to the tokens, and the result is returned as an immutable list of tokens.
See Also:
  • Field Details

  • Constructor Details

    • TransformTokenAction

      public TransformTokenAction(@NotNull @NotNull TokenTransformer transformer)
      Constructs a new transform token action with the given transformer.
      Parameters:
      transformer - The transformer to apply to tokens
      Throws:
      NullPointerException - If the transformer is null
  • Method Details

    • apply

      @NotNull public @NotNull @Unmodifiable List<Token> apply(@NotNull @NotNull TokenRuleMatch match)
      Description copied from interface: TokenAction
      Applies this token action to the given token rule match.
      The action can modify, transform or remove the tokens of the match.
      Specified by:
      apply in interface TokenAction
      Parameters:
      match - The token rule match to apply the action to
      Returns:
      The resulting immutable list of tokens after applying the action
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • transformer

      @NotNull public @NotNull TokenTransformer transformer()
      Returns the value of the transformer record component.
      Returns:
      the value of the transformer record component