Java反射封装库joor.zip

时间:2022-08-04 22:38:23
【文件属性】:

文件名称:Java反射封装库joor.zip

文件大小:118KB

文件格式:ZIP

更新时间:2022-08-04 22:38:23

开源项目

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


【文件预览】:
jOOR-master
----.github()
--------issue_template.md(112B)
----LICENSE.txt(10KB)
----jOOR-java-6()
--------src()
--------pom.xml(10KB)
----jOOR-java-8()
--------src()
--------pom.xml(10KB)
----.travis.yml(373B)
----jOOR()
--------src()
--------pom.xml(10KB)
----README.md(4KB)
----.gitignore(63B)

网友评论