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
Apache Commons Lang 3 contais the class EnumUtils. If you aren't using Apache Commons in your projects, you're doing it wrong. You are reinventing the wheel!
There's a dozen of cool methods that we could use without throws an Exception. For example:
Gets the enum for the class, returning null if not found.
This method differs from Enum.valueOf in that it does not throw an exceptionfor an invalid enum name and performs case insensitive matching of the name.
EnumUtils.getEnumIgnoreCase(SeasonEnum.class, season);