@Test public void entrySet() { final Set<Map.Entry<String, String>> entries = sampleMap().entrySet(); assertEquals(3, entries.size()); assertTrue(entries.contains(new AbstractMap.SimpleImmutableEntry<>("my.prop", "1234"))); assertTrue(entries.contains(new AbstractMap.SimpleImmutableEntry<>("my.null.value", null))); assertTrue(entries.contains(new AbstractMap.SimpleImmutableEntry<>("my.null", null))); assertThrows(UnsupportedOperationException.class, () -> entries.remove(new AbstractMap.SimpleImmutableEntry<>("my.prop", "1234"))); }
@Override public Set<Map.Entry<String, String>> entrySet() { if (entrySet == null) { entrySet = new AbstractSet<Entry<String, String>>() { @Override public Iterator<Entry<String, String>> iterator() { return new Iterator<Entry<String, String>>() { final Iterator<Entry<String, ConfigValue>> delegate = ConfigValueMapView.this.delegate.entrySet() .iterator(); @Override public boolean hasNext() { return delegate.hasNext(); } @Override public Entry<String, String> next() { final Entry<String, ConfigValue> next = delegate.next(); final ConfigValue configValue = next.getValue(); final String value = configValue != null ? configValue.getValue() : null; return new AbstractMap.SimpleImmutableEntry<>(next.getKey(), value); } }; } @Override public int size() { return delegate.size(); } }; } return entrySet; }
ConfigValueMapView extends AbstractMap<String, String> { @Override public Set<Map.Entry<String, String>> entrySet() { if (entrySet == null) { entrySet = new AbstractSet<Entry<String, String>>() { @Override public Iterator<Entry<String, String>> iterator() { return new Iterator<Entry<String, String>>() { final Iterator<Entry<String, ConfigValue>> delegate = ConfigValueMapView.this.delegate.entrySet() .iterator(); @Override public boolean hasNext() { return delegate.hasNext(); } @Override public Entry<String, String> next() { final Entry<String, ConfigValue> next = delegate.next(); final ConfigValue configValue = next.getValue(); final String value = configValue != null ? configValue.getValue() : null; return new AbstractMap.SimpleImmutableEntry<>(next.getKey(), value); } }; } @Override public int size() { return delegate.size(); } }; } return entrySet; } }
ConfigValueMapView extends AbstractMap<String, String> { @Override public Set<Map.Entry<String, String>> entrySet() { if (entrySet == null) { entrySet = new AbstractSet<Entry<String, String>>() { @Override public Iterator<Entry<String, String>> iterator() { return new Iterator<Entry<String, String>>() { final Iterator<Entry<String, ConfigValue>> delegate = ConfigValueMapView.this.delegate.entrySet() .iterator(); @Override public boolean hasNext() { return delegate.hasNext(); } @Override public Entry<String, String> next() { final Entry<String, ConfigValue> next = delegate.next(); final ConfigValue configValue = next.getValue(); final String value = configValue != null ? configValue.getValue() : null; return new AbstractMap.SimpleImmutableEntry<>(next.getKey(), value); } }; } @Override public int size() { return delegate.size(); } }; } return entrySet; } ConfigValueMapView(final Map<String, ConfigValue> delegate); }
ConfigValueMapView extends AbstractMap<String, String> { @Override public Set<Map.Entry<String, String>> entrySet() { if (entrySet == null) { entrySet = new AbstractSet<Entry<String, String>>() { @Override public Iterator<Entry<String, String>> iterator() { return new Iterator<Entry<String, String>>() { final Iterator<Entry<String, ConfigValue>> delegate = ConfigValueMapView.this.delegate.entrySet() .iterator(); @Override public boolean hasNext() { return delegate.hasNext(); } @Override public Entry<String, String> next() { final Entry<String, ConfigValue> next = delegate.next(); final ConfigValue configValue = next.getValue(); final String value = configValue != null ? configValue.getValue() : null; return new AbstractMap.SimpleImmutableEntry<>(next.getKey(), value); } }; } @Override public int size() { return delegate.size(); } }; } return entrySet; } ConfigValueMapView(final Map<String, ConfigValue> delegate); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(final Object key); @Override boolean containsValue(final Object value); @Override String get(final Object key); @Override Set<String> keySet(); @Override Set<Map.Entry<String, String>> entrySet(); @Override Collection<String> values(); }
ConfigValueMapView extends AbstractMap<String, String> { @Override public Set<Map.Entry<String, String>> entrySet() { if (entrySet == null) { entrySet = new AbstractSet<Entry<String, String>>() { @Override public Iterator<Entry<String, String>> iterator() { return new Iterator<Entry<String, String>>() { final Iterator<Entry<String, ConfigValue>> delegate = ConfigValueMapView.this.delegate.entrySet() .iterator(); @Override public boolean hasNext() { return delegate.hasNext(); } @Override public Entry<String, String> next() { final Entry<String, ConfigValue> next = delegate.next(); final ConfigValue configValue = next.getValue(); final String value = configValue != null ? configValue.getValue() : null; return new AbstractMap.SimpleImmutableEntry<>(next.getKey(), value); } }; } @Override public int size() { return delegate.size(); } }; } return entrySet; } ConfigValueMapView(final Map<String, ConfigValue> delegate); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(final Object key); @Override boolean containsValue(final Object value); @Override String get(final Object key); @Override Set<String> keySet(); @Override Set<Map.Entry<String, String>> entrySet(); @Override Collection<String> values();  }