@Test public void computeKeyAcceptsLegalKey1() { statistics.computeMapKey(statistics.MAX_KEY_1, 0, 0, CourseOverGroundStatisticData.STAT_SHIP_COUNT); }
short computeMapKey(int key1, int key2, int key3, String key4) { if (key1 > MAX_KEY_1) { throw new IllegalArgumentException("key1 must be 0-" + MAX_KEY_1 + " - not " + key1 + "."); } if (key2 > MAX_KEY_2) { throw new IllegalArgumentException("key2 must be 0-" + MAX_KEY_2 + " - not " + key2 + "."); } if (key3 > MAX_KEY_3) { throw new IllegalArgumentException("key3 must be 0-" + MAX_KEY_3 + " - not " + key3 + "."); } if (! getNameOfOnlySupportedValueOfKey4().equals(key4)) { throw new IllegalArgumentException("key4 '" + key4 + "' is not supported."); } final int d2 = MAX_KEY_2 + 1; final int d3 = MAX_KEY_3 + 1; return (short) (key1*d2*d3 + key2*d3 + key3); }
FourKeyStatisticData implements StatisticData, FourKeyMap { short computeMapKey(int key1, int key2, int key3, String key4) { if (key1 > MAX_KEY_1) { throw new IllegalArgumentException("key1 must be 0-" + MAX_KEY_1 + " - not " + key1 + "."); } if (key2 > MAX_KEY_2) { throw new IllegalArgumentException("key2 must be 0-" + MAX_KEY_2 + " - not " + key2 + "."); } if (key3 > MAX_KEY_3) { throw new IllegalArgumentException("key3 must be 0-" + MAX_KEY_3 + " - not " + key3 + "."); } if (! getNameOfOnlySupportedValueOfKey4().equals(key4)) { throw new IllegalArgumentException("key4 '" + key4 + "' is not supported."); } final int d2 = MAX_KEY_2 + 1; final int d3 = MAX_KEY_3 + 1; return (short) (key1*d2*d3 + key2*d3 + key3); } }
FourKeyStatisticData implements StatisticData, FourKeyMap { short computeMapKey(int key1, int key2, int key3, String key4) { if (key1 > MAX_KEY_1) { throw new IllegalArgumentException("key1 must be 0-" + MAX_KEY_1 + " - not " + key1 + "."); } if (key2 > MAX_KEY_2) { throw new IllegalArgumentException("key2 must be 0-" + MAX_KEY_2 + " - not " + key2 + "."); } if (key3 > MAX_KEY_3) { throw new IllegalArgumentException("key3 must be 0-" + MAX_KEY_3 + " - not " + key3 + "."); } if (! getNameOfOnlySupportedValueOfKey4().equals(key4)) { throw new IllegalArgumentException("key4 '" + key4 + "' is not supported."); } final int d2 = MAX_KEY_2 + 1; final int d3 = MAX_KEY_3 + 1; return (short) (key1*d2*d3 + key2*d3 + key3); } protected  FourKeyStatisticData(int maxKey1, int maxKey2, int maxKey3, int maxNumKey4); }
FourKeyStatisticData implements StatisticData, FourKeyMap { short computeMapKey(int key1, int key2, int key3, String key4) { if (key1 > MAX_KEY_1) { throw new IllegalArgumentException("key1 must be 0-" + MAX_KEY_1 + " - not " + key1 + "."); } if (key2 > MAX_KEY_2) { throw new IllegalArgumentException("key2 must be 0-" + MAX_KEY_2 + " - not " + key2 + "."); } if (key3 > MAX_KEY_3) { throw new IllegalArgumentException("key3 must be 0-" + MAX_KEY_3 + " - not " + key3 + "."); } if (! getNameOfOnlySupportedValueOfKey4().equals(key4)) { throw new IllegalArgumentException("key4 '" + key4 + "' is not supported."); } final int d2 = MAX_KEY_2 + 1; final int d3 = MAX_KEY_3 + 1; return (short) (key1*d2*d3 + key2*d3 + key3); } protected  FourKeyStatisticData(int maxKey1, int maxKey2, int maxKey3, int maxNumKey4); final int getMaxKey1(); final int getMaxKey2(); final int getMaxKey3(); @Override void incrementValue(int key1, int key2, int key3, String key4); @Override void setValue(int key1, int key2, int key3, String key4, int value); @Override Integer getValue(int key1, int key2, int key3, String key4); int aggregateSumOverKey1(int key2, int key3, String key4); @Override int getSumFor(String key4); @Override String getStatisticName(); @Override String getStatisticDataType(); @Override TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> getData(); }
FourKeyStatisticData implements StatisticData, FourKeyMap { short computeMapKey(int key1, int key2, int key3, String key4) { if (key1 > MAX_KEY_1) { throw new IllegalArgumentException("key1 must be 0-" + MAX_KEY_1 + " - not " + key1 + "."); } if (key2 > MAX_KEY_2) { throw new IllegalArgumentException("key2 must be 0-" + MAX_KEY_2 + " - not " + key2 + "."); } if (key3 > MAX_KEY_3) { throw new IllegalArgumentException("key3 must be 0-" + MAX_KEY_3 + " - not " + key3 + "."); } if (! getNameOfOnlySupportedValueOfKey4().equals(key4)) { throw new IllegalArgumentException("key4 '" + key4 + "' is not supported."); } final int d2 = MAX_KEY_2 + 1; final int d3 = MAX_KEY_3 + 1; return (short) (key1*d2*d3 + key2*d3 + key3); } protected  FourKeyStatisticData(int maxKey1, int maxKey2, int maxKey3, int maxNumKey4); final int getMaxKey1(); final int getMaxKey2(); final int getMaxKey3(); @Override void incrementValue(int key1, int key2, int key3, String key4); @Override void setValue(int key1, int key2, int key3, String key4, int value); @Override Integer getValue(int key1, int key2, int key3, String key4); int aggregateSumOverKey1(int key2, int key3, String key4); @Override int getSumFor(String key4); @Override String getStatisticName(); @Override String getStatisticDataType(); @Override TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> getData();  }