Enum Class TokenType

java.lang.Object
java.lang.Enum<TokenType>
cloud.opencode.base.expression.parser.TokenType
All Implemented Interfaces:
Serializable, Comparable<TokenType>, Constable

public enum TokenType extends Enum<TokenType>
Token Type Enum 词法单元类型枚举

Represents the types of tokens in expression parsing.

表示表达式解析中的词法单元类型。

Features | 主要功能:

  • Literal types: NUMBER, STRING, BOOLEAN, NULL - 字面量类型
  • Operators: arithmetic, comparison, logical, assignment - 运算符: 算术、比较、逻辑、赋值
  • Punctuation: parentheses, brackets, braces, dot, comma - 标点: 括号、方括号、花括号、点、逗号
  • Special: SAFE_NAV, FILTER, PROJECT, MATCHES, INSTANCEOF - 特殊: 空安全导航、过滤、投影、匹配、instanceof

Usage Examples | 使用示例:

Token token = Token.of(TokenType.NUMBER, 42, 0, 2);
if (token.is(TokenType.NUMBER)) {
    Number value = token.numberValue();
}

Security | 安全性:

  • Thread-safe: Yes, immutable enum - 线程安全: 是,不可变枚举
  • Null-safe: N/A - 空值安全: 不适用
Since:
JDK 25, opencode-base-expression V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Enum Constant Details

  • Method Details

    • values

      public static TokenType[] 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 TokenType 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