I am constructing enum values that have a data structure like the following:
enum MetaType {
HUMAN(
new MetaTypeAttribute(AttributeType.BODY, 1, 6),
new MetaTypeAttribute(AttributeType.AGILITY, 1, 6),
new MetaTypeAttribute(AttributeType.REACTION, 1, 6)
),
ORK(
new MetaTypeAttribute(AttributeType.BODY, 4, 9),
new MetaTypeAttribute(AttributeType.AGILITY, 1, 6),
new MetaTypeAttribute(AttributeType.REACTION, 1, 6)
);
MetaType(MetaTypeAttribute body, MetaTypeAttribute agility, MetaTypeAttribute reaction) {
}
}
So there is an enum of MetaTypes; each MetaType specifies a fixed set of MetaTypeAttributes, which consist of a min and max value for that attribute.
I hate this syntax. It's too long, it's ugly, and it doesn't prevent me from passing in the wrong AttributeType (the AttributeType should match up with the order of the arguments of MetaType's constructor; AttributeType.BODY > body, etc.). What I want is a better pattern for ensuring that an object is constructed with this exact scheme.
This code is abbreviated. In reality there are 9 AttributeTypes.
Any suggestions for improvement?