List<?> temp = empObjList.stream()
.filter(nestedDo -> nestedDo.getAttrib1() == "subject")
.collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
这里我调用方法getAttrib1().但是要调用的方法只能动态识别.我将只获得函数的名称作为String值.我想将它动态转换为函数.我知道我可以使用Reflection来进行动态方法调用,但我不能通过反射重写上面的代码.
我认为你所寻找的东西更像是
List<?> temp = empObjList.stream().filter(this::processDo)
.collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
哪个processDo(nestedDo)方法可以进行反射,以确定在do上调用哪种方法.
| 归档时间: |
|
| 查看次数: |
1059 次 |
| 最近记录: |