类 TypeUtils
java.lang.Object
io.agentscope.core.util.TypeUtils
Utility class for type-safe operations.
-
方法概要
-
方法详细资料
-
safeCast
Safely cast an object to the specified type.- 类型参数:
T- The target type- 参数:
obj- The object to castclazz- The target class- 返回:
- The casted object
- 抛出:
ClassCastException- if the object is not an instance of the target class
-
safeCastOptional
Safely cast an object to the specified type, returning Optional.- 类型参数:
T- The target type- 参数:
obj- The object to castclazz- The target class- 返回:
- Optional containing the casted object, or empty if cast fails
-