@Test public void detectDeclaredPropertyTypeテスト() { Class<?> s = Beans.detectDeclaredPropertyType("stringField", BeansBean.class); Class<?> i = Beans.detectDeclaredPropertyType("integerField", BeansBean.class); Class<?> bi = Beans.detectDeclaredPropertyType("bigIntegerField", BeansBean.class); Class<?> f = Beans.detectDeclaredPropertyType("floatField", BeansBean.class); Class<?> d = Beans.detectDeclaredPropertyType("doubleField", BeansBean.class); Class<?> bd = Beans.detectDeclaredPropertyType("bigDecimalField", BeansBean.class); assertEquals(String.class, s); assertEquals(Integer.class, i); assertEquals(BigInteger.class, bi); assertEquals(Float.class, f); assertEquals(Double.class, d); assertEquals(BigDecimal.class, bd); }
public static Class<?> detectDeclaredPropertyType(String propertyName, Class<?> target) { Args.checkNotBlank(propertyName); Args.checkNotNull(target); String[] properties = propertyName.split("\\."); Class<?> result = target; for (String property : properties) { PropertyDescriptor pd = findPropertyDescriptorFor(result, property); if (pd == null) { if (L.isDebugEnabled()) { Map<String, Object> replace = new HashMap<String, Object>(1); replace.put("property", propertyName); replace.put("class", target.getClass().getName()); L.debug(Strings.substitute(R.getString("D-UTIL#0015"), replace)); } return null; } result = pd.getPropertyType(); } return result; }
Beans { public static Class<?> detectDeclaredPropertyType(String propertyName, Class<?> target) { Args.checkNotBlank(propertyName); Args.checkNotNull(target); String[] properties = propertyName.split("\\."); Class<?> result = target; for (String property : properties) { PropertyDescriptor pd = findPropertyDescriptorFor(result, property); if (pd == null) { if (L.isDebugEnabled()) { Map<String, Object> replace = new HashMap<String, Object>(1); replace.put("property", propertyName); replace.put("class", target.getClass().getName()); L.debug(Strings.substitute(R.getString("D-UTIL#0015"), replace)); } return null; } result = pd.getPropertyType(); } return result; } }
Beans { public static Class<?> detectDeclaredPropertyType(String propertyName, Class<?> target) { Args.checkNotBlank(propertyName); Args.checkNotNull(target); String[] properties = propertyName.split("\\."); Class<?> result = target; for (String property : properties) { PropertyDescriptor pd = findPropertyDescriptorFor(result, property); if (pd == null) { if (L.isDebugEnabled()) { Map<String, Object> replace = new HashMap<String, Object>(1); replace.put("property", propertyName); replace.put("class", target.getClass().getName()); L.debug(Strings.substitute(R.getString("D-UTIL#0015"), replace)); } return null; } result = pd.getPropertyType(); } return result; } private  Beans(); }
Beans { public static Class<?> detectDeclaredPropertyType(String propertyName, Class<?> target) { Args.checkNotBlank(propertyName); Args.checkNotNull(target); String[] properties = propertyName.split("\\."); Class<?> result = target; for (String property : properties) { PropertyDescriptor pd = findPropertyDescriptorFor(result, property); if (pd == null) { if (L.isDebugEnabled()) { Map<String, Object> replace = new HashMap<String, Object>(1); replace.put("property", propertyName); replace.put("class", target.getClass().getName()); L.debug(Strings.substitute(R.getString("D-UTIL#0015"), replace)); } return null; } result = pd.getPropertyType(); } return result; } private  Beans(); static String capitalize(String capitalizee); static String decapitalize(String decapitalizee); static String decapitalize(String decapitalizee, boolean doubleUppercaseEnable); static boolean isPropertyReader(String suspect); static boolean isPropertyWriter(String suspect); static boolean isPropertyAccessor(String suspect); static String generatePropertyNameFor(String accessorName); static T make(Class<T> clazz); static PropertyDescriptor[] findPropertyDescriptorsFor(Class<?> clazz); static PropertyDescriptor findPropertyDescriptorFor(Class<?> clazz, String propertyName); static Object readPropertyValueNamed(String propertyName, Object bean); static void writePropertyValueNamed(String propertyName, Object bean, Object newValue); static Object readPseudoPropertyValueNamed(String propertyName, Object bean); static void writePseudoPropertyValueNamed(String propertyName, Object bean, Object newValue); static String[] listPseudoPropertyNames(Class<?> clazz); static Class<?> detectDeclaredPropertyType(String propertyName, Class<?> target); }
Beans { public static Class<?> detectDeclaredPropertyType(String propertyName, Class<?> target) { Args.checkNotBlank(propertyName); Args.checkNotNull(target); String[] properties = propertyName.split("\\."); Class<?> result = target; for (String property : properties) { PropertyDescriptor pd = findPropertyDescriptorFor(result, property); if (pd == null) { if (L.isDebugEnabled()) { Map<String, Object> replace = new HashMap<String, Object>(1); replace.put("property", propertyName); replace.put("class", target.getClass().getName()); L.debug(Strings.substitute(R.getString("D-UTIL#0015"), replace)); } return null; } result = pd.getPropertyType(); } return result; } private  Beans(); static String capitalize(String capitalizee); static String decapitalize(String decapitalizee); static String decapitalize(String decapitalizee, boolean doubleUppercaseEnable); static boolean isPropertyReader(String suspect); static boolean isPropertyWriter(String suspect); static boolean isPropertyAccessor(String suspect); static String generatePropertyNameFor(String accessorName); static T make(Class<T> clazz); static PropertyDescriptor[] findPropertyDescriptorsFor(Class<?> clazz); static PropertyDescriptor findPropertyDescriptorFor(Class<?> clazz, String propertyName); static Object readPropertyValueNamed(String propertyName, Object bean); static void writePropertyValueNamed(String propertyName, Object bean, Object newValue); static Object readPseudoPropertyValueNamed(String propertyName, Object bean); static void writePseudoPropertyValueNamed(String propertyName, Object bean, Object newValue); static String[] listPseudoPropertyNames(Class<?> clazz); static Class<?> detectDeclaredPropertyType(String propertyName, Class<?> target);  }