I have an enum Foo
public enum Foo {
A("first"),
B("second"),
private final String value;
private Foo(String value) {
this.value = value;
}
public String value() {
return this.value;
}
}
Below I am trying to check if a string is contained in my enum.
public boolean isValidFoo(String fooStr) {
return EnumSet.allOf(Foo.class)
.contains(Foo.valueOf(fooStr.toUpperCase()));
}
This works when I send A
or B
for fooStr
.
How to make it work when I send first
or second
for fooStr
?