I have the following enum
:
public enum UserRole {
ADMIN,
MANAGER,
OPERATOR
}
I need to get the UserRole value from its corresponding numeric value as shown below:
String role = "0";
UserRole userRole = UserRole.valueOf(role); // I am expecting to get UserRole.ADMIN
It throws "java.lang.IllegalArgumentException: No enum constant com.mycompany.domain.model.UserRole.... java.base/java.lang.Enum.valueOf(Enum.java:240)". So, do I need to make some implementation in the UserRole
class?