Package icu.easyj.core.convert
Class ConvertUtils
java.lang.Object
icu.easyj.core.convert.ConvertUtils
转换工具类
- Author:
- wangliang181230
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddConvert(org.springframework.core.convert.converter.Converter<?, ?> converter) 添加转换器static booleancanConvert(DataType sourceType, DataType targetType) 判断是否可以转换static booleancanConvert(Class<?> sourceType, Class<?> targetType) 判断是否可以转换static booleancanConvert(org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType) 判断是否可以转换static <T> T转换static <T> T转换static <T> T转换static <T> T转换static <T> T转换static <T> T转换static <T> List<T>convertList(Collection<?> sourceList, DataType targetType) 转换列表数据static <T> List<T>convertList(Collection<?> sourceList, Class<T> targetClass) 转换列表数据static <T> List<T>convertList(Collection<?> sourceList, org.springframework.core.convert.TypeDescriptor targetType) 转换列表数据static org.springframework.core.convert.support.DefaultConversionService获取转换服务
-
Constructor Details
-
ConvertUtils
public ConvertUtils()
-
-
Method Details
-
getConversionService
public static org.springframework.core.convert.support.DefaultConversionService getConversionService()获取转换服务- Returns:
- 转换服务
-
addConvert
public static void addConvert(@NonNull org.springframework.core.convert.converter.Converter<?, ?> converter) 添加转换器- Parameters:
converter- 转换器
-
canConvert
判断是否可以转换- Parameters:
sourceType- 源类型targetType- 目标类型- Returns:
- 是否可以转换
-
canConvert
public static boolean canConvert(@Nullable org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType) 判断是否可以转换- Parameters:
sourceType- 源类型targetType- 目标类型- Returns:
- 是否可以转换
-
canConvert
判断是否可以转换- Parameters:
sourceType- 源类型targetType- 目标类型- Returns:
- 是否可以转换
-
convert
转换- Type Parameters:
T- 目标类型- Parameters:
source- 源对象targetClass- 目标类- Returns:
- 转换后的目标类对象
- Throws:
ConvertException- 转换失败时,抛出该异常
-
convert
public static <T> T convert(@Nullable Object source, org.springframework.core.convert.TypeDescriptor targetType) 转换- Type Parameters:
T- 目标类型- Parameters:
source- 源对象targetType- 目标类描述- Returns:
- 转换后的目标类对象
-
convert
转换- Type Parameters:
T- 目标类型- Parameters:
source- 源对象targetType- 目标类描述- Returns:
- 转换后的目标类对象
-
convert
public static <T> T convert(@Nullable Object source, Class<T> targetClass, @Nullable T defaultValue) 转换- Type Parameters:
T- 目标类型- Parameters:
source- 源对象targetClass- 目标类defaultValue- 转换失败时,返回的默认值- Returns:
- 转换后的目标类对象
-
convert
public static <T> T convert(@Nullable Object source, org.springframework.core.convert.TypeDescriptor targetType, @Nullable T defaultValue) 转换- Type Parameters:
T- 目标类型- Parameters:
source- 源对象targetType- 目标类描述defaultValue- 转换失败时,返回的默认值- Returns:
- 转换后的目标类对象
-
convert
转换- Type Parameters:
T- 目标类型- Parameters:
source- 源对象targetType- 目标类描述defaultValue- 转换失败时,返回的默认值- Returns:
- 转换后的目标类对象
-
convertList
@NonNull public static <T> List<T> convertList(@Nullable Collection<?> sourceList, Class<T> targetClass) 转换列表数据- Type Parameters:
T- 目标类型- Parameters:
sourceList- 源对象列表targetClass- 目标类- Returns:
- 转换后的目标类对象列表
-
convertList
@NonNull public static <T> List<T> convertList(@Nullable Collection<?> sourceList, org.springframework.core.convert.TypeDescriptor targetType) 转换列表数据- Type Parameters:
T- 目标类型- Parameters:
sourceList- 源对象列表targetType- 目标类描述- Returns:
- 转换后的目标类对象列表
-
convertList
@NonNull public static <T> List<T> convertList(@Nullable Collection<?> sourceList, DataType targetType) 转换列表数据- Type Parameters:
T- 目标类型- Parameters:
sourceList- 源对象列表targetType- 目标类描述- Returns:
- 转换后的目标类对象列表
-