@@ -39,6 +39,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @author Jürgen Diez
|
||||
*/
|
||||
class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T> {
|
||||
|
||||
@@ -63,7 +64,7 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
@Nullable
|
||||
protected TypeInformation<?> doGetMapValueType() {
|
||||
|
||||
if (Map.class.isAssignableFrom(getType())) {
|
||||
if (isMap()) {
|
||||
|
||||
var arguments = type.getActualTypeArguments();
|
||||
|
||||
@@ -141,13 +142,13 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
|
||||
@Nullable
|
||||
protected TypeInformation<?> doGetComponentType() {
|
||||
|
||||
var isCustomMapImplementation = isMap() && !getType().equals(Map.class);
|
||||
var isCustomMapImplementation = isMap() && !isMapBaseType();
|
||||
|
||||
if (isCustomMapImplementation) {
|
||||
return getRequiredSuperTypeInformation(Map.class).getComponentType();
|
||||
return getRequiredSuperTypeInformation(getMapBaseType()).getComponentType();
|
||||
}
|
||||
|
||||
return createInfo(type.getActualTypeArguments()[0]);
|
||||
return createInfo(this.type.getActualTypeArguments()[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
|
||||
private static final Class<?>[] MAP_TYPES;
|
||||
protected static final Class<?>[] MAP_TYPES;
|
||||
private static final Class<?>[] COLLECTION_TYPES;
|
||||
|
||||
static {
|
||||
@@ -328,7 +328,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
|
||||
@Nullable
|
||||
protected TypeInformation<?> doGetMapValueType() {
|
||||
return isMap() ? getTypeArgument(getBaseType(MAP_TYPES), 1)
|
||||
return isMap() ? getTypeArgument(getMapBaseType(), 1)
|
||||
: getTypeArguments().stream().skip(1).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
}
|
||||
|
||||
if (isMap()) {
|
||||
return getTypeArgument(getBaseType(MAP_TYPES), 0);
|
||||
return getTypeArgument(getMapBaseType(), 0);
|
||||
}
|
||||
|
||||
if (Iterable.class.isAssignableFrom(rawType)) {
|
||||
@@ -469,6 +469,27 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
: null;
|
||||
}
|
||||
|
||||
protected boolean isMapBaseType() {
|
||||
return isBaseType(MAP_TYPES);
|
||||
}
|
||||
|
||||
private boolean isBaseType(Class<?>[] candidates) {
|
||||
|
||||
Class<S> type = getType();
|
||||
|
||||
for (Class<?> candidate: candidates) {
|
||||
if (candidate.equals(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Class<?> getMapBaseType() {
|
||||
return getBaseType(MAP_TYPES);
|
||||
}
|
||||
|
||||
private Class<?> getBaseType(Class<?>[] candidates) {
|
||||
|
||||
var type = getType();
|
||||
|
||||
Reference in New Issue
Block a user