@Test public void shouldHaveEqualEntry() { Map<String, String> map = new ImmutableMap<>( Collections.singletonMap( "k", "v" ) ); Entry<String, String> e = map.entrySet().iterator().next(); assertThat( e, is( e ) ); assertThat( e, is( (Entry<String, String>) new Node<>( "k", "v" ) ) ); }
@Override public Set<Entry<K, V>> entrySet() { Set<Entry<K, V>> entries = new LinkedHashSet<>(); Node<K, V> node = first; while ( node != null ) { entries.add( node ); node = node.next; } return unmodifiableSet( entries ); }
ImmutableMap extends AbstractMap<K, V> { @Override public Set<Entry<K, V>> entrySet() { Set<Entry<K, V>> entries = new LinkedHashSet<>(); Node<K, V> node = first; while ( node != null ) { entries.add( node ); node = node.next; } return unmodifiableSet( entries ); } }
ImmutableMap extends AbstractMap<K, V> { @Override public Set<Entry<K, V>> entrySet() { Set<Entry<K, V>> entries = new LinkedHashSet<>(); Node<K, V> node = first; while ( node != null ) { entries.add( node ); node = node.next; } return unmodifiableSet( entries ); } ImmutableMap( Map<K, V> map ); }
ImmutableMap extends AbstractMap<K, V> { @Override public Set<Entry<K, V>> entrySet() { Set<Entry<K, V>> entries = new LinkedHashSet<>(); Node<K, V> node = first; while ( node != null ) { entries.add( node ); node = node.next; } return unmodifiableSet( entries ); } ImmutableMap( Map<K, V> map ); @Override Set<Entry<K, V>> entrySet(); }
ImmutableMap extends AbstractMap<K, V> { @Override public Set<Entry<K, V>> entrySet() { Set<Entry<K, V>> entries = new LinkedHashSet<>(); Node<K, V> node = first; while ( node != null ) { entries.add( node ); node = node.next; } return unmodifiableSet( entries ); } ImmutableMap( Map<K, V> map ); @Override Set<Entry<K, V>> entrySet();  }