Record Class TokenRuleMatch

java.lang.Object
java.lang.Record
net.luis.utils.io.token.rule.TokenRuleMatch
Record Components:
startIndex - The start index of the match
endIndex - The end index of the match (exclusive)
matchedTokens - The list of matched tokens
matchingTokenRule - The matching token rule

public record TokenRuleMatch(int startIndex, int endIndex, @NotNull List<Token> matchedTokens, @NotNull TokenRule matchingTokenRule) extends Record
A class that represents a match of a token rule.
It contains the start and end index of the match, the matched tokens, and the matching token rule.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    The field for the endIndex record component.
    private final @NotNull List<Token>
    The field for the matchedTokens record component.
    private final @NotNull TokenRule
    The field for the matchingTokenRule record component.
    private final int
    The field for the startIndex record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TokenRuleMatch(int startIndex, int endIndex, @NotNull List<Token> matchedTokens, @NotNull TokenRule matchingTokenRule)
    Constructs a new token rule match with the given start and end index, matched tokens, and matching token rule.
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull TokenRuleMatch
    empty(int index)
    Creates an empty token rule match with the given index.
    An empty token rule match has a start and end index of the given index, an empty list of matched tokens, and a matching token rule that always matches.
    This is useful for terminating the token rule matching process without consuming any tokens.
    int
    Returns the value of the endIndex record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @NotNull List<Token>
    Returns the value of the matchedTokens record component.
    @NotNull TokenRule
    Returns the value of the matchingTokenRule record component.
    int
    Returns the value of the startIndex 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

    • startIndex

      private final int startIndex
      The field for the startIndex record component.
    • endIndex

      private final int endIndex
      The field for the endIndex record component.
    • matchedTokens

      @NotNull private final @NotNull List<Token> matchedTokens
      The field for the matchedTokens record component.
    • matchingTokenRule

      @NotNull private final @NotNull TokenRule matchingTokenRule
      The field for the matchingTokenRule record component.
  • Constructor Details

    • TokenRuleMatch

      public TokenRuleMatch(int startIndex, int endIndex, @NotNull @NotNull List<Token> matchedTokens, @NotNull @NotNull TokenRule matchingTokenRule)
      Constructs a new token rule match with the given start and end index, matched tokens, and matching token rule.
      Parameters:
      startIndex - The start index of the match
      endIndex - The end index of the match (exclusive)
      matchedTokens - The list of matched tokens
      matchingTokenRule - The matching token rule
      Throws:
      NullPointerException - If the matched tokens or matching token rule are null
  • Method Details

    • empty

      @NotNull public static @NotNull TokenRuleMatch empty(int index)
      Creates an empty token rule match with the given index.
      An empty token rule match has a start and end index of the given index, an empty list of matched tokens, and a matching token rule that always matches.
      This is useful for terminating the token rule matching process without consuming any tokens.
      Parameters:
      index - The index of the empty token rule match
      Returns:
      An empty token rule match
      See Also:
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • startIndex

      public int startIndex()
      Returns the value of the startIndex record component.
      Returns:
      the value of the startIndex record component
    • endIndex

      public int endIndex()
      Returns the value of the endIndex record component.
      Returns:
      the value of the endIndex record component
    • matchedTokens

      @NotNull public @NotNull List<Token> matchedTokens()
      Returns the value of the matchedTokens record component.
      Returns:
      the value of the matchedTokens record component
    • matchingTokenRule

      @NotNull public @NotNull TokenRule matchingTokenRule()
      Returns the value of the matchingTokenRule record component.
      Returns:
      the value of the matchingTokenRule record component