Class TypeReference<T>
java.lang.Object
cloud.opencode.base.core.convert.TypeReference<T>
- Type Parameters:
T- the type to capture - 要捕获的类型
Type Reference - Captures generic type information at runtime
类型引用 - 运行时捕获泛型类型信息
Uses anonymous class pattern to preserve full generic type information.
使用匿名类方式创建,保留完整的泛型类型信息。
Features | 主要功能:
- Captures parameterized types - 捕获参数化类型
- Provides raw type access - 提供原始类型访问
- Enables type-safe generic conversions - 支持类型安全的泛型转换
Usage Examples | 使用示例:
// Capture List<String> type - 捕获 List<String> 类型
TypeReference<List<String>> ref = new TypeReference<List<String>>() {};
Type type = ref.getType(); // java.util.List<java.lang.String>
Class<?> raw = ref.getRawType(); // java.util.List
// Use with conversion - 用于转换
List<String> result = Convert.convert(value, new TypeReference<List<String>>() {});
Security | 安全性:
- Thread-safe: Yes (immutable after creation) - 线程安全: 是(创建后不可变)
- Null-safe: No, type must not be null - 空值安全: 否,类型不可为null
- Since:
- JDK 25, opencode-base-core V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
TypeReference
protected TypeReference()
-
-
Method Details
-
getType
Gets the full generic type 获取完整的泛型类型 -
getRawType
-
toString
-