1
1
/*
2
- * Copyright 2009-2022 the original author or authors.
2
+ * Copyright 2009-2023 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.
@@ -37,6 +37,7 @@ public class TypeParameterResolver {
37
37
* the field
38
38
* @param srcType
39
39
* the src type
40
+ *
40
41
* @return The field type as {@link Type}. If it has type parameters in the declaration,<br>
41
42
* they will be resolved to the actual runtime {@link Type}s.
42
43
*/
@@ -53,6 +54,7 @@ public static Type resolveFieldType(Field field, Type srcType) {
53
54
* the method
54
55
* @param srcType
55
56
* the src type
57
+ *
56
58
* @return The return type of the method as {@link Type}. If it has type parameters in the declaration,<br>
57
59
* they will be resolved to the actual runtime {@link Type}s.
58
60
*/
@@ -69,6 +71,7 @@ public static Type resolveReturnType(Method method, Type srcType) {
69
71
* the method
70
72
* @param srcType
71
73
* the src type
74
+ *
72
75
* @return The parameter types of the method as an array of {@link Type}s. If they have type parameters in the
73
76
* declaration,<br>
74
77
* they will be resolved to the actual runtime {@link Type}s.
@@ -95,7 +98,8 @@ private static Type resolveType(Type type, Type srcType, Class<?> declaringClass
95
98
}
96
99
}
97
100
98
- private static Type resolveGenericArrayType (GenericArrayType genericArrayType , Type srcType , Class <?> declaringClass ) {
101
+ private static Type resolveGenericArrayType (GenericArrayType genericArrayType , Type srcType ,
102
+ Class <?> declaringClass ) {
99
103
Type componentType = genericArrayType .getGenericComponentType ();
100
104
Type resolvedComponentType = null ;
101
105
if (componentType instanceof TypeVariable ) {
@@ -112,7 +116,8 @@ private static Type resolveGenericArrayType(GenericArrayType genericArrayType, T
112
116
}
113
117
}
114
118
115
- private static ParameterizedType resolveParameterizedType (ParameterizedType parameterizedType , Type srcType , Class <?> declaringClass ) {
119
+ private static ParameterizedType resolveParameterizedType (ParameterizedType parameterizedType , Type srcType ,
120
+ Class <?> declaringClass ) {
116
121
Class <?> rawType = (Class <?>) parameterizedType .getRawType ();
117
122
Type [] typeArgs = parameterizedType .getActualTypeArguments ();
118
123
Type [] args = new Type [typeArgs .length ];
@@ -161,7 +166,8 @@ private static Type resolveTypeVar(TypeVariable<?> typeVar, Type srcType, Class<
161
166
ParameterizedType parameterizedType = (ParameterizedType ) srcType ;
162
167
clazz = (Class <?>) parameterizedType .getRawType ();
163
168
} else {
164
- throw new IllegalArgumentException ("The 2nd arg must be Class or ParameterizedType, but was: " + srcType .getClass ());
169
+ throw new IllegalArgumentException (
170
+ "The 2nd arg must be Class or ParameterizedType, but was: " + srcType .getClass ());
165
171
}
166
172
167
173
if (clazz == declaringClass ) {
@@ -188,7 +194,8 @@ private static Type resolveTypeVar(TypeVariable<?> typeVar, Type srcType, Class<
188
194
return Object .class ;
189
195
}
190
196
191
- private static Type scanSuperTypes (TypeVariable <?> typeVar , Type srcType , Class <?> declaringClass , Class <?> clazz , Type superclass ) {
197
+ private static Type scanSuperTypes (TypeVariable <?> typeVar , Type srcType , Class <?> declaringClass , Class <?> clazz ,
198
+ Type superclass ) {
192
199
if (superclass instanceof ParameterizedType ) {
193
200
ParameterizedType parentAsType = (ParameterizedType ) superclass ;
194
201
Class <?> parentAsClass = (Class <?>) parentAsType .getRawType ();
@@ -212,7 +219,8 @@ private static Type scanSuperTypes(TypeVariable<?> typeVar, Type srcType, Class<
212
219
return null ;
213
220
}
214
221
215
- private static ParameterizedType translateParentTypeVars (ParameterizedType srcType , Class <?> srcClass , ParameterizedType parentType ) {
222
+ private static ParameterizedType translateParentTypeVars (ParameterizedType srcType , Class <?> srcClass ,
223
+ ParameterizedType parentType ) {
216
224
Type [] parentTypeArgs = parentType .getActualTypeArguments ();
217
225
Type [] srcTypeArgs = srcType .getActualTypeArguments ();
218
226
TypeVariable <?>[] srcTypeVars = srcClass .getTypeParameters ();
@@ -230,7 +238,7 @@ private static ParameterizedType translateParentTypeVars(ParameterizedType srcTy
230
238
newParentArgs [i ] = parentTypeArgs [i ];
231
239
}
232
240
}
233
- return noChange ? parentType : new ParameterizedTypeImpl ((Class <?>)parentType .getRawType (), null , newParentArgs );
241
+ return noChange ? parentType : new ParameterizedTypeImpl ((Class <?>) parentType .getRawType (), null , newParentArgs );
234
242
}
235
243
236
244
private TypeParameterResolver () {
@@ -268,7 +276,8 @@ public Type getRawType() {
268
276
269
277
@ Override
270
278
public String toString () {
271
- return "ParameterizedTypeImpl [rawType=" + rawType + ", ownerType=" + ownerType + ", actualTypeArguments=" + Arrays .toString (actualTypeArguments ) + "]" ;
279
+ return "ParameterizedTypeImpl [rawType=" + rawType + ", ownerType=" + ownerType + ", actualTypeArguments="
280
+ + Arrays .toString (actualTypeArguments ) + "]" ;
272
281
}
273
282
}
274
283
0 commit comments