Class ForwardingNavigableMap<K,V>
- java.lang.Object
-
- com.google.common.collect.ForwardingObject
-
- com.google.common.collect.ForwardingMap<K,V>
-
- com.google.common.collect.ForwardingSortedMap<K,V>
-
- com.google.common.collect.ForwardingNavigableMap<K,V>
-
- All Implemented Interfaces:
Map<K,V>
,NavigableMap<K,V>
,SortedMap<K,V>
public abstract class ForwardingNavigableMap<K,V> extends ForwardingSortedMap<K,V> implements NavigableMap<K,V>
A navigable map which forwards all its method calls to another navigable map. Subclasses should override one or more methods to modify the behavior of the backing map as desired per the decorator pattern.Warning: The methods of
ForwardingNavigableMap
forward indiscriminately to the methods of the delegate. For example, overridingForwardingMap.put(K, V)
alone will not change the behavior ofForwardingMap.putAll(java.util.Map<? extends K, ? extends V>)
, which can lead to unexpected behavior. In this case, you should overrideputAll
as well, either providing your own implementation, or delegating to the providedstandardPutAll
method.Each of the
standard
methods uses the map's comparator (or the natural ordering of the elements, if there is no comparator) to test element equality. As a result, if the comparator is not consistent with equals, some of the standard implementations may violate theMap
contract.The
standard
methods and the collection views they return are not guaranteed to be thread-safe, even when all of the methods that they depend on are thread-safe.- Since:
- 12.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map.Entry<K,V>
ceilingEntry(K key)
K
ceilingKey(K key)
NavigableSet<K>
descendingKeySet()
NavigableMap<K,V>
descendingMap()
Map.Entry<K,V>
firstEntry()
Map.Entry<K,V>
floorEntry(K key)
K
floorKey(K key)
NavigableMap<K,V>
headMap(K toKey, boolean inclusive)
Map.Entry<K,V>
higherEntry(K key)
K
higherKey(K key)
Map.Entry<K,V>
lastEntry()
Map.Entry<K,V>
lowerEntry(K key)
K
lowerKey(K key)
NavigableSet<K>
navigableKeySet()
Map.Entry<K,V>
pollFirstEntry()
Map.Entry<K,V>
pollLastEntry()
NavigableMap<K,V>
subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
NavigableMap<K,V>
tailMap(K fromKey, boolean inclusive)
-
Methods inherited from class com.google.common.collect.ForwardingSortedMap
comparator, firstKey, headMap, lastKey, subMap, tailMap
-
Methods inherited from class com.google.common.collect.ForwardingMap
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
-
Methods inherited from class com.google.common.collect.ForwardingObject
toString
-
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size
-
Methods inherited from interface java.util.NavigableMap
headMap, subMap, tailMap
-
-
-
-
Method Detail
-
lowerEntry
public Map.Entry<K,V> lowerEntry(K key)
- Specified by:
lowerEntry
in interfaceNavigableMap<K,V>
-
floorEntry
public Map.Entry<K,V> floorEntry(K key)
- Specified by:
floorEntry
in interfaceNavigableMap<K,V>
-
ceilingEntry
public Map.Entry<K,V> ceilingEntry(K key)
- Specified by:
ceilingEntry
in interfaceNavigableMap<K,V>
-
ceilingKey
public K ceilingKey(K key)
- Specified by:
ceilingKey
in interfaceNavigableMap<K,V>
-
higherEntry
public Map.Entry<K,V> higherEntry(K key)
- Specified by:
higherEntry
in interfaceNavigableMap<K,V>
-
firstEntry
public Map.Entry<K,V> firstEntry()
- Specified by:
firstEntry
in interfaceNavigableMap<K,V>
-
lastEntry
public Map.Entry<K,V> lastEntry()
- Specified by:
lastEntry
in interfaceNavigableMap<K,V>
-
pollFirstEntry
public Map.Entry<K,V> pollFirstEntry()
- Specified by:
pollFirstEntry
in interfaceNavigableMap<K,V>
-
pollLastEntry
public Map.Entry<K,V> pollLastEntry()
- Specified by:
pollLastEntry
in interfaceNavigableMap<K,V>
-
descendingMap
public NavigableMap<K,V> descendingMap()
- Specified by:
descendingMap
in interfaceNavigableMap<K,V>
-
navigableKeySet
public NavigableSet<K> navigableKeySet()
- Specified by:
navigableKeySet
in interfaceNavigableMap<K,V>
-
descendingKeySet
public NavigableSet<K> descendingKeySet()
- Specified by:
descendingKeySet
in interfaceNavigableMap<K,V>
-
subMap
public NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
- Specified by:
subMap
in interfaceNavigableMap<K,V>
-
headMap
public NavigableMap<K,V> headMap(K toKey, boolean inclusive)
- Specified by:
headMap
in interfaceNavigableMap<K,V>
-
tailMap
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive)
- Specified by:
tailMap
in interfaceNavigableMap<K,V>
-
-