The translate to rpc methods in enums used to switch on their own values, which is fragile implementation. (Refer: Effective Java Vol 2: Item 30: Enum type that switches on its own value - questionable)
Therefore the enum template has been edited to generate methods that use constant-specific method implementation. (Refer: Effective Java Vol 2: Item 30: Enum type with constant-specific method implementations)
For example, this generates enums that are as follows:
The translate to rpc methods in enums used to switch on their own values, which is fragile implementation. (Refer: Effective Java Vol 2: Item 30: Enum type that switches on its own value - questionable)
Therefore the enum template has been edited to generate methods that use constant-specific method implementation. (Refer: Effective Java Vol 2: Item 30: Enum type with constant-specific method implementations)
For example, this generates enums that are as follows:
The behaviour at the call site will be exactly the same as before. But there are certain benefits to it:
default
branch is not present.default
is removed, any mismatch will be caught at compile-time and those bugs won't propagate to run-time.