DynamicObject implements Serializable, PortableObject { public void update(Object target) { if (target == null) { throw new IllegalArgumentException( "Target to update cannot be null"); } BeanWrapper bw = new BeanWrapperImpl(target); bw.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true)); for (Map.Entry<String, Object> property : m_properties.entrySet()) { String propertyName = property.getKey(); Object value = property.getValue(); if (value instanceof Map) { PropertyDescriptor pd = bw.getPropertyDescriptor(propertyName); if (!Map.class.isAssignableFrom(pd.getPropertyType()) || pd.getWriteMethod() == null) { value = new DynamicObject((Map<String, Object>) value); } } if (value instanceof DynamicObject) { ((DynamicObject) value).update(bw.getPropertyValue(propertyName)); } else { bw.setPropertyValue(propertyName, value); } } } DynamicObject();  DynamicObject(Object bean);  DynamicObject(Object bean, PropertyList properties);  DynamicObject(Map<String, Object> map); Object getValue(String name); void setValue(String name, Object value); boolean getBoolean(String name); void setBoolean(String name, boolean value); byte getByte(String name); void setByte(String name, byte value); char getChar(String name); void setChar(String name, char value); short getShort(String name); void setShort(String name, short value); int getInt(String name); void setInt(String name, int value); long getLong(String name); void setLong(String name, long value); float getFloat(String name); void setFloat(String name, float value); double getDouble(String name); void setDouble(String name, double value); BigDecimal getBigDecimal(String name); void setBigDecimal(String name, BigDecimal value); String getString(String name); void setString(String name, String value); Date getDate(String name); void setDate(String name, Date value); void merge(DynamicObject obj); void merge(Object obj); void merge(Object obj, PropertyList properties); void merge(Map<String, Object> map); void update(Object target); static Map<String, Object> getPropertyMap(Object obj); @Override @SuppressWarnings({"unchecked"}) void readExternal(PofReader reader); @Override void writeExternal(PofWriter writer); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testUpdate() { Person p = new Person(1L, "Homer", null, new Address("111 Main St", "Springfield", "USA")); DynamicObject address = new DynamicObject(); address.setValue("street", "555 Main St"); DynamicObject o = new DynamicObject(); o.setValue("id", "5"); o.setValue("name", "Homer Simpson"); o.setValue("dateOfBirth", "2010-10-10"); o.setValue("address", address); o.update(p); assertEquals(5L, p.getId()); assertEquals("Homer Simpson", p.getName()); assertEquals(new Date(110, 9, 10), p.getDateOfBirth()); assertEquals("555 Main St", p.getAddress().getStreet()); }