I have an enum with 4 values, and I have a method signature that accepts an enum value. I would like to be able to do something with all enum values not passed as the argument to doSomething().
public void doSomething(EnumThing thing){
EnumThing[] thingValues = EnumThing.values();
List<EnumThing> valuesNotPassedAsArg = new ArrayList<EnumThing>();
for(EnumThing th : thingValues){
valuesNotPassedAsArg.add(th);
}
valuesNotPassAsArg.remove(thing);
//here I would loop through all valuesNotPassAsArg and do something with them
}
public enum EnumThing{
SOMETHING, SOMETHINGELSE, ANOTHERTHING;
}
Is there a cleaner way to do this? I feel as if the loop to get the items from the thingValues array is superfluous.
EnumThing.values();will return all the enum values, and not any kind of subset. So, what exactly do you want to do? Please explain a little bit more.thing?