I'm using enums like below snippet and it is very helpful for me. However, when I want to define more than one ENUM (e.g. ENUM2, ENUM3), which have same parameters, I have to write everything that is tagged as "repeated code" in the snippet.
I'm thinking to encapsulate all parameters (p1, ...) within an object and just to give a reference to this object in the enum. However, this idea disturbs me since other extra instances will be generated.
Is the above approach is right, or how can solve this problem?
public enum ENUM1 {
KEY_1(p1, p2, ..., pn),
...
KEY_M(p1, p2, ..., pn);
// constructor
// REPEATED CODE
private int p1, p2, ..., pn;
public getP1();
...
public getPM();
}