TypedMap implements Iterable<Entry<Object, V>> { @NonNull Single<V> get(Object key) { if (map.containsKey(key)) { return Single.just(map.get(key)); } else if (key != null && map.containsKey(key.getClass())) { return Single.just(map.get(key.getClass())); } else { return Single.error(new NoSuchElementException("no value mapped to : " + key)); } } TypedMap(Map<Object, V> map); @NonNull TypedMap<V> clear(); @Override @NonNull Iterator<Entry<Object, V>> iterator();  }
@Test(expected = NoSuchElementException.class) public void getObjectKeyFromEmptyMapThenThrowNoSuchElement() { TypedMap<Integer> map = new TypedMap<>(new HashMap<Object,Integer>()); map.get(new A()).blockingGet(); }
@Test(expected = NoSuchElementException.class) public void getClassKeyFromEmptyMapThenThrowNoSuchElement() { TypedMap<Integer> map = new TypedMap<>(new HashMap<Object,Integer>()); map.get(A.class).blockingFirst(); }