yangys
2024-03-31 2969df3e404db3cd116f27db1495e523ce05bf86
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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);
    }
}