- //通过字节码筛选相应的属性,赋值,打印get方法观察赋值情况
- if(!"class".equals(name)){
- if (setMethod != null){
- if (type == boolean.class || type == Boolean.class) {
- setMethod.invoke(obj, true);
- }
- if (type == String.class) {
- setMethod.invoke(obj, "www.itheima.com");
- }
- if (type == int.class || type == Integer.class) {
- setMethod.invoke(obj, 100);
- }
- if (type == double.class || type == Double.class) {
-
- setMethod.invoke(obj, 0.01D);
- }
- }
- if (getMethod != null) {
- System.out.println(type + " " + name + "="
- + getMethod.invoke(obj, null));
- }
- }
复制代码 |
|