DATACMNS-42 - MappingBeanHelper now considers all Numbers to be simple types.

Fixed bug in isSimpleType(…) along the lines.
This commit is contained in:
Oliver Gierke
2011-06-04 06:34:24 +02:00
parent 12d5c0ddb9
commit 364a84ffb8
3 changed files with 14 additions and 3 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;
}
}