MixedTypeMap implements ReadOnlyMixedTypeMap<K> { @Override public <V> V get(K id, Class<V> clazz) { Key<K, V> key = Key.get(id, clazz); return (V) map.get(key); } MixedTypeMap(Map<Key<K, ?>, Object> map);  MixedTypeMap(); void put(K id, Class<V1> clazz, V2 instance); void put(K id, TypeToken<V1> clazz, V2 instance); void put(Key<K, V1> key, V2 instance); @Override V get(K id, Class<V> clazz); @Override V get(K id, TypeToken<V> type); @Override V get(Key<K, V> key); MixedTypeMap<K> putAll(MixedTypeMap<K> otherMap); @Override int size(); void clear();  }
@Test(groups = "fast") public void testSanity1() throws Exception { Long value = stringMap1.get(key1, Long.class); Assert.assertEquals(value.longValue(), 100L); }
@Test(groups = "fast") public void testSanity2() throws Exception { Pair pair = stringMap1.get(key2); Assert.assertEquals(pair.getFirst(), 200L); Assert.assertEquals(pair.getSecond(), 800L); }
@Test(groups = "fast") public void testSanity3() throws Exception { CounterMap<String> value = stringMap1.get(key3); Assert.assertEquals(value.get("a"), 1); Assert.assertEquals(value.get("b"), 2); Assert.assertEquals(value.get("c"), 3); }
@Test(groups = "fast") public void testSuperType() throws Exception { Key<String, Object> objectKey = Key.get("x", Object.class); Key<String, Number> numberKey = Key.get("x", Number.class); Key<String, Float> floatKey = Key.get("x", Float.class); asssertSuperTestResults(objectKey, numberKey, floatKey); }
@Test(groups = "fast") public void testSuperUsingTypeToken() throws Exception { Key<String, Object> objectKey = Key.get("x", TypeToken.of(Object.class)); Key<String, Number> numberKey = Key.get("x", TypeToken.of(Number.class)); Key<String, Float> floatKey = Key.get("x", TypeToken.of(Float.class)); asssertSuperTestResults(objectKey, numberKey, floatKey); }