Class TypeLiteral<T>
java.lang.Object
cloud.opencode.base.reflect.type.TypeLiteral<T>
- Type Parameters:
T- the type to capture | 要捕获的类型
Type Literal (Alternative to TypeToken)
类型字面量(TypeToken的替代)
A simpler alternative to TypeToken for capturing generic types. Similar to Commons Lang TypeLiteral.
用于捕获泛型类型的更简单的TypeToken替代方案。 类似于Commons Lang TypeLiteral。
Usage Examples | 使用示例:
TypeLiteral<List<String>> type = new TypeLiteral<List<String>>() {};
Type actualType = type.getType();
Features | 主要功能:
- Generic type capture via anonymous subclass - 通过匿名子类捕获泛型类型
- Raw type extraction - 原始类型提取
- Type equality comparison - 类型相等比较
Security | 安全性:
- Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
- Null-safe: No (must be created with type parameter) - 空值安全: 否(必须带类型参数创建)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a TypeLiteral by capturing generic type 通过捕获泛型类型创建TypeLiteral -
Method Summary
-
Constructor Details
-
TypeLiteral
protected TypeLiteral()Creates a TypeLiteral by capturing generic type 通过捕获泛型类型创建TypeLiteral
-
-
Method Details
-
getType
-
getRawType
-
toTypeToken
-
equals
-
hashCode
-
toString
-