List of usage examples for org.apache.commons.beanutils MappedPropertyDescriptor getReadMethod
public synchronized Method getReadMethod()
From source file:no.sesat.search.datamodel.DataModelFactoryImplTest.java
/** * * @throws java.lang.Exception//from w ww. j a v a 2 s . co m */ @Test public void testDataObjectGetters() throws Exception { LOG.info("testDataObjectGetters()"); scan(DataObject.class, DataModel.class, new Command() { public void execute(Object... args) { try { final Class<?> cls = (Class<?>) args[0]; final Object dataObject = testInstantiate(cls); final PropertyDescriptor[] properties = Introspector.getBeanInfo(cls).getPropertyDescriptors(); for (PropertyDescriptor property : properties) { if (null != property.getReadMethod()) { final Object value = invoke(property.getReadMethod(), dataObject, new Object[0]); LOG.info(" Getter on " + property.getName() + " returned " + value); } if (property instanceof MappedPropertyDescriptor) { final MappedPropertyDescriptor mappedProperty = (MappedPropertyDescriptor) property; if (null != mappedProperty.getReadMethod()) { final Object value = invoke(mappedProperty.getMappedReadMethod(), dataObject, ""); LOG.info(" Getter on " + mappedProperty.getName() + " returned " + value); } } } } catch (IntrospectionException ie) { LOG.info(ie.getMessage(), ie); throw new RuntimeException(ie.getMessage(), ie); } } }); }