读书人

Spring 源码之判断属性基本部类

发布时间: 2012-08-28 12:37:01 作者: rapoo

Spring 源码之判断属性基本类型

判断是否是基本类型
/** * Check if the given type represents a "simple" property: * a primitive, a String or other CharSequence, a Number, a Date, * a URI, a URL, a Locale, a Class, or a corresponding array. * <p>Used to determine properties to check for a "simple" dependency-check. * @param clazz the type to check * @return whether the given type represents a "simple" property * @see org.springframework.beans.factory.support.RootBeanDefinition#DEPENDENCY_CHECK_SIMPLE * @see org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#checkDependencies */public static boolean isSimpleProperty(Class<?> clazz) {Assert.notNull(clazz, "Class must not be null");return isSimpleValueType(clazz) || (clazz.isArray() && isSimpleValueType(clazz.getComponentType()));}

?

/** * Check if the given type represents a "simple" value type: * a primitive, a String or other CharSequence, a Number, a Date, * a URI, a URL, a Locale or a Class. * @param clazz the type to check * @return whether the given type represents a "simple" value type */public static boolean isSimpleValueType(Class<?> clazz) {return ClassUtils.isPrimitiveOrWrapper(clazz) || clazz.isEnum() ||CharSequence.class.isAssignableFrom(clazz) ||Number.class.isAssignableFrom(clazz) ||Date.class.isAssignableFrom(clazz) ||clazz.equals(URI.class) || clazz.equals(URL.class) ||clazz.equals(Locale.class) || clazz.equals(Class.class);}

?

?

读书人网 >编程

热点推荐