/** * Utility method used to organize pairs into a Map. * * @param pairs * An array of Key/Value pairs * @return Map<Key,Value> * @throws ClassCastException * if Key/Value pairs do not match */ private static Map fromPairs(Object[] pairs) { Map map = new HashMap(); for (int i = 0; i < pairs.length; i += 2) { Key key = (Key) pairs[i]; Object value = pairs[i+1]; if (!key.isCompatibleValue(value)) { throw new ClassCastException(key + " requires " + key.getValueClass() + " - could cast " + value); } map.put(key, value); } return map; }
return super.isCompatibleValue(value);