Enum Class Terminator.TerminationStrategy

java.lang.Object
java.lang.Enum<Terminator.TerminationStrategy>
eu.svjatoslav.commons.string.tokenizer.Terminator.TerminationStrategy
All Implemented Interfaces:
Serializable, Comparable<Terminator.TerminationStrategy>, Constable
Enclosing class:
Terminator

public static enum Terminator.TerminationStrategy extends Enum<Terminator.TerminationStrategy>
Defines how matched tokens are handled by the tokenizer.
  • Enum Constant Details

    • PRESERVE

      public static final Terminator.TerminationStrategy PRESERVE
      Preserve the matched token and return it for processing.

      Use this for tokens you want to capture and handle in your parsing logic, such as keywords, operators, literals, or other syntax elements.

      Example use cases:

      • Keywords: "if", "else", "while"
      • Operators: "+", "-", "==", "<"
      • Literals: numbers, quoted strings
      • Delimiters: parentheses, brackets
    • DROP

      public static final Terminator.TerminationStrategy DROP
      Drop the matched token silently without returning it.

      Use this for tokens that act as separators or noise that you don't need to process, such as whitespace or comments.

      Example use cases:

      • Whitespace: spaces, tabs, newlines
      • Comments: "// ...", "/* ... */"
      • Optional separators that don't affect parsing

      Dropped tokens still separate other tokens - they're just not returned by getNextToken().

  • Method Details

    • values

      public static Terminator.TerminationStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Terminator.TerminationStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null