Java Code Examples for org.apache.commons.beanutils.PropertyUtils#setMappedProperty()

The following examples show how to use org.apache.commons.beanutils.PropertyUtils#setMappedProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestMultiWrapDynaBean.java    From commons-configuration with Apache License 2.0 5 votes vote down vote up
/**
 * Tests whether a map property can be set.
 */
@Test
public void testSetMappedProperty() throws Exception
{
    final MultiWrapDynaBean bean = createBean(true);
    final String key = "testKey";
    final String text = "Hello World";
    PropertyUtils.setMappedProperty(bean, MAPPED_PROPERTY, key, text);
    assertEquals("Property not set", text,
            wrapDynaBean.get(MAPPED_PROPERTY, key));
}
 
Example 2
Source File: CourseService.java    From tutorials with MIT License 4 votes vote down vote up
public static void setMappedValue(Course course, String enrollId, Student student) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    // Setting the mapped properties
    PropertyUtils.setMappedProperty(course, "enrolledStudent(" + enrollId + ")", student);
}