Is it even possible?
With the introduction of lambda expression in Java 8 you can now have anonymous methods.
Say I have a class Alpha and I want to filter Alphas on a specific condition. To do this you can use a Predicatetest that accepts an Alpha and returns a boolean.
Assuming that the filter method has this signature:
List filter(Predicate filterPredicate)
With the old anonymous class solution you would need to something like:
filter(new Predicate() {
boolean test(Alpha alpha) {
return alpha.centauri > 1;
}
});
With the Java 8 lambdas you can do:
filter(alpha -> alpha.centauri > 1);
For more detailed information see the Lambda Expressions tutorial