This map is immutable, and designed to provide a map implementation that is only used to iterate over its entries. Each entry in this map is dynamically generated based on an entry in the underlying map.
Any method that is not the size(), isEmpty(), Map.forEach(
Important: Implementations should ensure that the transformed keys still stay unique in the map, as they was in the subject map. Violating this may result in undefined behaviour in some implementations.
An use-case for this kind of map is to create a new Map with the given entries without pre-allocating the transformed entries beforehand.
Example:
Map<Integer, Integer> ints = ...; Map<Integer, String> nmap = new TreeMap<>(new TransformingMap<Integer, Integer, Integer, String>(ints) { @Override protected Entry<Integer, String> transformEntry(Integer key, Integer value) { return ImmutableUtils.makeImmutableMapEntry(key + value, Integer.toString(key * value)); } });Constructing a map in this way instead of calling Map.put(
public | TransformingMap( Creates a new instance with the given map. |
public Set< | entrySet() Returns a Set view of the mappings contained in this map. |
public boolean | isEmpty() Returns true if this map contains no key-value mappings. |
public int | size() Returns the number of key-value mappings in this map. |
protected abstract Entry< | transformEntry( Transforms the source entry key-value pair to the map entry. |
From: AbstractMap< |
From: Object |
From: Map< |
null
.