Java反射封装库joor.zip

所需积分/C币:19 2019-07-16 04:51:43 118KB ZIP
80
收藏 收藏
举报

jOOR 在java原生的反射基础上进行了简单的封装,使得反射使用方便不少! 举个简单的列子,供大家参考。 java 原生反射写法: try {  Method m1 = department.getClass().getMethod("getEmployees");  Employee employees = (Employee[]) m1.invoke(department);  for (Employee employee : employees) {    Method m2 = employee.getClass().getMethod("getAddress");    Address address = (Address) m2.invoke(employee);    Method m3 = address.getClass().getMethod("getStreet");    Street street = (Street) m3.invoke(address);    System.out.println(street);  }}// There are many checked exceptions that you are likely to ignore anyway catch (Exception ignore) {  // ... or maybe just wrap in your preferred runtime exception:  throw new RuntimeException(e);} jOOR写法:   Employee[] employees = on(department).call("getEmployees").get();for (Employee employee : employees) {  Street street = on(employee).call("getAddress").call("getStreet").get();  System.out.println(street);} 标签:joor

...展开详情
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
关注 私信
上传资源赚钱or赚积分
最新推荐
Java反射封装库joor.zip 19积分/C币 立即下载
1/0