Beans { public static Object getProperty(BeanType beanType,Object bean,String property) throws ObjectNotFoundException{ if(bean instanceof DynaBean){ return ((DynaBean) bean).getProperty(property); } BeanProperty bp = beanType.tryGetProperty(property); if(null != bp){ return bp.getValue(bean); } throw new ObjectNotFoundException("Property '" + property + "' not found in bean class '" + bean.getClass().getName()); } protected  Beans(); static boolean isSimpleProperty(Class<?> clazz); static boolean isSetterMethod(String methodName); static boolean isGetterMethod(String methodName); static String extractPropertyFromSetter(String methodName); static String extraPropertyFromGetter(String methodName); static Map<String,Object> toMap(Object bean); static T copyNew(T from); static void copyProperties(Object from,Object to); static Object getProperty(BeanType beanType,Object bean,String property); static Object getNestableProperty(Object bean,String property); static Object getNestableProperty(Map map, String property); static Object getNestableProperty(BeanType beanType, Object bean, String property); static T fromMapNestable(BeanType beanType, Map<String, Object> map); static void setProperties(BeanType beanType,Object bean,Map<String, Object> map); static void setPropertiesNestable(BeanType beanType, Object bean, Map<String, Object> map); static void setProperty(BeanType beanType,Object bean,String property,Object value); static void setProperty(BeanType beanType,Object bean,String property,Object value, boolean ignoreCase); static final String SETTER_PREFIX; static final String GETTER_PREFIX; static final String IS_PREFIX; }
@Test public void testBeanPropertyWithoutField() { BeanType bt = BeanType.of(TestedBean.class); BeanProperty ok = bt.getProperty("ok"); assertEquals(Boolean.TRUE,ok.getValue(new TestedBean())); BeanProperty intValue = bt.getProperty("intValue"); assertEquals(new Integer(100), intValue.getValue(new TestedBean())); }