How can I get an abstract enumeration or some kind of basic enumeration?
In my general code, I would like to have an idea of ββthe enum element, MyItems, without binding myself to a specific enumeration. Then in each of my projects I would have a specific implementation.
eg. Common code
public interface MyItems {
}
Project A
public enum Items implements MyItems {
RED_CAR, BLUE_CAR, GREEN_CAR;
}
Project B
public enum Items implements MyItems {
BROWN_TREE, GREEN_TREE;
}
This seems to work, but in my general code, I cannot write a loop over my interface enumeration, since it is not an enumeration. In my general code, I would like to write
for (MyItems item : MyItems.values())
doSomething(item);
but I cannot, because my interface is just a marker interface, and it does not have .values ββ().
Any suggestions are greatly appreciated. I do not know if I am trying completely wrong.