public abstract class ConvertUtils extends Object
| Constructor and Description |
|---|
ConvertUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addConvert(org.springframework.core.convert.converter.Converter<?,?> converter)
添加转换器
|
static boolean |
canConvert(Class<?> sourceType,
Class<?> targetType)
判断是否可以转换
|
static boolean |
canConvert(DataType sourceType,
DataType targetType)
判断是否可以转换
|
static boolean |
canConvert(org.springframework.core.convert.TypeDescriptor sourceType,
org.springframework.core.convert.TypeDescriptor targetType)
判断是否可以转换
|
static <T> T |
convert(Object source,
Class<T> targetClass)
转换
|
static <T> T |
convert(Object source,
Class<T> targetClass,
T defaultValue)
转换
|
static <T> T |
convert(Object source,
DataType targetType)
转换
|
static <T> T |
convert(Object source,
DataType targetType,
T defaultValue)
转换
|
static <T> T |
convert(Object source,
org.springframework.core.convert.TypeDescriptor targetType)
转换
|
static <T> T |
convert(Object source,
org.springframework.core.convert.TypeDescriptor targetType,
T defaultValue)
转换
|
static <T> List<T> |
convertList(Collection<?> sourceList,
Class<T> targetClass)
转换列表数据
|
static <T> List<T> |
convertList(Collection<?> sourceList,
DataType targetType)
转换列表数据
|
static <T> List<T> |
convertList(Collection<?> sourceList,
org.springframework.core.convert.TypeDescriptor targetType)
转换列表数据
|
static org.springframework.core.convert.support.DefaultConversionService |
getConversionService()
获取转换服务
|
public static org.springframework.core.convert.support.DefaultConversionService getConversionService()
public static void addConvert(@NonNull
org.springframework.core.convert.converter.Converter<?,?> converter)
converter - 转换器public static boolean canConvert(@Nullable
Class<?> sourceType,
Class<?> targetType)
sourceType - 源类型targetType - 目标类型public static boolean canConvert(@Nullable
org.springframework.core.convert.TypeDescriptor sourceType,
org.springframework.core.convert.TypeDescriptor targetType)
sourceType - 源类型targetType - 目标类型public static boolean canConvert(@Nullable
DataType sourceType,
DataType targetType)
sourceType - 源类型targetType - 目标类型public static <T> T convert(@Nullable
Object source,
Class<T> targetClass)
T - 目标类型source - 源对象targetClass - 目标类ConvertException - 转换失败时,抛出该异常public static <T> T convert(@Nullable
Object source,
org.springframework.core.convert.TypeDescriptor targetType)
T - 目标类型source - 源对象targetType - 目标类描述public static <T> T convert(@Nullable
Object source,
DataType targetType)
T - 目标类型source - 源对象targetType - 目标类描述public static <T> T convert(@Nullable
Object source,
Class<T> targetClass,
@Nullable
T defaultValue)
T - 目标类型source - 源对象targetClass - 目标类defaultValue - 转换失败时,返回的默认值public static <T> T convert(@Nullable
Object source,
org.springframework.core.convert.TypeDescriptor targetType,
@Nullable
T defaultValue)
T - 目标类型source - 源对象targetType - 目标类描述defaultValue - 转换失败时,返回的默认值public static <T> T convert(@Nullable
Object source,
DataType targetType,
@Nullable
T defaultValue)
T - 目标类型source - 源对象targetType - 目标类描述defaultValue - 转换失败时,返回的默认值@NonNull public static <T> List<T> convertList(@Nullable Collection<?> sourceList, Class<T> targetClass)
T - 目标类型sourceList - 源对象列表targetClass - 目标类@NonNull public static <T> List<T> convertList(@Nullable Collection<?> sourceList, org.springframework.core.convert.TypeDescriptor targetType)
T - 目标类型sourceList - 源对象列表targetType - 目标类描述@NonNull public static <T> List<T> convertList(@Nullable Collection<?> sourceList, DataType targetType)
T - 目标类型sourceList - 源对象列表targetType - 目标类描述Copyright © 2021–2022 EasyJ????. All rights reserved.