I have an enum with custom values:
enum DaysOfExercise{
MONDAY ("legs Workout"),
WEDNESDAY ("back workout"),
SATURDAY ("running") ;
private String exercise ;
private DaysOfExercise(String exercise){
this.exercise = exercise ;
}
public String getExercise(){
return this.exercise ;
}
}
I need to add a search feature that returns a DaysOfExercise
based on an entered exercise name.
I know that there is is the .values()
method in the Enum to return the list of DaysOfExercise
values to easily iterate over, but in my case I want to return the embedded values list to compare with what the user has typed in.
Is there any built-in method that could return the list of the enum custom values instead of the enum values?
Note: It is not that I'm stuck with this problem. I can easily solve it with a couple of loops. I'm just looking for an optimized solution.