@Test public void values() { final Collection<String> values = sampleMap().values(); assertEquals(3, values.size()); assertTrue(values.contains(null)); assertTrue(values.contains("1234")); assertThrows(UnsupportedOperationException.class, () -> values.remove("1234")); }
@Override public Collection<String> values() { if (values == null) { values = new AbstractCollection<String>() { @Override public Iterator<String> iterator() { final Iterator<ConfigValue> delegate = ConfigValueMapView.this.delegate.values().iterator(); return new Iterator<String>() { @Override public boolean hasNext() { return delegate.hasNext(); } @Override public String next() { final ConfigValue configValue = delegate.next(); return configValue != null ? configValue.getValue() : null; } }; } @Override public int size() { return delegate.size(); } }; } return values; }
ConfigValueMapView extends AbstractMap<String, String> { @Override public Collection<String> values() { if (values == null) { values = new AbstractCollection<String>() { @Override public Iterator<String> iterator() { final Iterator<ConfigValue> delegate = ConfigValueMapView.this.delegate.values().iterator(); return new Iterator<String>() { @Override public boolean hasNext() { return delegate.hasNext(); } @Override public String next() { final ConfigValue configValue = delegate.next(); return configValue != null ? configValue.getValue() : null; } }; } @Override public int size() { return delegate.size(); } }; } return values; } }
ConfigValueMapView extends AbstractMap<String, String> { @Override public Collection<String> values() { if (values == null) { values = new AbstractCollection<String>() { @Override public Iterator<String> iterator() { final Iterator<ConfigValue> delegate = ConfigValueMapView.this.delegate.values().iterator(); return new Iterator<String>() { @Override public boolean hasNext() { return delegate.hasNext(); } @Override public String next() { final ConfigValue configValue = delegate.next(); return configValue != null ? configValue.getValue() : null; } }; } @Override public int size() { return delegate.size(); } }; } return values; } ConfigValueMapView(final Map<String, ConfigValue> delegate); }
ConfigValueMapView extends AbstractMap<String, String> { @Override public Collection<String> values() { if (values == null) { values = new AbstractCollection<String>() { @Override public Iterator<String> iterator() { final Iterator<ConfigValue> delegate = ConfigValueMapView.this.delegate.values().iterator(); return new Iterator<String>() { @Override public boolean hasNext() { return delegate.hasNext(); } @Override public String next() { final ConfigValue configValue = delegate.next(); return configValue != null ? configValue.getValue() : null; } }; } @Override public int size() { return delegate.size(); } }; } return values; } 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 Collection<String> values() { if (values == null) { values = new AbstractCollection<String>() { @Override public Iterator<String> iterator() { final Iterator<ConfigValue> delegate = ConfigValueMapView.this.delegate.values().iterator(); return new Iterator<String>() { @Override public boolean hasNext() { return delegate.hasNext(); } @Override public String next() { final ConfigValue configValue = delegate.next(); return configValue != null ? configValue.getValue() : null; } }; } @Override public int size() { return delegate.size(); } }; } return values; } 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();  }