Class ForwardingSortedMap<K,V>
- All Implemented Interfaces:
Map<K,
,V> SequencedMap<K,
,V> SortedMap<K,
V>
- Direct Known Subclasses:
ForwardingNavigableMap
,Maps.UnmodifiableNavigableMap
Warning: The methods of ForwardingSortedMap
forward indiscriminately to
the methods of the delegate. For example, overriding ForwardingMap.put(K, V)
alone will not change
the behavior of ForwardingMap.putAll(java.util.Map<? extends K, ? extends V>)
, which can lead to unexpected behavior. In this case, you should
override putAll
as well, either providing your own implementation, or delegating to the
provided standardPutAll
method.
default
method warning: This class does not forward calls to
default
methods. Instead, it inherits their default implementations. When those implementations
invoke methods, they invoke methods on the ForwardingSortedMap
.
Each of the standard
methods, where appropriate, use the comparator of the map to test
equality for both keys and values, unlike ForwardingMap
.
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:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
A sensible implementation ofSortedMap.keySet()
in terms of the methods ofForwardingSortedMap
.Nested classes/interfaces inherited from class com.google.common.collect.ForwardingMap
ForwardingMap.StandardEntrySet, ForwardingMap.StandardValues
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionComparator
<? super K> delegate()
Returns the backing delegate instance that methods are forwarded to.firstKey()
lastKey()
protected boolean
A sensible definition ofForwardingMap.containsKey(java.lang.Object)
in terms of thefirstKey()
method oftailMap(K)
.standardSubMap
(K fromKey, K toKey) A sensible default implementation ofsubMap(Object, Object)
in terms ofheadMap(Object)
andtailMap(Object)
.(package private) static int
unsafeCompare
(Comparator<?> comparator, Object o1, Object o2) 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.SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry, sequencedEntrySet, sequencedKeySet, sequencedValues
-
Constructor Details
-
ForwardingSortedMap
protected ForwardingSortedMap()Constructor for use by subclasses.
-
-
Method Details
-
delegate
Description copied from class:ForwardingObject
Returns 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.- Specified by:
delegate
in classForwardingMap<K,
V>
-
comparator
- Specified by:
comparator
in interfaceSortedMap<K,
V>
-
firstKey
-
headMap
-
lastKey
-
subMap
-
tailMap
-
unsafeCompare
static int unsafeCompare(@CheckForNull Comparator<?> comparator, @CheckForNull Object o1, @CheckForNull Object o2) -
standardContainsKey
A sensible definition ofForwardingMap.containsKey(java.lang.Object)
in terms of thefirstKey()
method oftailMap(K)
. If you overridetailMap(K)
, you may wish to overrideForwardingMap.containsKey(java.lang.Object)
to forward to this implementation.- Overrides:
standardContainsKey
in classForwardingMap<K,
V> - Since:
- 7.0
-
standardSubMap
A sensible default implementation ofsubMap(Object, Object)
in terms ofheadMap(Object)
andtailMap(Object)
. In some situations, you may wish to overridesubMap(Object, Object)
to forward to this implementation.- Since:
- 7.0
-