Returns an unmodifiable view of the specified map entry. The Entry#setValue operation throws an UnsupportedOperationException. This also has the side-effect of redefining equals to comply with the Entry contract, to avoid a possible nefarious implementation of equals. @param
(final Entry<? extends K, ? extends V> entry)
| 1349 | |
| 1350 | |
| 1351 | static <K, V> Entry<K, V> unmodifiableEntry(final Entry<? extends K, ? extends V> entry) { |
| 1352 | checkNotNull(entry); |
| 1353 | return new AbstractMapEntry<K, V>() { |
| 1354 | @Override |
| 1355 | public K getKey() { |
| 1356 | return entry.getKey(); |
| 1357 | } |
| 1358 | |
| 1359 | @Override |
| 1360 | public V getValue() { |
| 1361 | return entry.getValue(); |
| 1362 | } |
| 1363 | }; |
| 1364 | } |
| 1365 | |
| 1366 | |
| 1367 | static <K, V> UnmodifiableIterator<Entry<K, V>> unmodifiableEntryIterator(final Iterator<Entry<K, V>> entryIterator) { |
no test coverage detected