Record Class WrapTokenAction

java.lang.Object
java.lang.Record
net.luis.utils.io.token.rule.actions.WrapTokenAction
Record Components:
prefixToken - The prefix token
suffixToken - The suffix token
All Implemented Interfaces:
TokenAction

public record WrapTokenAction(@NotNull Token prefixToken, @NotNull Token suffixToken) extends Record implements TokenAction
Token action that wraps the tokens with a prefix and suffix token.
The prefix and suffix tokens are added to the beginning and end of the matched tokens, respectively.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final @NotNull Token
    The field for the prefixToken record component.
    private final @NotNull Token
    The field for the suffixToken record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    WrapTokenAction(@NotNull Token prefixToken, @NotNull Token suffixToken)
    Constructs a new wrap token action with the given prefix and suffix tokens.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull @Unmodifiable List<Token>
    apply(@NotNull TokenRuleMatch match)
    Applies this token action to the given token rule match.
    The action can modify, transform or remove the tokens of the match.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @NotNull Token
    Returns the value of the prefixToken record component.
    @NotNull Token
    Returns the value of the suffixToken record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • prefixToken

      @NotNull private final @NotNull Token prefixToken
      The field for the prefixToken record component.
    • suffixToken

      @NotNull private final @NotNull Token suffixToken
      The field for the suffixToken record component.
  • Constructor Details

    • WrapTokenAction

      public WrapTokenAction(@NotNull @NotNull Token prefixToken, @NotNull @NotNull Token suffixToken)
      Constructs a new wrap token action with the given prefix and suffix tokens.
      Parameters:
      prefixToken - The prefix token
      suffixToken - The suffix token
      Throws:
      NullPointerException - If the prefix or suffix token 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.
    • prefixToken

      @NotNull public @NotNull Token prefixToken()
      Returns the value of the prefixToken record component.
      Returns:
      the value of the prefixToken record component
    • suffixToken

      @NotNull public @NotNull Token suffixToken()
      Returns the value of the suffixToken record component.
      Returns:
      the value of the suffixToken record component