Effective Java! Emulate Extensible Enums With Interfaces.
3 min readJun 3, 2021
We continue digging into different considerations while working with enums
. Earlier in this series we considered the alternatives to the use of enum
s. Throughout the preceding chapters we have shown that enums are the preferred method. There is one place where the alternatives of using regular classes are superior to enum
s, that is with extending existing functionality. For good reason the enum
type does not allow extension.
That being said, there are times when we could want this type of functionality, particularly when working…