|
1 | 1 | /* |
2 | | - * Copyright 2002-2013 the original author or authors. |
| 2 | + * Copyright 2002-2014 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -835,6 +835,23 @@ public static ResolvableType forField(Field field, Class<?> implementationClass) |
835 | 835 | return forType(null, new FieldTypeProvider(field), owner.asVariableResolver()); |
836 | 836 | } |
837 | 837 |
|
| 838 | + /** |
| 839 | + * Return a {@link ResolvableType} for the specified {@link Field} with a given |
| 840 | + * implementation. |
| 841 | + * <p>Use this variant when the class that declares the field includes generic |
| 842 | + * parameter variables that are satisfied by the implementation type. |
| 843 | + * @param field the source field |
| 844 | + * @param implementationType the implementation type |
| 845 | + * @return a {@link ResolvableType} for the specified field |
| 846 | + * @see #forField(Field) |
| 847 | + */ |
| 848 | + public static ResolvableType forField(Field field, ResolvableType implementationType) { |
| 849 | + Assert.notNull(field, "Field must not be null"); |
| 850 | + implementationType = (implementationType == null ? NONE : implementationType); |
| 851 | + ResolvableType owner = implementationType.as(field.getDeclaringClass()); |
| 852 | + return forType(null, new FieldTypeProvider(field), owner.asVariableResolver()); |
| 853 | + } |
| 854 | + |
838 | 855 | /** |
839 | 856 | * Return a {@link ResolvableType} for the specified {@link Field} with the |
840 | 857 | * given nesting level. |
@@ -963,7 +980,25 @@ public static ResolvableType forMethodParameter(Method method, int parameterInde |
963 | 980 | * @see #forMethodParameter(Method, int) |
964 | 981 | */ |
965 | 982 | public static ResolvableType forMethodParameter(MethodParameter methodParameter) { |
966 | | - return forMethodParameter(methodParameter, null); |
| 983 | + return forMethodParameter(methodParameter, (Type) null); |
| 984 | + } |
| 985 | + |
| 986 | + /** |
| 987 | + * Return a {@link ResolvableType} for the specified {@link MethodParameter} with a |
| 988 | + * given implementation type. Use this variant when the class that declares the method |
| 989 | + * includes generic parameter variables that are satisfied by the implementation type. |
| 990 | + * @param methodParameter the source method parameter (must not be {@code null}) |
| 991 | + * @param implementationType the implementation type |
| 992 | + * @return a {@link ResolvableType} for the specified method parameter |
| 993 | + * @see #forMethodParameter(MethodParameter) |
| 994 | + */ |
| 995 | + public static ResolvableType forMethodParameter(MethodParameter methodParameter, ResolvableType implementationType) { |
| 996 | + Assert.notNull(methodParameter, "MethodParameter must not be null"); |
| 997 | + implementationType = (implementationType == null ? forType(methodParameter.getContainingClass()) : implementationType); |
| 998 | + ResolvableType owner = implementationType.as(methodParameter.getDeclaringClass()); |
| 999 | + return forType(null, new MethodParameterTypeProvider(methodParameter), |
| 1000 | + owner.asVariableResolver()).getNested(methodParameter.getNestingLevel(), |
| 1001 | + methodParameter.typeIndexesPerLevel); |
967 | 1002 | } |
968 | 1003 |
|
969 | 1004 | /** |
|
0 commit comments