接口 TypeConverter
-
- 所有已知子接口:
TypeConverterSupport
- 所有已知实现类:
TypeConverterSupportImpl
public interface TypeConverter定义了类型转换方法的接口
-
-
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 default <T> TconvertIfNecessary(@Nullable Object source, @NotNull TypeDescriptor typeDescriptor)将该值转换为所需的类型default <T> TconvertIfNecessary(@Nullable Object source, @NotNull Class<T> requiredType)将该值转换为所需的类型<T> TconvertIfNecessary(@Nullable Object source, @Nullable Class<T> requiredType, @Nullable TypeDescriptor typeDescriptor)将该值转换为所需的类型
-
-
-
方法详细资料
-
convertIfNecessary
@Nullable default <T> T convertIfNecessary(@Nullable @Nullable Object source, @NotNull @NotNull Class<T> requiredType) throws TypeMismatchException将该值转换为所需的类型- 参数:
source- 要转换的值requiredType- 必须转换为的类型- 返回:
- 类型转换的结果
- 抛出:
TypeMismatchException- 如果类型转换失败,则抛出该例外
-
convertIfNecessary
@Nullable default <T> T convertIfNecessary(@Nullable @Nullable Object source, @NotNull @NotNull TypeDescriptor typeDescriptor) throws TypeMismatchException将该值转换为所需的类型- 参数:
source- 要转换的值typeDescriptor- 要使用的类型描述符- 返回:
- 类型转换的结果
- 抛出:
TypeMismatchException- 如果类型转换失败,则抛出该例外
-
convertIfNecessary
@Nullable <T> T convertIfNecessary(@Nullable @Nullable Object source, @Nullable @Nullable Class<T> requiredType, @Nullable @Nullable TypeDescriptor typeDescriptor) throws TypeMismatchException将该值转换为所需的类型注意:requiredType 或 typeDescriptor 必须有一个不为空!
- 参数:
source- 要转换的值requiredType- 必须转换为的类型 (如果不知道,则为null,例如在集合元素的情况下)typeDescriptor- 要使用的类型描述符(可能是null))- 返回:
- 类型转换的结果
- 抛出:
TypeMismatchException- 如果类型转换失败,则抛出该例外
-
-