I am considering to use an enum with a static initializer like this:
public enum MyEnum{
...
private static HashMap<X, Y> features;
static {
features.put(X, new (Y));
}
...
}
Is the HashMap going to be reinitialized every time I need a value from it?
No, like all static blocks it’s executed only when the type is initialized.
So this will be done only once.
But you should affect a value to your map : you don’t do it in the code we see. You should have