I have a simple problem where I’m not sure how to solve it in the most type save way. I have two sets of well known values, which means that enums seem like a natural fit. However, those enums are parameterized with description texts. How do I write a generic function that takes the whole enum as a parameter? Enums can’t inherit from a “parameterized enum”. Can they implement interfaces? Can I even reference the whole enum set, or do I have to pass the SomeEnum.values() array around?
11/29/2017, 10:28 AM
Enums are fully fledged objects so yes, they can implement interfaces. To access the enum values you can either pass around the values array, use
11/29/2017, 10:30 AM
Okay thanks, I’ll see if I can make them implement a getText interface and pass around the values array, since that looks more intuitive to me than the other options.