У меня есть следующий класс enum
:Сохранение коллекции карт значений в классе Enum для лучшего доступа
public class DataParameter {
public enum Types {
BIG(-1), SMALL(1), SMAL2(2), SMAL3(5), BIG1(-1), BIG2(1), BIG3(2), BIF4(
5);
private final int id;
Types(int id) {
this.id = id;
}
public int getValue() {
return id;
}
public static <T> parseType(T type, int id) {
int intType = Integer.parseInt(String.valueOf(type));
if (intType == SIZE_XL.getValue()) {
if (id == -1)
return BIG;
if (id == 1)
return BIG2;
if (id == 2)
return BIG3;
if (id == 5)
return BIG4;
} else if (intType == SIZE_LARGE.getValue()) {
if (id == 5)
return BIG4;
if (id == 2)
return SMALL2;
if (id == 5)
return SMALL3;
} else if (intType == SIZE_UKNOWN.getValue()) {
if (id == -1)
return BIG;
if (id == -1)
return BIG;
if (id == -1)
return BIG1;
if (id == 5)
return BIG4;
} else if (intType == SIZE_UKNOWN_2.getValue()) {
return SMAL3;
}
return returnDefault(intType);
}
}
public DataParameter(GameTypes type) {
mValue = type.getValue();
}
}
Проблема, что этот код очень грязные много если заявления. Я попытался создать карту, которая будет следующая структура:
SIZE_XL ---> BIG,BIG2,BIG4
SIZE_LARGE ---> BIG4,SMALL2 ,SMALL3
SIZE_UKNOWN ---> BIG , BIG1 , BIG4
и их, когда, когда я получу ключ я извлечь элемент из карты я запутаться, потому что в enum
классе я получаю какое-то неизвестное проблемы.
HashMap<Integer, HashMap<Integer, Integer> myMap = new HashMap<Integer, HashMap<Integer, Integer>();
myMap.put(SIZE_XL.getValue(),BIG2.getValue(),BIG2)
myMap.put(SIZE_XL.getValue(),BIG3.getValue(),BIG3)
myMap.put(SIZE_XL.getValue(),BIG4.getValue(),BIG4)
...
... ..
Я ценю помощь в этом вопросе