I would have enum like this:
enum Kind { GREEN { @Override public void doSomething() { GreenKind.doSomething(); } }, WHITE { @Override public void doSomething() { WhiteKind.doSomething(); } }; public abstract void doSomething(); }
And pass the enum constant, for example, this method:
public static void invoke(Kind kind) { kind.doSomething(); }
and name it like this:
invoke(Kind.GREEN);
This method looks cleaner and is also safer since you can only have a fixed set of inputs.
source share