@Test public void entrySetToArrayWithInitializer() { Map.Entry[] init_exact_size = new Map.Entry[3]; Map.Entry[] init_too_small = new Map.Entry[2]; Map.Entry[] init_empty = new Map.Entry[0]; Map.Entry[] init_too_large = new Map.Entry[4]; Map.Entry[] arr_exact_size = map.entrySet().toArray(init_exact_size); Map.Entry[] arr_too_small = map.entrySet().toArray(init_too_small); Map.Entry[] arr_empty = map.entrySet().toArray(init_empty); Map.Entry[] arr_too_large = map.entrySet().toArray(init_too_large); assertSame(init_exact_size, arr_exact_size); assertNotSame(init_too_small, arr_too_small); assertNotSame(init_empty, arr_empty); assertSame(init_too_large, arr_too_large); assertThat(arr_exact_size, arrayContainingInAnyOrder( SimpleMapEntry.create(1, 1), SimpleMapEntry.create(4, 16), SimpleMapEntry.create(9, 81))); assertThat(arr_too_small, arrayContainingInAnyOrder( SimpleMapEntry.create(1, 1), SimpleMapEntry.create(4, 16), SimpleMapEntry.create(9, 81))); assertThat(arr_empty, arrayContainingInAnyOrder( SimpleMapEntry.create(1, 1), SimpleMapEntry.create(4, 16), SimpleMapEntry.create(9, 81))); assertThat(Arrays.copyOf(arr_too_large, 3), arrayContainingInAnyOrder( SimpleMapEntry.create(1, 1), SimpleMapEntry.create(4, 16), SimpleMapEntry.create(9, 81))); assertNull(arr_too_large[3]); }
@Override public Set<Map.Entry<K, V>> entrySet() { return new EntrySet(); }
LazyMap implements Map<K, V> { @Override public Set<Map.Entry<K, V>> entrySet() { return new EntrySet(); } }
LazyMap implements Map<K, V> { @Override public Set<Map.Entry<K, V>> entrySet() { return new EntrySet(); } LazyMap(Function<? super K, ? extends V> compute);  LazyMap(Function<? super K, ? extends V> compute, Supplier<Map<K, V>> mapSupplier);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys, Supplier<Map<K, V>> mapSupplier); }
LazyMap implements Map<K, V> { @Override public Set<Map.Entry<K, V>> entrySet() { return new EntrySet(); } LazyMap(Function<? super K, ? extends V> compute);  LazyMap(Function<? super K, ? extends V> compute, Supplier<Map<K, V>> mapSupplier);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys, Supplier<Map<K, V>> mapSupplier); @Override boolean isEmpty(); @Override int size(); @Override V get(Object key); @Override V put(K key, V value); @Override void putAll(Map<? extends K, ? extends V> m); @Override V remove(Object k); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Map.Entry<K, V>> entrySet(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); }
LazyMap implements Map<K, V> { @Override public Set<Map.Entry<K, V>> entrySet() { return new EntrySet(); } LazyMap(Function<? super K, ? extends V> compute);  LazyMap(Function<? super K, ? extends V> compute, Supplier<Map<K, V>> mapSupplier);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys, Supplier<Map<K, V>> mapSupplier); @Override boolean isEmpty(); @Override int size(); @Override V get(Object key); @Override V put(K key, V value); @Override void putAll(Map<? extends K, ? extends V> m); @Override V remove(Object k); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Map.Entry<K, V>> entrySet(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString();  }