/** * Sets the given property on the target JavaBean using bean instrospection. * @param propertyName Property to set. * @param value Property value to set. * @param target Target java bean on which to set property. */ public static void setProperty(final String propertyName, final Object value, final Object target) { try { setProperty(propertyName, value, target, Introspector.getBeanInfo(target.getClass())); } catch (final IntrospectionException e) { throw new RuntimeException("Failed getting bean info on target JavaBean " + target, e); } }
/** * Sets the given property on the target javabean using bean instrospection. * @param propertyName Property to set. * @param value Property value to set. * @param target Target java bean on which to set property. */ public static void setProperty(final String propertyName, final Object value, final Object target) { try { setProperty(propertyName, value, target, Introspector.getBeanInfo(target.getClass())); } catch (final IntrospectionException e) { throw new RuntimeException("Failed getting bean info on target javabean " + target, e); } }
final PropertyDescriptor pd = ReflectUtils.getPropertyDescriptor(info, property); if (pd != null) { ReflectUtils.setProperty(property, convertIfNecessary(pd, value), validator, info); log.debug("Set " + property + "=" + value); } else {
final PropertyDescriptor pd = ReflectUtils.getPropertyDescriptor(info, property); if (pd != null) { ReflectUtils.setProperty(property, convertIfNecessary(pd, value), validator, info); logger.debug("Set {} = {}", property, value); } else {
/** * Test method for {@link org.jasig.cas.client.util.ReflectUtils#setProperty(java.lang.String, java.lang.Object, java.lang.Object)}. */ public void testSetPropertyStringObjectObject() { final TestBean bean = new TestBean(); ReflectUtils.setProperty("count", new Integer(30000), bean); assertEquals(30000, bean.getCount()); ReflectUtils.setProperty("name", "bob", bean); assertEquals("bob", bean.getName()); ReflectUtils.setProperty("flag", Boolean.TRUE, bean); assertTrue(bean.isFlag()); }