If you look at this answer , which outlines the benefits of using the lambda expression in this enum script, you may notice that these benefits all disappear in the pre-Java 8 option. This is no more readable than the old specialized version of enum , and it does not improve performance. In addition, interface BinaryOperator did not exist before Java 8, so its another class that you will need to add to your code base in order to follow this approach.
The main reason for using this approach for delegates in pre-Java 8 code is to make porting easier if you plan to upgrade to Java 8 soon.
Update your updated question:
If you mainly focus on the use case of Java 8, I would recommend always using the delegation approach, when all cases of enum have different behavior, which still follows a similar pattern, which may benefit from using lambda expressions, since its case when implemented operators, as in your example.
A counter-example would be enum , where most of them have common behavior that will be overridden for only one or more cases. For instance:.
enum Tokens { FOO, BAR, BAZ, AND, A, LOT, MORE
source share