What's the best practice to "look up" Java Enums?
- by Marcus
We have a REST API where clients can supply parameters representing values defined on the server in Java Enums.
So we can provide a descriptive error, we add this lookup method to each Enum. Seems like we're just copying code (bad). Is there a better practice?
public enum MyEnum {
A, B, C, D;
public static MyEnum lookup(String id) {
…