- java.lang.Object
-
- net.morimekta.collect.UnmodifiableMapBase<K,V>
-
- Type Parameters:
K
- The map key type.V
- The map value type.
- All Implemented Interfaces:
Map<K,V>
- Direct Known Subclasses:
UnmodifiableMap
,UnmodifiableSortedMap
public abstract class UnmodifiableMapBase<K,V> extends Object implements Map<K,V>
Base implementation class for immutable maps.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsValue(Object o)
protected static <K,V>
Map.Entry<K,V>entry(K key, V value)
Set<Map.Entry<K,V>>
entrySet()
boolean
equals(Object obj)
int
hashCode()
boolean
isEmpty()
Set<K>
keySet()
protected abstract Set<Map.Entry<K,V>>
makeEntrySet()
protected abstract Set<K>
makeKeySet()
UnmodifiableSortedMap<K,V>
orderedBy(Comparator<? super K> comparator)
Get the map as a sorted map ordered by the specific comparator.V
put(K k, V v)
void
putAll(Map<? extends K,? extends V> map)
V
remove(Object o)
int
size()
String
toString()
Collection<V>
values()
abstract Map<K,V>
withEntries(Map<? extends K,? extends V> map)
Get a map with entries from this with additional entries from provided map.abstract Map<K,V>
withEntry(K key, V value)
Get a map with entries from this with the additional entry.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, forEach, get, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
orderedBy
public UnmodifiableSortedMap<K,V> orderedBy(Comparator<? super K> comparator)
Get the map as a sorted map ordered by the specific comparator.- Parameters:
comparator
- The comparator to make the map sorted for.- Returns:
- The sorted map.
-
withEntry
public abstract Map<K,V> withEntry(K key, V value)
Get a map with entries from this with the additional entry. The entry will overwrite if the key conflicts.- Parameters:
key
- The entry key.value
- The entry value.- Returns:
- The resulting map.
-
withEntries
public abstract Map<K,V> withEntries(Map<? extends K,? extends V> map)
Get a map with entries from this with additional entries from provided map. Entries in the provided map will overwrite if key conflict.- Parameters:
map
- Map with additional entries.- Returns:
- The resulting map.
-
containsValue
public boolean containsValue(Object o)
- Specified by:
containsValue
in interfaceMap<K,V>
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object obj)
-
entry
protected static <K,V> Map.Entry<K,V> entry(K key, V value)
-
-