@Test public void getData() { statistics.setValue(3, 1, ShipTypeAndSizeStatisticData.STAT_SHIP_COUNT, 42); TreeMap<Integer,TreeMap<Integer,HashMap<String,Integer>>> data = statistics.getData(); assertEquals(42, (int) data.get(3+1).get(1+1).get(ShipTypeAndSizeStatisticData.STAT_SHIP_COUNT)); assertNull(data.get(3+1).get(2+1)); assertNull(data.get(2+1)); assertEquals(1, data.keySet().size()); assertEquals(1, data.get(3+1).keySet().size()); }
@Override public TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> getData() { TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> root = new TreeMap<>(); TShortIterator keys = data.keySet().iterator(); while(keys.hasNext()) { short key = keys.next(); int key1 = extractKey1(key); int key2 = extractKey2(key); int shipTypeBucket = key1 + 1; int shipSizeBucket = key2 + 1; TreeMap<Integer, HashMap<String, Integer>> level1 = root.get(shipTypeBucket); if (level1 == null) { level1 = new TreeMap<>(); root.put(shipTypeBucket, level1); } HashMap<String, Integer> statistics = level1.get(shipSizeBucket); if (statistics == null) { statistics = new HashMap<>(); level1.put(shipSizeBucket, statistics); } String statisticsName = STAT_SHIP_COUNT; Integer statisticsValue = getValue(key1, key2, statisticsName); if (statisticsValue != null) { statistics.put(statisticsName, statisticsValue); } } return root; }
ShipTypeAndSizeStatisticData implements StatisticData, ThreeKeyMap { @Override public TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> getData() { TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> root = new TreeMap<>(); TShortIterator keys = data.keySet().iterator(); while(keys.hasNext()) { short key = keys.next(); int key1 = extractKey1(key); int key2 = extractKey2(key); int shipTypeBucket = key1 + 1; int shipSizeBucket = key2 + 1; TreeMap<Integer, HashMap<String, Integer>> level1 = root.get(shipTypeBucket); if (level1 == null) { level1 = new TreeMap<>(); root.put(shipTypeBucket, level1); } HashMap<String, Integer> statistics = level1.get(shipSizeBucket); if (statistics == null) { statistics = new HashMap<>(); level1.put(shipSizeBucket, statistics); } String statisticsName = STAT_SHIP_COUNT; Integer statisticsValue = getValue(key1, key2, statisticsName); if (statisticsValue != null) { statistics.put(statisticsName, statisticsValue); } } return root; } }
ShipTypeAndSizeStatisticData implements StatisticData, ThreeKeyMap { @Override public TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> getData() { TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> root = new TreeMap<>(); TShortIterator keys = data.keySet().iterator(); while(keys.hasNext()) { short key = keys.next(); int key1 = extractKey1(key); int key2 = extractKey2(key); int shipTypeBucket = key1 + 1; int shipSizeBucket = key2 + 1; TreeMap<Integer, HashMap<String, Integer>> level1 = root.get(shipTypeBucket); if (level1 == null) { level1 = new TreeMap<>(); root.put(shipTypeBucket, level1); } HashMap<String, Integer> statistics = level1.get(shipSizeBucket); if (statistics == null) { statistics = new HashMap<>(); level1.put(shipSizeBucket, statistics); } String statisticsName = STAT_SHIP_COUNT; Integer statisticsValue = getValue(key1, key2, statisticsName); if (statisticsValue != null) { statistics.put(statisticsName, statisticsValue); } } return root; } protected  ShipTypeAndSizeStatisticData(int maxKey1, int maxKey2, int maxNumKey3); }
ShipTypeAndSizeStatisticData implements StatisticData, ThreeKeyMap { @Override public TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> getData() { TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> root = new TreeMap<>(); TShortIterator keys = data.keySet().iterator(); while(keys.hasNext()) { short key = keys.next(); int key1 = extractKey1(key); int key2 = extractKey2(key); int shipTypeBucket = key1 + 1; int shipSizeBucket = key2 + 1; TreeMap<Integer, HashMap<String, Integer>> level1 = root.get(shipTypeBucket); if (level1 == null) { level1 = new TreeMap<>(); root.put(shipTypeBucket, level1); } HashMap<String, Integer> statistics = level1.get(shipSizeBucket); if (statistics == null) { statistics = new HashMap<>(); level1.put(shipSizeBucket, statistics); } String statisticsName = STAT_SHIP_COUNT; Integer statisticsValue = getValue(key1, key2, statisticsName); if (statisticsValue != null) { statistics.put(statisticsName, statisticsValue); } } return root; } protected  ShipTypeAndSizeStatisticData(int maxKey1, int maxKey2, int maxNumKey3); static ShipTypeAndSizeStatisticData create(); @Override @SuppressWarnings("unused") String getMeaningOfKey1(); @Override @SuppressWarnings("unused") String getMeaningOfKey2(); @Override @SuppressWarnings("unused") String getMeaningOfKey3(); @Override String getStatisticName(); @Override String getStatisticDataType(); @Override TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> getData(); @Override void incrementValue(int key1, int key2, String key3); @Override void setValue(int key1, int key2, String key3, int value); @Override Integer getValue(int key1, int key2, String key3); @Override int getSumFor(String key3); }
ShipTypeAndSizeStatisticData implements StatisticData, ThreeKeyMap { @Override public TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> getData() { TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> root = new TreeMap<>(); TShortIterator keys = data.keySet().iterator(); while(keys.hasNext()) { short key = keys.next(); int key1 = extractKey1(key); int key2 = extractKey2(key); int shipTypeBucket = key1 + 1; int shipSizeBucket = key2 + 1; TreeMap<Integer, HashMap<String, Integer>> level1 = root.get(shipTypeBucket); if (level1 == null) { level1 = new TreeMap<>(); root.put(shipTypeBucket, level1); } HashMap<String, Integer> statistics = level1.get(shipSizeBucket); if (statistics == null) { statistics = new HashMap<>(); level1.put(shipSizeBucket, statistics); } String statisticsName = STAT_SHIP_COUNT; Integer statisticsValue = getValue(key1, key2, statisticsName); if (statisticsValue != null) { statistics.put(statisticsName, statisticsValue); } } return root; } protected  ShipTypeAndSizeStatisticData(int maxKey1, int maxKey2, int maxNumKey3); static ShipTypeAndSizeStatisticData create(); @Override @SuppressWarnings("unused") String getMeaningOfKey1(); @Override @SuppressWarnings("unused") String getMeaningOfKey2(); @Override @SuppressWarnings("unused") String getMeaningOfKey3(); @Override String getStatisticName(); @Override String getStatisticDataType(); @Override TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> getData(); @Override void incrementValue(int key1, int key2, String key3); @Override void setValue(int key1, int key2, String key3, int value); @Override Integer getValue(int key1, int key2, String key3); @Override int getSumFor(String key3); static final String STAT_SHIP_COUNT; }