When defining Predicate's or Function's, I used to create them as static final
private static final Predicate<SomeDto> SOME_PREDICATE =
new Predicate<SomeDto>() {
@Override
public boolean apply(SomeDto input) {
return input.isValid();
}
}
However I have noticed that there is a lot of use also with enum
version, for example
private enum SomePredicate implements Predicate<SomeDto> {
INSTANCE;
@Override
public boolean apply(SomeDto input) {
return input.isValid();
}
}
I am aware about the enum vs static final topics, but is there any real advantage of using enum's over static final with predicates or functions?