What is the best practice for packaging Java enums?
is it separate file for each enum?
having same file for all the enums?
What are the pros and cons ?
First, an overriding rule is that if an
For example, if you are building an expression processor and declaring an enumeration for an expression sub-type, a binary expression sub-type, and a unary expression sub-type, you may want to group the three enumerations together in a single file.
Enums are classes so you should pack them as ordinary classes. If the enum is used in many places inside the package then put it in a single file. If the enum is strongly linked with a class, then put it as a public (or protected) static inner class.
I do not see reasons for placing all the enums in a single file unless they are related.