Class ForwardingNavigableSet<E extends @Nullable java.lang.Object>
- java.lang.Object
-
- com.google.common.collect.ForwardingObject
-
- com.google.common.collect.ForwardingCollection<E>
-
- com.google.common.collect.ForwardingSet<E>
-
- com.google.common.collect.ForwardingSortedSet<E>
-
- com.google.common.collect.ForwardingNavigableSet<E>
-
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.NavigableSet<E>,java.util.Set<E>,java.util.SortedSet<E>
- Direct Known Subclasses:
ForwardingNavigableSet.StandardDescendingSet
@GwtIncompatible public abstract class ForwardingNavigableSet<E extends @Nullable java.lang.Object> extends ForwardingSortedSet<E> implements java.util.NavigableSet<E>
A navigable set which forwards all its method calls to another navigable set. Subclasses should override one or more methods to modify the behavior of the backing set as desired per the decorator pattern.Warning: The methods of
ForwardingNavigableSetforward indiscriminately to the methods of the delegate. For example, overridingForwardingCollection.add(E)alone will not change the behavior ofForwardingCollection.addAll(java.util.Collection<? extends E>), which can lead to unexpected behavior. In this case, you should overrideaddAllas well, either providing your own implementation, or delegating to the providedstandardAddAllmethod.defaultmethod warning: This class does not forward calls todefaultmethods. Instead, it inherits their default implementations. When those implementations invoke methods, they invoke methods on theForwardingNavigableSet.Each of the
standardmethods uses the set'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 theSetcontract.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 classForwardingNavigableSet.StandardDescendingSetA sensible implementation ofNavigableSet.descendingSet()in terms of the other methods ofNavigableSet, notably includingNavigableSet.descendingIterator().
-
Constructor Summary
Constructors Modifier Constructor Description protectedForwardingNavigableSet()Constructor for use by subclasses.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Eceiling(E e)protected abstract java.util.NavigableSet<E>delegate()Returns the backing delegate instance that methods are forwarded to.java.util.Iterator<E>descendingIterator()java.util.NavigableSet<E>descendingSet()Efloor(E e)java.util.NavigableSet<E>headSet(E toElement, boolean inclusive)Ehigher(E e)Elower(E e)EpollFirst()EpollLast()protected EstandardCeiling(E e)protected EstandardFirst()protected EstandardFloor(E e)A sensible definition offloor(E)in terms of thedescendingIteratormethod ofheadSet(Object, boolean).protected java.util.SortedSet<E>standardHeadSet(E toElement)A sensible definition ofForwardingSortedSet.headSet(Object)in terms of theheadSet(Object, boolean)method.protected EstandardHigher(E e)protected EstandardLast()protected EstandardLower(E e)A sensible definition oflower(E)in terms of thedescendingIteratormethod ofheadSet(Object, boolean).protected EstandardPollFirst()A sensible definition ofpollFirst()in terms of theiteratormethod.protected EstandardPollLast()A sensible definition ofpollLast()in terms of thedescendingIteratormethod.protected java.util.NavigableSet<E>standardSubSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)A sensible definition ofsubSet(Object, boolean, Object, boolean)in terms of theheadSetandtailSetmethods.protected java.util.SortedSet<E>standardSubSet(E fromElement, E toElement)A sensible definition ofForwardingSortedSet.subSet(Object, Object)in terms of thesubSet(Object, boolean, Object, boolean)method.protected java.util.SortedSet<E>standardTailSet(E fromElement)A sensible definition ofForwardingSortedSet.tailSet(Object)in terms of thetailSet(Object, boolean)method.java.util.NavigableSet<E>subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)java.util.NavigableSet<E>tailSet(E fromElement, boolean inclusive)-
Methods inherited from class com.google.common.collect.ForwardingSortedSet
comparator, first, headSet, last, standardContains, standardRemove, subSet, tailSet
-
Methods inherited from class com.google.common.collect.ForwardingSet
equals, hashCode, standardEquals, standardHashCode, standardRemoveAll
-
Methods inherited from class com.google.common.collect.ForwardingCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContainsAll, standardIsEmpty, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray
-
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
-
-
-
-
Constructor Detail
-
ForwardingNavigableSet
protected ForwardingNavigableSet()
Constructor for use by subclasses.
-
-
Method Detail
-
delegate
protected abstract java.util.NavigableSet<E> 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.- Specified by:
delegatein classForwardingSortedSet<E extends @Nullable java.lang.Object>
-
lower
@CheckForNull public E lower(E e)
-
standardLower
@CheckForNull protected E standardLower(E e)
A sensible definition oflower(E)in terms of thedescendingIteratormethod ofheadSet(Object, boolean). If you overrideheadSet(Object, boolean), you may wish to overridelower(E)to forward to this implementation.
-
floor
@CheckForNull public E floor(E e)
-
standardFloor
@CheckForNull protected E standardFloor(E e)
A sensible definition offloor(E)in terms of thedescendingIteratormethod ofheadSet(Object, boolean). If you overrideheadSet(Object, boolean), you may wish to overridefloor(E)to forward to this implementation.
-
ceiling
@CheckForNull public E ceiling(E e)
-
standardCeiling
@CheckForNull protected E standardCeiling(E e)
A sensible definition ofceiling(E)in terms of theiteratormethod oftailSet(Object, boolean). If you overridetailSet(Object, boolean), you may wish to overrideceiling(E)to forward to this implementation.
-
higher
@CheckForNull public E higher(E e)
-
standardHigher
@CheckForNull protected E standardHigher(E e)
A sensible definition ofhigher(E)in terms of theiteratormethod oftailSet(Object, boolean). If you overridetailSet(Object, boolean), you may wish to overridehigher(E)to forward to this implementation.
-
pollFirst
@CheckForNull public E pollFirst()
-
standardPollFirst
@CheckForNull protected E standardPollFirst()
A sensible definition ofpollFirst()in terms of theiteratormethod. If you overrideForwardingCollection.iterator()you may wish to overridepollFirst()to forward to this implementation.
-
pollLast
@CheckForNull public E pollLast()
-
standardPollLast
@CheckForNull protected E standardPollLast()
A sensible definition ofpollLast()in terms of thedescendingIteratormethod. If you overridedescendingIterator()you may wish to overridepollLast()to forward to this implementation.
-
standardFirst
protected E standardFirst()
-
standardLast
protected E standardLast()
-
descendingSet
public java.util.NavigableSet<E> descendingSet()
-
descendingIterator
public java.util.Iterator<E> descendingIterator()
-
subSet
public java.util.NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
-
standardSubSet
protected java.util.NavigableSet<E> standardSubSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
A sensible definition ofsubSet(Object, boolean, Object, boolean)in terms of theheadSetandtailSetmethods. In many cases, you may wish to overridesubSet(Object, boolean, Object, boolean)to forward to this implementation.
-
standardSubSet
protected java.util.SortedSet<E> standardSubSet(E fromElement, E toElement)
A sensible definition ofForwardingSortedSet.subSet(Object, Object)in terms of thesubSet(Object, boolean, Object, boolean)method. If you overridesubSet(Object, boolean, Object, boolean), you may wish to overrideForwardingSortedSet.subSet(Object, Object)to forward to this implementation.- Overrides:
standardSubSetin classForwardingSortedSet<E extends @Nullable java.lang.Object>
-
standardHeadSet
protected java.util.SortedSet<E> standardHeadSet(E toElement)
A sensible definition ofForwardingSortedSet.headSet(Object)in terms of theheadSet(Object, boolean)method. If you overrideheadSet(Object, boolean), you may wish to overrideForwardingSortedSet.headSet(Object)to forward to this implementation.
-
standardTailSet
protected java.util.SortedSet<E> standardTailSet(E fromElement)
A sensible definition ofForwardingSortedSet.tailSet(Object)in terms of thetailSet(Object, boolean)method. If you overridetailSet(Object, boolean), you may wish to overrideForwardingSortedSet.tailSet(Object)to forward to this implementation.
-
-