@Test public void readPropertyValueNamedネストリストテスト() { Object target = new Object() { @SuppressWarnings("unused") public Object getProp() { return Lists.gen("0", "1", "2"); } }; String value = (String) Beans.readPropertyValueNamed("prop[0]", target); assertNotNull(value); assertEquals("0", value); value = (String) Beans.readPropertyValueNamed("prop[1]", target); assertNotNull(value); assertEquals("1", value); value = (String) Beans.readPropertyValueNamed("prop[2]", target); assertNotNull(value); assertEquals("2", value); }
public static Object readPropertyValueNamed(String propertyName, Object bean) { Args.checkNotBlank(propertyName); Args.checkNotNull(bean); Object temporaryPropertyValue = bean; String[] properties = propertyName.split("\\."); for (String property : properties) { Matcher matcher = ARRAY_PROPERTY_PATTERN.matcher(property); if (matcher.matches()) { String arrayPropertyName = matcher.group(1); Integer arrayPropertyIndex = Integer.valueOf(matcher.group(2)); Object array = readPropertyValueNamed0(arrayPropertyName, temporaryPropertyValue); temporaryPropertyValue = readElementAt(arrayPropertyIndex, array); } else { temporaryPropertyValue = readPropertyValueNamed0(property, temporaryPropertyValue); } } return temporaryPropertyValue; }
Beans { public static Object readPropertyValueNamed(String propertyName, Object bean) { Args.checkNotBlank(propertyName); Args.checkNotNull(bean); Object temporaryPropertyValue = bean; String[] properties = propertyName.split("\\."); for (String property : properties) { Matcher matcher = ARRAY_PROPERTY_PATTERN.matcher(property); if (matcher.matches()) { String arrayPropertyName = matcher.group(1); Integer arrayPropertyIndex = Integer.valueOf(matcher.group(2)); Object array = readPropertyValueNamed0(arrayPropertyName, temporaryPropertyValue); temporaryPropertyValue = readElementAt(arrayPropertyIndex, array); } else { temporaryPropertyValue = readPropertyValueNamed0(property, temporaryPropertyValue); } } return temporaryPropertyValue; } }
Beans { public static Object readPropertyValueNamed(String propertyName, Object bean) { Args.checkNotBlank(propertyName); Args.checkNotNull(bean); Object temporaryPropertyValue = bean; String[] properties = propertyName.split("\\."); for (String property : properties) { Matcher matcher = ARRAY_PROPERTY_PATTERN.matcher(property); if (matcher.matches()) { String arrayPropertyName = matcher.group(1); Integer arrayPropertyIndex = Integer.valueOf(matcher.group(2)); Object array = readPropertyValueNamed0(arrayPropertyName, temporaryPropertyValue); temporaryPropertyValue = readElementAt(arrayPropertyIndex, array); } else { temporaryPropertyValue = readPropertyValueNamed0(property, temporaryPropertyValue); } } return temporaryPropertyValue; } private  Beans(); }
Beans { public static Object readPropertyValueNamed(String propertyName, Object bean) { Args.checkNotBlank(propertyName); Args.checkNotNull(bean); Object temporaryPropertyValue = bean; String[] properties = propertyName.split("\\."); for (String property : properties) { Matcher matcher = ARRAY_PROPERTY_PATTERN.matcher(property); if (matcher.matches()) { String arrayPropertyName = matcher.group(1); Integer arrayPropertyIndex = Integer.valueOf(matcher.group(2)); Object array = readPropertyValueNamed0(arrayPropertyName, temporaryPropertyValue); temporaryPropertyValue = readElementAt(arrayPropertyIndex, array); } else { temporaryPropertyValue = readPropertyValueNamed0(property, temporaryPropertyValue); } } return temporaryPropertyValue; } 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 Object readPropertyValueNamed(String propertyName, Object bean) { Args.checkNotBlank(propertyName); Args.checkNotNull(bean); Object temporaryPropertyValue = bean; String[] properties = propertyName.split("\\."); for (String property : properties) { Matcher matcher = ARRAY_PROPERTY_PATTERN.matcher(property); if (matcher.matches()) { String arrayPropertyName = matcher.group(1); Integer arrayPropertyIndex = Integer.valueOf(matcher.group(2)); Object array = readPropertyValueNamed0(arrayPropertyName, temporaryPropertyValue); temporaryPropertyValue = readElementAt(arrayPropertyIndex, array); } else { temporaryPropertyValue = readPropertyValueNamed0(property, temporaryPropertyValue); } } return temporaryPropertyValue; } 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);  }