DATACMNS-783 - DefaultTypeMapper now specializes raw generic types.
If the type lookup from the store source returns a raw generic type (e.g. resolving the value of a generic property against a value of that generic type - i.e. not a more concrete type binding the generic information) in the context of a generic property, we previously did not apply the generics information of the contextual instance to that very raw type. We now expose a TypeInformation.specialize(ClassTypeInformation) which applies the current generics context to the given raw type and basically creates a synthetic parameterized TypeInformation instance. DefaultTypeMapper applies this specialization by default now with ClassTypeInformation simply returning the given type as is so that we don't create any resolution overhead in case no generics are involved in the first place.
This commit is contained in:
@@ -147,10 +147,16 @@ public class DefaultTypeMapper<S> implements TypeMapper<S> {
|
||||
|
||||
Class<T> rawType = basicType == null ? null : basicType.getType();
|
||||
|
||||
boolean isMoreConcreteCustomType = rawType == null ? true : rawType.isAssignableFrom(documentsTargetType)
|
||||
&& !rawType.equals(documentsTargetType);
|
||||
return isMoreConcreteCustomType ? (TypeInformation<? extends T>) ClassTypeInformation.from(documentsTargetType)
|
||||
: basicType;
|
||||
boolean isMoreConcreteCustomType = rawType == null ? true
|
||||
: rawType.isAssignableFrom(documentsTargetType) && !rawType.equals(documentsTargetType);
|
||||
|
||||
if (!isMoreConcreteCustomType) {
|
||||
return basicType;
|
||||
}
|
||||
|
||||
ClassTypeInformation<?> targetType = ClassTypeInformation.from(documentsTargetType);
|
||||
|
||||
return (TypeInformation<? extends T>) (basicType != null ? basicType.specialize(targetType) : targetType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user