Skip to content

Commit 3556d4b

Browse files
committed
Revised forClass argument names
Issue: SPR-14976 (cherry picked from commit ced7503)
1 parent c22cad1 commit 3556d4b

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

spring-core/src/main/java/org/springframework/core/ResolvableType.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ private ResolvableType(
174174
* Avoids all {@code instanceof} checks in order to create a straight {@link Class} wrapper.
175175
* @since 4.2
176176
*/
177-
private ResolvableType(Class<?> sourceClass) {
178-
this.resolved = (sourceClass != null ? sourceClass : Object.class);
177+
private ResolvableType(Class<?> clazz) {
178+
this.resolved = (clazz != null ? clazz : Object.class);
179179
this.type = this.resolved;
180180
this.typeProvider = null;
181181
this.variableResolver = null;
@@ -408,7 +408,7 @@ public ResolvableType asMap() {
408408
* {@link #getSuperType() supertype} and {@link #getInterfaces() interface}
409409
* hierarchies to find a match, returning {@link #NONE} if this type does not
410410
* implement or extend the specified class.
411-
* @param type the required class type
411+
* @param type the required type (typically narrowed)
412412
* @return a {@link ResolvableType} representing this object as the specified
413413
* type, or {@link #NONE} if not resolvable as that type
414414
* @see #asCollection()
@@ -923,30 +923,30 @@ public String toString() {
923923
* Return a {@link ResolvableType} for the specified {@link Class},
924924
* using the full generic type information for assignability checks.
925925
* For example: {@code ResolvableType.forClass(MyArrayList.class)}.
926-
* @param sourceClass the source class ({@code null} is semantically
926+
* @param clazz the class to introspect ({@code null} is semantically
927927
* equivalent to {@code Object.class} for typical use cases here}
928928
* @return a {@link ResolvableType} for the specified class
929929
* @see #forClass(Class, Class)
930930
* @see #forClassWithGenerics(Class, Class...)
931931
*/
932-
public static ResolvableType forClass(Class<?> sourceClass) {
933-
return new ResolvableType(sourceClass);
932+
public static ResolvableType forClass(Class<?> clazz) {
933+
return new ResolvableType(clazz);
934934
}
935935

936936
/**
937937
* Return a {@link ResolvableType} for the specified {@link Class}, doing
938938
* assignability checks against the raw class only (analogous to
939939
* {@link Class#isAssignableFrom}, which this serves as a wrapper for.
940940
* For example: {@code ResolvableType.forRawClass(List.class)}.
941-
* @param sourceClass the source class ({@code null} is semantically
941+
* @param clazz the class to introspect ({@code null} is semantically
942942
* equivalent to {@code Object.class} for typical use cases here}
943943
* @return a {@link ResolvableType} for the specified class
944944
* @since 4.2
945945
* @see #forClass(Class)
946946
* @see #getRawClass()
947947
*/
948-
public static ResolvableType forRawClass(Class<?> sourceClass) {
949-
return new ResolvableType(sourceClass) {
948+
public static ResolvableType forRawClass(Class<?> clazz) {
949+
return new ResolvableType(clazz) {
950950
@Override
951951
public boolean isAssignableFrom(Class<?> other) {
952952
return ClassUtils.isAssignable(getRawClass(), other);
@@ -960,50 +960,50 @@ public boolean isAssignableFrom(ResolvableType other) {
960960
}
961961

962962
/**
963-
* Return a {@link ResolvableType} for the specified {@link Class}
964-
* with a given implementation.
963+
* Return a {@link ResolvableType} for the specified base type
964+
* (interface or base class) with a given implementation class.
965965
* For example: {@code ResolvableType.forClass(List.class, MyArrayList.class)}.
966-
* @param sourceClass the source class (must not be {@code null}
966+
* @param baseType the base type (must not be {@code null})
967967
* @param implementationClass the implementation class
968-
* @return a {@link ResolvableType} for the specified class backed by the given
969-
* implementation class
968+
* @return a {@link ResolvableType} for the specified base type backed by the
969+
* given implementation class
970970
* @see #forClass(Class)
971971
* @see #forClassWithGenerics(Class, Class...)
972972
*/
973-
public static ResolvableType forClass(Class<?> sourceClass, Class<?> implementationClass) {
974-
Assert.notNull(sourceClass, "Source class must not be null");
975-
ResolvableType asType = forType(implementationClass).as(sourceClass);
976-
return (asType == NONE ? forType(sourceClass) : asType);
973+
public static ResolvableType forClass(Class<?> baseType, Class<?> implementationClass) {
974+
Assert.notNull(baseType, "Base type must not be null");
975+
ResolvableType asType = forType(implementationClass).as(baseType);
976+
return (asType == NONE ? forType(baseType) : asType);
977977
}
978978

979979
/**
980980
* Return a {@link ResolvableType} for the specified {@link Class} with pre-declared generics.
981-
* @param sourceClass the source class
981+
* @param clazz the class (or interface) to introspect
982982
* @param generics the generics of the class
983983
* @return a {@link ResolvableType} for the specific class and generics
984984
* @see #forClassWithGenerics(Class, ResolvableType...)
985985
*/
986-
public static ResolvableType forClassWithGenerics(Class<?> sourceClass, Class<?>... generics) {
987-
Assert.notNull(sourceClass, "Source class must not be null");
988-
Assert.notNull(generics, "Generics must not be null");
986+
public static ResolvableType forClassWithGenerics(Class<?> clazz, Class<?>... generics) {
987+
Assert.notNull(clazz, "Class must not be null");
988+
Assert.notNull(generics, "Generics array must not be null");
989989
ResolvableType[] resolvableGenerics = new ResolvableType[generics.length];
990990
for (int i = 0; i < generics.length; i++) {
991991
resolvableGenerics[i] = forClass(generics[i]);
992992
}
993-
return forClassWithGenerics(sourceClass, resolvableGenerics);
993+
return forClassWithGenerics(clazz, resolvableGenerics);
994994
}
995995

996996
/**
997997
* Return a {@link ResolvableType} for the specified {@link Class} with pre-declared generics.
998-
* @param sourceClass the source class
998+
* @param clazz the class (or interface) to introspect
999999
* @param generics the generics of the class
10001000
* @return a {@link ResolvableType} for the specific class and generics
10011001
* @see #forClassWithGenerics(Class, Class...)
10021002
*/
1003-
public static ResolvableType forClassWithGenerics(Class<?> sourceClass, ResolvableType... generics) {
1004-
Assert.notNull(sourceClass, "Source class must not be null");
1005-
Assert.notNull(generics, "Generics must not be null");
1006-
TypeVariable<?>[] variables = sourceClass.getTypeParameters();
1003+
public static ResolvableType forClassWithGenerics(Class<?> clazz, ResolvableType... generics) {
1004+
Assert.notNull(clazz, "Class must not be null");
1005+
Assert.notNull(generics, "Generics array must not be null");
1006+
TypeVariable<?>[] variables = clazz.getTypeParameters();
10071007
Assert.isTrue(variables.length == generics.length, "Mismatched number of generics specified");
10081008

10091009
Type[] arguments = new Type[generics.length];
@@ -1013,7 +1013,7 @@ public static ResolvableType forClassWithGenerics(Class<?> sourceClass, Resolvab
10131013
arguments[i] = (argument != null ? argument : variables[i]);
10141014
}
10151015

1016-
ParameterizedType syntheticType = new SyntheticParameterizedType(sourceClass, arguments);
1016+
ParameterizedType syntheticType = new SyntheticParameterizedType(clazz, arguments);
10171017
return forType(syntheticType, new TypeVariablesVariableResolver(variables, generics));
10181018
}
10191019

@@ -1077,8 +1077,8 @@ public static ResolvableType forField(Field field, Class<?> implementationClass)
10771077
*/
10781078
public static ResolvableType forField(Field field, ResolvableType implementationType) {
10791079
Assert.notNull(field, "Field must not be null");
1080-
implementationType = (implementationType == null ? NONE : implementationType);
1081-
ResolvableType owner = implementationType.as(field.getDeclaringClass());
1080+
ResolvableType owner = (implementationType != null ? implementationType : NONE);
1081+
owner = owner.as(field.getDeclaringClass());
10821082
return forType(null, new FieldTypeProvider(field), owner.asVariableResolver());
10831083
}
10841084

0 commit comments

Comments
 (0)