Here\'s my problem - I\'m looking for (if it even exists) the enum equivalent of ArrayList.contains();.
Here\'s a sample of my code problem:
<
This approach can be used to check any Enum, you can add it to an Utils class:
public static > boolean enumContains(Class enumerator, String value)
{
for (T c : enumerator.getEnumConstants()) {
if (c.name().equals(value)) {
return true;
}
}
return false;
}
Use it this way:
boolean isContained = Utils.enumContains(choices.class, "value");