17/12/23 22:53:26.74 uGK8CTGJ.net
enum使うなら専用のクラス作るとかね
class Table<Row, Column, Value> {
Map<Row, Map<Column, Value>> data;
Table() {
data = new HashMap<>();
}
void put(Row row, Column column, Value value) {
Map<Column, Value> record = data.get(row);
if (record == null) {
record = new HashMap<>();
data.put(row, record);
}
record.put(column, value);
}
Value get(Row row, Column column) {
Map<Column, Value> record = data.get(row);
if (record == null) {
return null;
}
return record.get(column);
}
}
public static void main(String[] args) {
Table<SexType, BloodType, String> table = new Table<>();
table.put(SexType.MALE, BloodType.A, "鈴木さん");
System.out.println(table.get(SexType.MALE, BloodType.A));
}