You can extend the singleton enum paradigm to support "similar but different" singletones using the marker interface:
public interface MySingletonInterface {
void doFoo(Bar bar);
}
Then your enums can implement the interface:
public enum FirstSingletonEnum implements MySingleTonInterface {
...
@Override
public void doFoo(Bar bar) {
...
}
}
public enum SecondSingletonEnum implements MySingleTonInterface {
...
@Override
public void doFoo(Bar bar) {
...
}
}
It seems to me that this is a cleaner approach that puts all implementations in one enumeration.
, . , , enum , , enum, . , , , , .