List of usage examples for org.apache.commons.beanutils PropertyUtilsBean setSimpleProperty
public void setSimpleProperty(Object bean, String name, Object value) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
From source file:de.micromata.genome.util.bean.PropertyDescriptorUtils.java
/** * Write property.//from w w w.j a va 2s . co m * * @param bean the bean * @param pd the pd * @param value the value * @throws PropertyAccessException the property access exception */ public static void writeProperty(Object bean, PropertyDescriptor pd, Object value) throws PropertyAccessException { PropertyUtilsBean proputils = BeanUtilsBean.getInstance().getPropertyUtils(); try { proputils.setSimpleProperty(bean, pd.getName(), value); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) { throw new PropertyAccessException("setSimpleProperty", bean, pd, ex); } }
From source file:org.eclipse.reddeer.junit.internal.configuration.setter.ConfigurationSetter.java
private void inject(Requirement<?> requirement, String key, Object value) { PropertyUtilsBean utils = new PropertyUtilsBean(); try {/* w w w .j av a2 s . c om*/ utils.setSimpleProperty(requirement, key, value); } catch (IllegalAccessException e) { throw createCannotSetPropertyException(key, value, requirement.getClass(), e); } catch (InvocationTargetException e) { throw createCannotSetPropertyException(key, value, requirement.getClass(), e); } catch (NoSuchMethodException e) { throw createCannotSetPropertyException(key, value, requirement.getClass(), e); } }
From source file:org.eclipse.wb.internal.rcp.model.rcp.ActionFactoryCreationSupport.java
/** * Copies value of property from "this" {@link IWorkbenchAction} into design {@link Action} * object.// w w w.ja v a 2s . co m */ private static void copyActionProperty(Object action, IWorkbenchAction sourceAction, String propertyName) throws Exception { PropertyUtilsBean propertyUtils = new PropertyUtilsBean(); Object value = propertyUtils.getSimpleProperty(sourceAction, propertyName); if (value instanceof String) { propertyUtils.setSimpleProperty(action, propertyName, value); } else if (value != null && ReflectionUtils.isSuccessorOf(value.getClass(), "org.eclipse.jface.resource.ImageDescriptor")) { ClassLoader classLoader = action.getClass().getClassLoader(); Object imageDescriptor = createID(classLoader, (ImageDescriptor) value); propertyUtils.setSimpleProperty(action, propertyName, imageDescriptor); } }