Say I have 3 or n filters. Say 3 for the sake of it.
Say I define these filters and create a map of it as well
class Person {
Strong status;
}
Predicate<Person> completedP = j->j.getStatus().equalsIgnoreCase("completed");
Predicate<Person> inProgressP = j->j.getStatus().equalsIgnoreCase("inprogress");
Predicate<Person> nullStatusP = j->j.getStatus() == null && j.id() == null;
Map<String, Predicate<Person>> filterMap = Map.of("complatedP",completedP,
"inProgressP", inProgressP, "nullStatusP", nullStatusP);
Now say I have an input as List<Person> people
How do I get the output/result as
Map<String, List<Person>>
The key to the result map is one of the 3 filter names. I do not want to do
groupBy 3 times and apply single filter each time.
How do I generalize if it I have a N
filters in the map. For my current requirement, 3 filters is all I need though