I have a Predicate that filters my Task objects based on date:
Predicate<Task> startDateFiltering = new Predicate<Task>() { @Override public boolean apply(Task input) { return input.getStartDate() != null && input.getStartDate().after(date); } };
It makes no sense to use it as long as the date variable is available in context. However, I would like to make it reusable and embed it in the Task class by doing something like this:
public static final Predicate<Task> startDateFiltering = new Predicate<Task>() { @Override public boolean apply(Task input) { return input.getStartDate() != null && input.getStartDate().after(date); } };
To access it as Task.startDateFiltering every time I need it. But how do you pass the date argument to it?
source share