|
|
|
@ -41,13 +41,17 @@ import org.springframework.util.ConcurrentReferenceHashMap; |
|
|
|
* @author Phillip Webb |
|
|
|
* @author Phillip Webb |
|
|
|
* @since 2.5.2 |
|
|
|
* @since 2.5.2 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public abstract class GenericTypeResolver { |
|
|
|
public final class GenericTypeResolver { |
|
|
|
|
|
|
|
|
|
|
|
/** Cache from Class to TypeVariable Map. */ |
|
|
|
/** Cache from Class to TypeVariable Map. */ |
|
|
|
@SuppressWarnings("rawtypes") |
|
|
|
@SuppressWarnings("rawtypes") |
|
|
|
private static final Map<Class<?>, Map<TypeVariable, Type>> typeVariableCache = new ConcurrentReferenceHashMap<>(); |
|
|
|
private static final Map<Class<?>, Map<TypeVariable, Type>> typeVariableCache = new ConcurrentReferenceHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private GenericTypeResolver() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Determine the target type for the given generic parameter type. |
|
|
|
* Determine the target type for the given generic parameter type. |
|
|
|
* @param methodParameter the method parameter specification |
|
|
|
* @param methodParameter the method parameter specification |
|
|
|
@ -86,7 +90,7 @@ public abstract class GenericTypeResolver { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
public static Class<?> resolveReturnTypeArgument(Method method, Class<?> genericIfc) { |
|
|
|
public static Class<?> resolveReturnTypeArgument(Method method, Class<?> genericIfc) { |
|
|
|
Assert.notNull(method, "method must not be null"); |
|
|
|
Assert.notNull(method, "Method must not be null"); |
|
|
|
ResolvableType resolvableType = ResolvableType.forMethodReturnType(method).as(genericIfc); |
|
|
|
ResolvableType resolvableType = ResolvableType.forMethodReturnType(method).as(genericIfc); |
|
|
|
if (!resolvableType.hasGenerics() || resolvableType.getType() instanceof WildcardType) { |
|
|
|
if (!resolvableType.hasGenerics() || resolvableType.getType() instanceof WildcardType) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
|