|
|
|
@ -31,11 +31,8 @@ import org.springframework.expression.spel.support.StandardEvaluationContext; |
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.util.LinkedList; |
|
|
|
import java.util.*; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
import java.util.concurrent.ConcurrentSkipListSet; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author Jon Brisbin <jbrisbin@vmware.com> |
|
|
|
* @author Jon Brisbin <jbrisbin@vmware.com> |
|
|
|
@ -44,28 +41,30 @@ public abstract class MappingBeanHelper { |
|
|
|
|
|
|
|
|
|
|
|
protected static GenericConversionService conversionService = ConversionServiceFactory.createDefaultConversionService(); |
|
|
|
protected static GenericConversionService conversionService = ConversionServiceFactory.createDefaultConversionService(); |
|
|
|
protected static SpelExpressionParser parser = new SpelExpressionParser(); |
|
|
|
protected static SpelExpressionParser parser = new SpelExpressionParser(); |
|
|
|
protected static Set<String> simpleTypes = new ConcurrentSkipListSet<String>() {{ |
|
|
|
protected static Set<Class<?>> simpleTypes = Collections.newSetFromMap(new ConcurrentHashMap<Class<?>, Boolean>()); |
|
|
|
add(boolean.class.getName()); |
|
|
|
|
|
|
|
add(long.class.getName()); |
|
|
|
static { |
|
|
|
add(short.class.getName()); |
|
|
|
simpleTypes.add(boolean.class); |
|
|
|
add(int.class.getName()); |
|
|
|
simpleTypes.add(long.class); |
|
|
|
add(byte.class.getName()); |
|
|
|
simpleTypes.add(short.class); |
|
|
|
add(float.class.getName()); |
|
|
|
simpleTypes.add(int.class); |
|
|
|
add(double.class.getName()); |
|
|
|
simpleTypes.add(byte.class); |
|
|
|
add(char.class.getName()); |
|
|
|
simpleTypes.add(float.class); |
|
|
|
add(Boolean.class.getName()); |
|
|
|
simpleTypes.add(double.class); |
|
|
|
add(Long.class.getName()); |
|
|
|
simpleTypes.add(char.class); |
|
|
|
add(Short.class.getName()); |
|
|
|
simpleTypes.add(Boolean.class); |
|
|
|
add(Integer.class.getName()); |
|
|
|
simpleTypes.add(Long.class); |
|
|
|
add(Byte.class.getName()); |
|
|
|
simpleTypes.add(Short.class); |
|
|
|
add(Float.class.getName()); |
|
|
|
simpleTypes.add(Integer.class); |
|
|
|
add(Double.class.getName()); |
|
|
|
simpleTypes.add(Byte.class); |
|
|
|
add(Character.class.getName()); |
|
|
|
simpleTypes.add(Float.class); |
|
|
|
add(String.class.getName()); |
|
|
|
simpleTypes.add(Double.class); |
|
|
|
add(java.util.Date.class.getName()); |
|
|
|
simpleTypes.add(Character.class); |
|
|
|
add(Locale.class.getName()); |
|
|
|
simpleTypes.add(String.class); |
|
|
|
add(Class.class.getName()); |
|
|
|
simpleTypes.add(java.util.Date.class); |
|
|
|
}}; |
|
|
|
simpleTypes.add(Locale.class); |
|
|
|
|
|
|
|
simpleTypes.add(Class.class); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static GenericConversionService getConversionService() { |
|
|
|
public static GenericConversionService getConversionService() { |
|
|
|
return conversionService; |
|
|
|
return conversionService; |
|
|
|
@ -75,10 +74,19 @@ public abstract class MappingBeanHelper { |
|
|
|
MappingBeanHelper.conversionService = conversionService; |
|
|
|
MappingBeanHelper.conversionService = conversionService; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static Set<String> getSimpleTypes() { |
|
|
|
public static Set<Class<?>> getSimpleTypes() { |
|
|
|
return simpleTypes; |
|
|
|
return simpleTypes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean isSimpleType(Class<?> type) { |
|
|
|
|
|
|
|
for (Class<?> clazz : simpleTypes) { |
|
|
|
|
|
|
|
if (type == clazz || type.isAssignableFrom(clazz)) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static <T> T constructInstance(PersistentEntity<T> entity, |
|
|
|
public static <T> T constructInstance(PersistentEntity<T> entity, |
|
|
|
PreferredConstructor.ParameterValueProvider provider) { |
|
|
|
PreferredConstructor.ParameterValueProvider provider) { |
|
|
|
return constructInstance(entity, provider, new StandardEvaluationContext()); |
|
|
|
return constructInstance(entity, provider, new StandardEvaluationContext()); |
|
|
|
|