Example usage for org.apache.commons.beanutils MappedPropertyDescriptor getMappedWriteMethod

List of usage examples for org.apache.commons.beanutils MappedPropertyDescriptor getMappedWriteMethod

Introduction

In this page you can find the example usage for org.apache.commons.beanutils MappedPropertyDescriptor getMappedWriteMethod.

Prototype

public Method getMappedWriteMethod() 

Source Link

Document

Gets the method that should be used to write one of the property value.

Usage

From source file:no.sesat.search.datamodel.BeanDataObjectInvocationHandler.java

private Method findSupport(final String propertyName, final boolean setter) throws IntrospectionException {

    // If there's a support instance, use it first.

    Method m = null;/* www.  ja  va 2  s . c  o  m*/
    if (null != support) {

        final PropertyDescriptor[] propDescriptors = Introspector
                .getBeanInfo(support.getClass().getInterfaces()[0]).getPropertyDescriptors();

        for (PropertyDescriptor pd : propDescriptors) {

            if (propertyName.equalsIgnoreCase(pd.getName())) {
                if (pd instanceof MappedPropertyDescriptor) {

                    final MappedPropertyDescriptor mpd = (MappedPropertyDescriptor) pd;
                    m = setter ? mpd.getMappedWriteMethod() : mpd.getMappedReadMethod();

                } else {
                    m = setter ? pd.getWriteMethod() : pd.getReadMethod();
                }
                break;
            }
        }
    }
    return m;
}

From source file:no.sesat.search.datamodel.DataModelTest.java

private void handleMappedProperty(final Collection<Method> propertyMethods,
        final MappedPropertyDescriptor property) throws IntrospectionException {

    if (null != property.getMappedReadMethod()) {
        propertyMethods.add(property.getMappedReadMethod());
        // recurse down the datamodel heirarchy
        if (null != property.getMappedPropertyType().getAnnotation(DataObject.class)) {
            ensureJavaBeanAPI(property.getMappedPropertyType());
        }//from   ww  w  .j a va 2  s . c  o m
    }
    if (null != property.getMappedWriteMethod()) {
        propertyMethods.add(property.getMappedWriteMethod());
    }
}