I want to create Comparator
based on Enum.name()
which is inside a bean class:
List.of(new JobRsp(Job.MY), new JobRsp(Job.OUR), new JobRsp(Job.YOUR)).stream()
.sorted(__ -> __.getJob().name());
If I only needed Enum.order()
I could write sorted(Job::getJob)
.
Is it possible co compose zero args methods in functional style in Java? Something like:
FuncUtils.compose(Job::getJob, Enum::name)
Or probably even longer:
.sort(FuncUtils.chainGetters(ObjA::getB, ObjB::getC, ObjC::getD, ObjD::getE))
Imaginary chainGetters
might check for null
s.
I understand that Java doesn't allow variadic generics so there should be chainGetters
for each argument arity.