Class EndTokenRule

java.lang.Object
net.luis.utils.io.token.rule.rules.EndTokenRule
All Implemented Interfaces:
TokenRule

@Singleton public final class EndTokenRule extends Object implements TokenRule
A token rule that always matches the end of the token list.
This rule is useful to ensure that the end of the token list is reached.
The rule will only match if the start index is larger than or equal to the size of the token list.
This class is implemented as a singleton and can be accessed via TokenRules.end() or INSTANCE.
  • Field Details

    • INSTANCE

      public static final EndTokenRule INSTANCE
      The singleton instance of this class.
  • Constructor Details

    • EndTokenRule

      private EndTokenRule()
      Private constructor to prevent instantiation.
  • Method Details

    • match

      @Nullable public @Nullable TokenRuleMatch match(@NotNull @NotNull List<Token> tokens, int startIndex)
      Description copied from interface: TokenRule
      Checks if the given tokens match this rule starting from the specified index.
      If the match is successful, a TokenRuleMatch is returned, otherwise null.
      Specified by:
      match in interface TokenRule
      Parameters:
      tokens - The list of tokens to match against
      startIndex - The index to start matching from
      Returns:
      A token rule match if successful, otherwise null