Suppose I want to create a set of related functions and want to group them in an enum.
I can code, just for example:
enum Case implements Function<Object, String> {
UPPER {
public String apply(Object o) {
return o.toString().toUpperCase();
}
},
LOWER {
public String apply(Object o) {
return o.toString().toLowerCase();
}
}
}
I would like to be able to code this as a lambda, something like (but doesn't compile):
enum CaseLambda implements Function<Object, String> {
UPPER (o -> o.toString().toUpperCase()),
LOWER (o -> o.toString().toLowerCase())
}
I've tried a few variations of brackets etc, but nothing compiles.
Is there a syntax that allows the declaration of enum instance implementation as lambda?