Say I have an enum which is just
public enum Blah { A, B, C, D }
and I would like to find the enum value of a string, for example
What about?
public enum MyEnum { FIRST, SECOND, THIRD; public static Optional fromString(String value){ try{ return Optional.of(MyEnum.valueOf(value)); }catch(Exception e){ return Optional.empty(); } } }