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
Guava also provides such function which will return an Optional if an enum cannot be found.
Optional
Enums.getIfPresent(MyEnum.class, id).toJavaUtil() .orElseThrow(()-> new RuntimeException("Invalid enum blah blah blah.....")))