DATACMNS-42 - MappingBeanHelper now considers all Numbers to be simple types.
Fixed bug in isSimpleType(…) along the lines.
This commit is contained in:
@@ -252,7 +252,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
|
||||
}
|
||||
|
||||
if (property.isCollection()) {
|
||||
return getTypeInformationIfNotSimpleType(typeInformation.getComponentType());
|
||||
return getTypeInformationIfNotSimpleType(getComponentTypeRecursively(typeInformation));
|
||||
}
|
||||
|
||||
if (property.isMap()) {
|
||||
@@ -261,6 +261,16 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private TypeInformation<?> getComponentTypeRecursively(TypeInformation<?> typeInformation) {
|
||||
TypeInformation<?> componentType = typeInformation.getComponentType();
|
||||
|
||||
if (componentType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return componentType.isCollectionLike() ? getComponentTypeRecursively(componentType) : componentType;
|
||||
}
|
||||
|
||||
private TypeInformation<?> getTypeInformationIfNotSimpleType(TypeInformation<?> information) {
|
||||
return information == null || MappingBeanHelper.isSimpleType(information.getType()) ? null : information;
|
||||
|
||||
@@ -218,7 +218,7 @@ public class BeanWrapper<E extends PersistentEntity<T, ?>, T> {
|
||||
private <S> S getPotentiallyConvertedValue(Object source, Class<S> targetType) {
|
||||
|
||||
boolean conversionServiceAvailable = conversionService != null;
|
||||
boolean conversionNeeded = source == null || !source.getClass().isAssignableFrom(targetType);
|
||||
boolean conversionNeeded = source == null || !targetType.isAssignableFrom(source.getClass());
|
||||
|
||||
if (conversionServiceAvailable && conversionNeeded) {
|
||||
return conversionService.convert(source, targetType);
|
||||
|
||||
@@ -61,6 +61,7 @@ public abstract class MappingBeanHelper {
|
||||
simpleTypes.add(Date.class);
|
||||
simpleTypes.add(Locale.class);
|
||||
simpleTypes.add(Class.class);
|
||||
simpleTypes.add(Number.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +81,7 @@ public abstract class MappingBeanHelper {
|
||||
*/
|
||||
public static boolean isSimpleType(Class<?> type) {
|
||||
for (Class<?> clazz : simpleTypes) {
|
||||
if (type == clazz || type.isAssignableFrom(clazz)) {
|
||||
if (type == clazz || clazz.isAssignableFrom(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user