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
Defines how matched tokens are handled by the tokenizer.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionReturns the enum constant of this class with the specified name.static Terminator.TerminationStrategy[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
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
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
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
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 nameNullPointerException- if the argument is null
-