I have the following method:
public XAP_ENUM_EnumConverter put(Type enumType, XAP_ENUM_EnumWrapper enumWrapper) {
ENUM_WRAPPERS_BY_TYPE_MAP.put(enumType, enumWrapper);
return this;
}
which i can invoke in a constructor like this:
private ALP_CONX_ColourHelper(XAP_ENUM_EnumConverter converter) {
this.converter = converter;
this.converter.put(ALP_CONX_Colour.class, new XAP_ENUM_EnumWrapper(ALP_CONX_Colour.values()));
}
Where ALP_CONX_Colour
is an enum, e.g.
public enum ALP_CONX_Colour {
BLACK,
WHITE,
NONE
}
A helper for a different enum would have a similar constructor.
But this rather redundant, as the name of the enum-class is required to provide both paramenters and this should always be consistent. It would make no sense to have a Type for "Colours" and a List for "Shapes". So, I'd like to refactor this function to one parameter like:
public XAP_ENUM_EnumConverter put(Type enumType) {
List<Object> enumList = this.createEnumList(enumType);
XAP_ENUM_EnumWrapper enumWrapper = new XAP_ENUM_EnumWrapper(enumList);
ENUM_WRAPPERS_BY_TYPE_MAP.put(enumType, enumWrapper);
return this;
}
private List<Object> createEnumList(Type enumType) {
// What do I need to do here?
return ???
}
Is it possible to do this? If so, how?