package com.qianwen.core.tool.utils;
|
|
import com.qianwen.core.tool.convert.BladeConversionService;
|
import org.springframework.core.convert.TypeDescriptor;
|
import org.springframework.core.convert.support.GenericConversionService;
|
import org.springframework.lang.Nullable;
|
|
/* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/utils/ConvertUtil.class */
|
public class ConvertUtil {
|
/* JADX WARN: Multi-variable type inference failed */
|
@Nullable
|
public static <T> T convert(@Nullable Object source, Class<T> targetType) {
|
if (source == null)
|
return null;
|
if (ClassUtil.isAssignableValue(targetType, source))
|
return (T)source;
|
|
GenericConversionService conversionService = BladeConversionService.getInstance();
|
return (T)conversionService.convert(source, targetType);
|
}
|
|
@Nullable
|
public static <T> T convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
if (source == null) {
|
return null;
|
}
|
GenericConversionService conversionService = BladeConversionService.getInstance();
|
return (T) conversionService.convert(source, sourceType, targetType);
|
}
|
|
@Nullable
|
public static <T> T convert(@Nullable Object source, TypeDescriptor targetType) {
|
if (source == null) {
|
return null;
|
}
|
GenericConversionService conversionService = BladeConversionService.getInstance();
|
return (T) conversionService.convert(source, targetType);
|
}
|
}
|