Say I want to iterate through all declared enum classes that implement a certain interface.
So I have:
enum Fruit implements Edible {
//etc
}
enum Vegetable implements Edible {
//etc
}
enum Candy implements Edible {
//etc
}
is there a way in Java to loop through all the enum classes that implement the Edible interface? I assume this would require reflection. With standard Java classes, I don't believe there is a way to do this (to find all classes that subclass a certain type, or find all classes that implement a certain interface) but with enums, there should be a way to do this in Java.