public class LazyBean {
// public static void main(String[] args) {
// DynaBean dynaBean=new LazyDynaBean();
// dynaBean.set("foo", "bar");//单独
// dynaBean.set("customer", "title","Mr");//map,第一个标识,第二个是key,第三个value
// dynaBean.set("customer", "sturname","Mr");
// dynaBean.set("address", 1,"addlisten1");//数组,第一个标识,第二个索引,第三个值
// dynaBean.set("address", 2,"addlisten2");
// dynaBean.set("address", 3,"addlisten3");
// System.out.println(dynaBean.get("foo"));//获取
// System.out.println(dynaBean.get("address", 2));//获取数组,第2
// System.out.println(dynaBean.get("customer", "title"));//获取map中title键
// }
// public static void main(String[] args) {
//// LazyDynaMap dynaBean=new LazyDynaMap();
//// //map集合
//// dynaBean.set("foo", "bar");
//// dynaBean.set("name","zhangsan", "张三");
//// dynaBean.set("lisi", 0,"李四");
//// Map map=dynaBean.getMap();
//// System.out.println(map.get("lisi"));
//
// Map map=new HashMap();
// LazyDynaMap dynaMap=new LazyDynaMap(map);
// dynaMap.set("foo", "bar");
// System.out.println(map.get("foo"));
// }
public static void main(String[] args) {
// MutableDynaClass dynaClass=new LazyDynaClass();
// dynaClass.add("amount", java.lang.Integer.class);
// dynaClass.add("stuname", java.lang.String[].class);
// dynaClass.add("map", java.util.Map.class);
// DynaBean d=new LazyDynaBean(dynaClass);
// d.set("amount", 1);
// System.out.println(d.get("amount"));
DynaBean dynaBean = new LazyDynaBean(); // Create LazyDynaBean
MutableDynaClass dynaClass =
(MutableDynaClass)dynaBean.getDynaClass(); // get DynaClass
dynaClass.add("amount", java.lang.Integer.class); // add property
dynaClass.add("myBeans", java.lang.String[].class); // add 'array' indexed property
dynaClass.add("myMap", java.util.Map.class); // add mapped property
}
}