Skip to content

Commit 3e41d93

Browse files
committed
DATACMNS-1571 - Polishing.
1 parent 85e257f commit 3e41d93

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/main/java/org/springframework/data/util/TypeDiscoverer.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected TypeDiscoverer(Type type, Map<TypeVariable<?>, Type> typeVariableMap)
8989
this.componentType = Lazy.of(this::doGetComponentType);
9090
this.valueType = Lazy.of(this::doGetMapValueType);
9191
this.typeVariableMap = typeVariableMap;
92-
this.hashCode = 17 + (31 * type.hashCode()) + (31 * typeVariableMap.hashCode());
92+
this.hashCode = 17 + 31 * type.hashCode() + 31 * typeVariableMap.hashCode();
9393
}
9494

9595
/**
@@ -435,11 +435,12 @@ public TypeInformation<?> getSuperTypeInformation(Class<?> superType) {
435435
}
436436

437437
List<Type> candidates = new ArrayList<>();
438-
439438
Type genericSuperclass = rawType.getGenericSuperclass();
439+
440440
if (genericSuperclass != null) {
441441
candidates.add(genericSuperclass);
442442
}
443+
443444
candidates.addAll(Arrays.asList(rawType.getGenericInterfaces()));
444445

445446
for (Type candidate : candidates) {
@@ -449,7 +450,9 @@ public TypeInformation<?> getSuperTypeInformation(Class<?> superType) {
449450
if (superType.equals(candidateInfo.getType())) {
450451
return candidateInfo;
451452
} else {
453+
452454
TypeInformation<?> nestedSuperType = candidateInfo.getSuperTypeInformation(superType);
455+
453456
if (nestedSuperType != null) {
454457
return nestedSuperType;
455458
}
@@ -501,17 +504,19 @@ private TypeInformation<?> getTypeArgument(Class<?> bound, int index) {
501504

502505
Class<?>[] arguments = GenericTypeResolver.resolveTypeArguments(getType(), bound);
503506

504-
if (arguments == null) {
505-
return getSuperTypeInformation(bound) instanceof ParameterizedTypeInformation ? ClassTypeInformation.OBJECT
506-
: null;
507+
if (arguments != null) {
508+
return createInfo(arguments[index]);
507509
}
508510

509-
return createInfo(arguments[index]);
511+
return getSuperTypeInformation(bound) instanceof ParameterizedTypeInformation //
512+
? ClassTypeInformation.OBJECT //
513+
: null;
510514
}
511515

512516
private Class<?> getBaseType(Class<?>[] candidates) {
513517

514518
Class<S> type = getType();
519+
515520
for (Class<?> candidate : candidates) {
516521
if (candidate.isAssignableFrom(type)) {
517522
return candidate;

0 commit comments

Comments
 (0)