@SuppressWarnings("unchecked") public V put(K1 key1, K2 key2, V value) { assert k1Class.isInstance(key1); assert k2Class.isInstance(key2); assert valueClass.isInstance(value); Map<K2, V> map = get(key1); if (map == null) { map = new HashMap<>(); if (valueClass != Object.class) { map = Collections.checkedMap(map, (Class<K2>) k2Class, (Class<V>) valueClass); } put(key1, map); } return map.put(key2, value); }
public V get(K1 key1, K2 key2) { Map<K2, V> map = get(key1); if (map == null) return null; return map.get(key2); }
public DoubleKeyMap(Map<K1, Map<K2, V>> other) { this(); for (java.util.Map.Entry<K1, Map<K2, V>> e : other.entrySet()) { putAll(e.getKey(), e.getValue()); } }
public void putAll(K1 key1, Map<K2, V> map) { assert k1Class.isInstance(key1); for (Map.Entry<K2, V> e : map.entrySet()) { put(key1, e.getKey(), e.getValue()); } }
@SuppressWarnings("unchecked") public V put(K1 key1, K2 key2, V value) { assert k1Class.isInstance(key1); assert k2Class.isInstance(key2); assert valueClass.isInstance(value); Map<K2, V> map = get(key1); if (map == null) { map = new HashMap<>(); if (valueClass != Object.class) { map = Collections.checkedMap(map, (Class<K2>) k2Class, (Class<V>) valueClass); } put(key1, map); } return map.put(key2, value); }
public V get(K1 key1, K2 key2) { Map<K2, V> map = get(key1); if (map == null) return null; return map.get(key2); }
public DoubleKeyMap(Map<K1, Map<K2, V>> other) { this(); for (java.util.Map.Entry<K1, Map<K2, V>> e : other.entrySet()) { putAll(e.getKey(), e.getValue()); } }
public void putAll(K1 key1, Map<K2, V> map) { assert k1Class.isInstance(key1); for (Map.Entry<K2, V> e : map.entrySet()) { put(key1, e.getKey(), e.getValue()); } }
@SuppressWarnings("unchecked") public V put(K1 key1, K2 key2, V value) { assert k1Class.isInstance(key1); assert k2Class.isInstance(key2); assert valueClass.isInstance(value); Map<K2, V> map = get(key1); if (map == null) { map = new HashMap<>(); if (valueClass != Object.class) { map = Collections.checkedMap(map, (Class<K2>) k2Class, (Class<V>) valueClass); } put(key1, map); } return map.put(key2, value); }
public boolean containsKeys(K1 key1, K2 key2) { Map<K2, V> map = get(key1); if (map == null) return false; return map.containsKey(key2); }
public DoubleKeyMap(Map<K1, Map<K2, V>> other) { this(); for (java.util.Map.Entry<K1, Map<K2, V>> e : other.entrySet()) { putAll(e.getKey(), e.getValue()); } }
public void putAll(K1 key1, Map<K2, V> map) { assert k1Class.isInstance(key1); for (Map.Entry<K2, V> e : map.entrySet()) { put(key1, e.getKey(), e.getValue()); } }
@SuppressWarnings("unchecked") public V put(K1 key1, K2 key2, V value) { assert k1Class.isInstance(key1); assert k2Class.isInstance(key2); assert valueClass.isInstance(value); Map<K2, V> map = get(key1); if (map == null) { map = new HashMap<>(); if (valueClass != Object.class) { map = Collections.checkedMap(map, (Class<K2>) k2Class, (Class<V>) valueClass); } put(key1, map); } return map.put(key2, value); }
public boolean containsKeys(K1 key1, K2 key2) { Map<K2, V> map = get(key1); if (map == null) return false; return map.containsKey(key2); }