Class ForwardingNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
- 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>
@GwtIncompatible public abstract class ForwardingNavigableMap<K extends @Nullable Object,V extends @Nullable Object> 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
ForwardingNavigableMapforward 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 overrideputAllas well, either providing your own implementation, or delegating to the providedstandardPutAllmethod.defaultmethod warning: This class does not forward calls todefaultmethods. Instead, it inherits their default implementations. When those implementations invoke methods, they invoke methods on theForwardingNavigableMap.Each of the
standardmethods 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 theMapcontract.The
standardmethods 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
- Author:
- Louis Wasserman
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classForwardingNavigableMap.StandardDescendingMapA sensible implementation ofNavigableMap.descendingMap()in terms of the methods of thisNavigableMap.protected classForwardingNavigableMap.StandardNavigableKeySetA sensible implementation ofNavigableMap.navigableKeySet()in terms of the methods of thisNavigableMap.-
Nested classes/interfaces inherited from class com.google.common.collect.ForwardingSortedMap
ForwardingSortedMap.StandardKeySet
-
Nested classes/interfaces inherited from class com.google.common.collect.ForwardingMap
ForwardingMap.StandardEntrySet, ForwardingMap.StandardValues
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedForwardingNavigableMap()Constructor for use by subclasses.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Map.Entry<K,V>ceilingEntry(K key)KceilingKey(K key)protected abstract NavigableMap<K,V>delegate()Returns the backing delegate instance that methods are forwarded to.NavigableSet<K>descendingKeySet()NavigableMap<K,V>descendingMap()Map.Entry<K,V>firstEntry()Map.Entry<K,V>floorEntry(K key)KfloorKey(K key)NavigableMap<K,V>headMap(K toKey, boolean inclusive)Map.Entry<K,V>higherEntry(K key)KhigherKey(K key)Map.Entry<K,V>lastEntry()Map.Entry<K,V>lowerEntry(K key)KlowerKey(K key)NavigableSet<K>navigableKeySet()Map.Entry<K,V>pollFirstEntry()Map.Entry<K,V>pollLastEntry()protected Map.Entry<K,V>standardCeilingEntry(K key)protected KstandardCeilingKey(K key)A sensible definition ofceilingKey(K)in terms ofceilingEntry.protected NavigableSet<K>standardDescendingKeySet()protected Map.Entry<K,V>standardFirstEntry()protected KstandardFirstKey()A sensible definition ofForwardingSortedMap.firstKey()in terms offirstEntry.protected Map.Entry<K,V>standardFloorEntry(K key)protected KstandardFloorKey(K key)A sensible definition offloorKey(K)in terms offloorEntry.protected SortedMap<K,V>standardHeadMap(K toKey)A sensible definition ofForwardingSortedMap.headMap(Object)in terms ofheadMap(Object, boolean).protected Map.Entry<K,V>standardHigherEntry(K key)protected KstandardHigherKey(K key)A sensible definition ofhigherKey(K)in terms ofhigherEntry.protected Map.Entry<K,V>standardLastEntry()A sensible definition oflastEntry()in terms of theiterator()of theForwardingMap.entrySet()ofdescendingMap().protected KstandardLastKey()A sensible definition ofForwardingSortedMap.lastKey()in terms oflastEntry.protected Map.Entry<K,V>standardLowerEntry(K key)protected KstandardLowerKey(K key)A sensible definition oflowerKey(K)in terms oflowerEntry.protected Map.Entry<K,V>standardPollFirstEntry()protected Map.Entry<K,V>standardPollLastEntry()A sensible definition ofpollFirstEntry()in terms of theiteratorof theentrySetofdescendingMap.protected SortedMap<K,V>standardSubMap(K fromKey, K toKey)A sensible definition ofForwardingSortedMap.subMap(Object, Object)in terms ofsubMap(Object, boolean, Object, boolean).protected SortedMap<K,V>standardTailMap(K fromKey)A sensible definition ofForwardingSortedMap.tailMap(Object)in terms oftailMap(Object, boolean).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, standardContainsKey, subMap, tailMap
-
Methods inherited from class com.google.common.collect.ForwardingMap
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, standardClear, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToString, values
-
Methods inherited from class com.google.common.collect.ForwardingObject
toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
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
-
-
-
-
Constructor Detail
-
ForwardingNavigableMap
protected ForwardingNavigableMap()
Constructor for use by subclasses.
-
-
Method Detail
-
delegate
protected abstract NavigableMap<K,V> delegate()
Description copied from class:ForwardingObjectReturns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override this method with an abstract method that has a more specific return type, such asForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.
-
lowerEntry
@CheckForNull public Map.Entry<K,V> lowerEntry(K key)
- Specified by:
lowerEntryin interfaceNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
-
standardLowerEntry
@CheckForNull protected Map.Entry<K,V> standardLowerEntry(K key)
A sensible definition oflowerEntry(K)in terms of thelastEntry()ofheadMap(Object, boolean). If you overrideheadMap, you may wish to overridelowerEntryto forward to this implementation.
-
lowerKey
@CheckForNull public K lowerKey(K key)
-
standardLowerKey
@CheckForNull protected K standardLowerKey(K key)
A sensible definition oflowerKey(K)in terms oflowerEntry. If you overridelowerEntry(K), you may wish to overridelowerKeyto forward to this implementation.
-
floorEntry
@CheckForNull public Map.Entry<K,V> floorEntry(K key)
- Specified by:
floorEntryin interfaceNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
-
standardFloorEntry
@CheckForNull protected Map.Entry<K,V> standardFloorEntry(K key)
A sensible definition offloorEntry(K)in terms of thelastEntry()ofheadMap(Object, boolean). If you overrideheadMap, you may wish to overridefloorEntryto forward to this implementation.
-
floorKey
@CheckForNull public K floorKey(K key)
-
standardFloorKey
@CheckForNull protected K standardFloorKey(K key)
A sensible definition offloorKey(K)in terms offloorEntry. If you overridefloorEntry, you may wish to overridefloorKeyto forward to this implementation.
-
ceilingEntry
@CheckForNull public Map.Entry<K,V> ceilingEntry(K key)
- Specified by:
ceilingEntryin interfaceNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
-
standardCeilingEntry
@CheckForNull protected Map.Entry<K,V> standardCeilingEntry(K key)
A sensible definition ofceilingEntry(K)in terms of thefirstEntry()oftailMap(Object, boolean). If you overridetailMap, you may wish to overrideceilingEntryto forward to this implementation.
-
ceilingKey
@CheckForNull public K ceilingKey(K key)
- Specified by:
ceilingKeyin interfaceNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
-
standardCeilingKey
@CheckForNull protected K standardCeilingKey(K key)
A sensible definition ofceilingKey(K)in terms ofceilingEntry. If you overrideceilingEntry, you may wish to overrideceilingKeyto forward to this implementation.
-
higherEntry
@CheckForNull public Map.Entry<K,V> higherEntry(K key)
- Specified by:
higherEntryin interfaceNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
-
standardHigherEntry
@CheckForNull protected Map.Entry<K,V> standardHigherEntry(K key)
A sensible definition ofhigherEntry(K)in terms of thefirstEntry()oftailMap(Object, boolean). If you overridetailMap, you may wish to overridehigherEntryto forward to this implementation.
-
higherKey
@CheckForNull public K higherKey(K key)
-
standardHigherKey
@CheckForNull protected K standardHigherKey(K key)
A sensible definition ofhigherKey(K)in terms ofhigherEntry. If you overridehigherEntry, you may wish to overridehigherKeyto forward to this implementation.
-
firstEntry
@CheckForNull public Map.Entry<K,V> firstEntry()
- Specified by:
firstEntryin interfaceNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
-
standardFirstEntry
@CheckForNull protected Map.Entry<K,V> standardFirstEntry()
A sensible definition offirstEntry()in terms of theiterator()ofForwardingMap.entrySet(). If you overrideentrySet, you may wish to overridefirstEntryto forward to this implementation.
-
standardFirstKey
protected K standardFirstKey()
A sensible definition ofForwardingSortedMap.firstKey()in terms offirstEntry. If you overridefirstEntry, you may wish to overridefirstKeyto forward to this implementation.
-
lastEntry
@CheckForNull public Map.Entry<K,V> lastEntry()
-
standardLastEntry
@CheckForNull protected Map.Entry<K,V> standardLastEntry()
A sensible definition oflastEntry()in terms of theiterator()of theForwardingMap.entrySet()ofdescendingMap(). If you overridedescendingMap, you may wish to overridelastEntryto forward to this implementation.
-
standardLastKey
protected K standardLastKey()
A sensible definition ofForwardingSortedMap.lastKey()in terms oflastEntry. If you overridelastEntry, you may wish to overridelastKeyto forward to this implementation.
-
pollFirstEntry
@CheckForNull public Map.Entry<K,V> pollFirstEntry()
- Specified by:
pollFirstEntryin interfaceNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
-
standardPollFirstEntry
@CheckForNull protected Map.Entry<K,V> standardPollFirstEntry()
A sensible definition ofpollFirstEntry()in terms of theiteratorofentrySet. If you overrideentrySet, you may wish to overridepollFirstEntryto forward to this implementation.
-
pollLastEntry
@CheckForNull public Map.Entry<K,V> pollLastEntry()
- Specified by:
pollLastEntryin interfaceNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
-
standardPollLastEntry
@CheckForNull protected Map.Entry<K,V> standardPollLastEntry()
A sensible definition ofpollFirstEntry()in terms of theiteratorof theentrySetofdescendingMap. If you overridedescendingMap, you may wish to overridepollFirstEntryto forward to this implementation.
-
descendingMap
public NavigableMap<K,V> descendingMap()
- Specified by:
descendingMapin interfaceNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
-
navigableKeySet
public NavigableSet<K> navigableKeySet()
- Specified by:
navigableKeySetin interfaceNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
-
descendingKeySet
public NavigableSet<K> descendingKeySet()
- Specified by:
descendingKeySetin interfaceNavigableMap<K extends @Nullable Object,V extends @Nullable Object>
-
standardDescendingKeySet
protected NavigableSet<K> standardDescendingKeySet()
A sensible definition ofdescendingKeySet()as thenavigableKeySetofdescendingMap(). (TheForwardingNavigableMap.StandardDescendingMapimplementation implementsnavigableKeySeton its own, so as not to cause an infinite loop.) If you overridedescendingMap, you may wish to overridedescendingKeySetto forward to this implementation.
-
standardSubMap
protected SortedMap<K,V> standardSubMap(K fromKey, K toKey)
A sensible definition ofForwardingSortedMap.subMap(Object, Object)in terms ofsubMap(Object, boolean, Object, boolean). If you overridesubMap(K, boolean, K, boolean), you may wish to overridesubMapto forward to this implementation.- Overrides:
standardSubMapin classForwardingSortedMap<K extends @Nullable Object,V extends @Nullable Object>
-
subMap
public NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
-
headMap
public NavigableMap<K,V> headMap(K toKey, boolean inclusive)
-
tailMap
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive)
-
standardHeadMap
protected SortedMap<K,V> standardHeadMap(K toKey)
A sensible definition ofForwardingSortedMap.headMap(Object)in terms ofheadMap(Object, boolean). If you overrideheadMap(K, boolean), you may wish to overrideheadMapto forward to this implementation.
-
standardTailMap
protected SortedMap<K,V> standardTailMap(K fromKey)
A sensible definition ofForwardingSortedMap.tailMap(Object)in terms oftailMap(Object, boolean). If you overridetailMap(K, boolean), you may wish to overridetailMapto forward to this implementation.
-
-