1 3 package jodd.bean.loader; 4 5 import java.util.Iterator ; 6 import java.util.Map ; 7 8 import jodd.bean.BeanUtil; 9 import jodd.bean.BeanException; 10 11 18 public class MapBeanLoader implements BeanLoader { 19 20 public static void loadBean(Object bean, Object map) { 21 if (map instanceof Map ) { 22 Iterator i = ((Map )map).keySet().iterator(); 23 while (i.hasNext()) { 24 String propertyName = (String ) i.next(); 25 Object propertyValue = ((Map )map).get(propertyName); 26 if (propertyValue == null) { 27 return; 28 } 29 try { 30 BeanUtil.setPropertyForcedSilent(bean, propertyName, propertyValue); 31 } catch (BeanException bex) { 32 } 34 } 35 } 36 } 37 38 public void load(Object bean, Object map) { 39 loadBean(bean, map); 40 } 41 42 } 43 | Popular Tags |