Example usage for org.apache.commons.beanutils BeanUtilsBean getInstance

List of usage examples for org.apache.commons.beanutils BeanUtilsBean getInstance

Introduction

In this page you can find the example usage for org.apache.commons.beanutils BeanUtilsBean getInstance.

Prototype

public synchronized static BeanUtilsBean getInstance() 

Source Link

Usage

From source file:de.micromata.genome.util.bean.PropertyDescriptorUtils.java

/**
 * Gets the property descriptors.//from  w  ww  .  ja va2  s  .  c  o m
 *
 * @param clazz the clazz
 * @return the property descriptors
 */
public static PropertyDescriptor[] getPropertyDescriptors(Class<?> clazz) {
    return BeanUtilsBean.getInstance().getPropertyUtils().getPropertyDescriptors(clazz);
}

From source file:com.teamj.distribuidas.web.MainBean.java

@PostConstruct
public void init() {
    BeanUtilsBean beanUtilsBean = BeanUtilsBean.getInstance();
    beanUtilsBean.getConvertUtils()/* ww w . j  a v a2s  . c o m*/
            .register(new org.apache.commons.beanutils.converters.BigDecimalConverter(null), BigDecimal.class);

}

From source file:com.autentia.intra.util.BeanUtils.java

/**
 * Copies one ITransferObject into another (excluding the id property)
 *
 * @param copyAccountEntry/*w w  w  .  j  a  va2 s  .  c  om*/
 * @param periodicalAccountEntry
 */
public static void copyTransferObject(ITransferObject source, ITransferObject dest) {
    try {
        BeanUtilsBean.getInstance().copyProperties(dest, source);
    } catch (IllegalAccessException ex) {
        throw new RuntimeException("Error cloning ITransferObject", ex);
    } catch (InvocationTargetException ex) {
        throw new RuntimeException("Error cloning ITransferObject", ex);
    }
}

From source file:com.taobao.itest.matcher.AssertExcludedPropertiesEquals.java

/**
 * assertPropertiesEqualsIgnoreOthers /*  w w w.j  av a 2s .  com*/
 * Mainly used to compare the two bean, 
 * in addition to ignoring the property, other various attributes are equal
 * 
 *
 * @param expect
 * @param actual
 * @param ignoredProperties   ignoring property,
 *
 * 
 */
public static void assertPropertiesEqualsIgnoreOthers(Object expect, Object actual,
        String... ignoredProperties) {
    if (!ArrayUtils.isEmpty(ignoredProperties)) {
        PropertyDescriptor[] props = BeanUtilsBean.getInstance().getPropertyUtils()
                .getPropertyDescriptors(expect);
        String propertyNames = "";
        for (int i = 0; i < props.length; i++) {
            /*
             * The current bean in the property not for the "class", 
             * nor is ignoredProperties values, this time to put in the comparison
             */
            if (!props[i].getName().equals("class")
                    && !ArrayUtils.contains(ignoredProperties, props[i].getName())) {
                propertyNames += props[i].getName() + ",";
            }
        }
        /*   According to include comparison  */
        AssertPropertiesEquals.assertPropertiesEquals(expect, actual,
                propertyNames.substring(0, propertyNames.length() - 1).split(","));
    } else {
        /*
         * This parameter is empty, the situation has in the upper control,
         * directly through the reflection verified. 
         * But to prevent each other's direct calls, and still retain
         */
        AssertPropertiesEquals.assertPropertiesEquals(expect, actual);
    }
}

From source file:fr.paris.lutece.plugins.gru.business.NotifiedDemand.java

/**
 * Convert a Demand object into a NotifierDemand
 * /*from  ww w  .jav a  2  s.com*/
 * @param demand
 *            The Demand to convert
 * 
 * @return a NotifiedDemand
 */
public static NotifiedDemand toDemand(Demand demand) {
    NotifiedDemand notifiedDemand = null;
    if (demand != null) {
        BeanUtilsBean beanUtil = BeanUtilsBean.getInstance();
        notifiedDemand = new NotifiedDemand();

        try {
            beanUtil.getPropertyUtils().copyProperties(notifiedDemand, demand);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            AppLogService.error(COPY_PROPERTIES_ERROR, e);
        }

    }
    return notifiedDemand;
}

From source file:jin.collection.util.PropertyUtil.java

protected Object getNestedProperty(Object element, String property) {

    try {//  w w  w  . j  ava2  s. c  o  m
        return BeanUtilsBean.getInstance().getPropertyUtils().getNestedProperty(element, property);
    } catch (final IllegalAccessException e) {
        throw new PropertyAccessException(e);
    } catch (final InvocationTargetException e) {
        throw new PropertyAccessException(e);
    } catch (final NoSuchMethodException e) {
        throw new PropertyAccessException(e);
    }

    // try {
    // return lookUpValue(element, property);
    // } catch (final Exception e) {
    // throw new RuntimeException(e);
    // }
}

From source file:de.micromata.genome.util.bean.PropertyDescriptorUtils.java

/**
 * Read property./* w  w  w.j av a2s  . c om*/
 *
 * @param bean the bean
 * @param pd the pd
 * @return the object
 * @throws PropertyAccessException the property access exception
 */
public static Object readProperty(Object bean, PropertyDescriptor pd) throws PropertyAccessException {
    PropertyUtilsBean proputils = BeanUtilsBean.getInstance().getPropertyUtils();
    Object value;
    try {
        value = proputils.getSimpleProperty(bean, pd.getName());
        return value;
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
        throw new PropertyAccessException("getSimpleProperty", bean, pd, ex);
    }
}

From source file:jp.go.nict.langrid.dao.entity.ExternalService.java

@Override
public ExternalService clone() {
    try {/*  w ww  .  j  a  va2 s.  c  o  m*/
        return (ExternalService) BeanUtilsBean.getInstance().cloneBean(this);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (InstantiationException e) {
        throw new RuntimeException(e);
    } catch (InvocationTargetException e) {
        throw new RuntimeException(e);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
}

From source file:jp.go.nict.langrid.dao.entity.WebappService.java

@Override
public WebappService clone() {
    try {/*from w  ww  .j  a v  a2 s  . c  om*/
        return (WebappService) BeanUtilsBean.getInstance().cloneBean(this);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (InstantiationException e) {
        throw new RuntimeException(e);
    } catch (InvocationTargetException e) {
        throw new RuntimeException(e);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    }
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.GWikiActionBeanMacro.java

protected void populate(MacroAttributes attrs, GWikiContext ctx) {
    try {/*from   w ww. j ava2 s  .  c om*/
        BeanUtilsBean.getInstance().populate(this, attrs.getArgs().getMap());
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

}