- All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>
- Direct Known Subclasses:
ForwardingSortedSet, TypeToken.TypeSet
Warning: The methods of ForwardingSet forward indiscriminately to the
methods of the delegate. For example, overriding ForwardingCollection.add(E) alone will not change the
behavior of ForwardingCollection.addAll(Collection), which can lead to unexpected behavior. In this case, you should
override addAll as well, either providing your own implementation, or delegating to the
provided standardAddAll 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 ForwardingSet.
The standard methods are not guaranteed to be thread-safe, even when all of the
methods that they depend on are thread-safe.
- Since:
- 2.0
- Author:
- Kevin Bourrillion, Louis Wasserman
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondelegate()Returns the backing delegate instance that methods are forwarded to.booleaninthashCode()protected booleanstandardEquals(@Nullable Object object) A sensible definition ofequals(Object)in terms ofForwardingCollection.size()andForwardingCollection.containsAll(Collection).protected intA sensible definition ofhashCode()in terms ofForwardingCollection.iterator().protected booleanstandardRemoveAll(Collection<?> collection) A sensible definition ofForwardingCollection.removeAll(Collection)in terms ofForwardingCollection.iterator()andForwardingCollection.remove(Object).Methods inherited from class ForwardingCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArrayModifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends E> collection) voidclear()booleanbooleancontainsAll(Collection<?> collection) booleanisEmpty()iterator()booleanbooleanremoveAll(Collection<?> collection) booleanretainAll(Collection<?> collection) intsize()protected booleanstandardAddAll(Collection<? extends E> collection) A sensible definition ofForwardingCollection.addAll(Collection)in terms ofForwardingCollection.add(E).protected voidA sensible definition ofForwardingCollection.clear()in terms ofForwardingCollection.iterator(), using the iterator'sremovemethod.protected booleanstandardContains(@Nullable Object object) A sensible definition ofForwardingCollection.contains(Object)in terms ofForwardingCollection.iterator().protected booleanstandardContainsAll(Collection<?> collection) A sensible definition ofForwardingCollection.containsAll(Collection)in terms ofForwardingCollection.contains(Object).protected booleanA sensible definition ofForwardingCollection.isEmpty()as!iterator().hasNext.protected booleanstandardRemove(@Nullable Object object) A sensible definition ofForwardingCollection.remove(Object)in terms ofForwardingCollection.iterator(), using the iterator'sremovemethod.protected booleanstandardRetainAll(Collection<?> collection) A sensible definition ofForwardingCollection.retainAll(Collection)in terms ofForwardingCollection.iterator(), using the iterator'sremovemethod.A sensible definition ofForwardingCollection.toArray()in terms ofForwardingCollection.toArray(Object[]).standardToArray(T[] array) A sensible definition ofForwardingCollection.toArray(Object[])in terms ofForwardingCollection.size()andForwardingCollection.iterator().protected StringA sensible definition ofForwardingObject.toString()in terms ofForwardingCollection.iterator().toArray()toArray(T[] array) Methods inherited from class ForwardingObject
toStringMethods inherited from interface Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
ForwardingSet
protected ForwardingSet()Constructor for use by subclasses.
-
-
Method Details
-
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 asdelegate(). Concrete subclasses override this method to supply the instance being decorated.- Specified by:
delegatein classForwardingCollection<E extends @Nullable Object>
-
equals
-
hashCode
-
standardRemoveAll
A sensible definition ofForwardingCollection.removeAll(Collection)in terms ofForwardingCollection.iterator()andForwardingCollection.remove(Object). If you overrideiteratororremove, you may wish to overrideForwardingCollection.removeAll(Collection)to forward to this implementation.- Overrides:
standardRemoveAllin classForwardingCollection<E extends @Nullable Object>- Since:
- 7.0 (this version overrides the
ForwardingCollectionversion as of 12.0)
-
standardEquals
A sensible definition ofequals(Object)in terms ofForwardingCollection.size()andForwardingCollection.containsAll(Collection). If you override either of those methods, you may wish to overrideequals(Object)to forward to this implementation.- Since:
- 7.0
-
standardHashCode
protected int standardHashCode()A sensible definition ofhashCode()in terms ofForwardingCollection.iterator(). If you overrideForwardingCollection.iterator(), you may wish to overrideequals(Object)to forward to this implementation.- Since:
- 7.0
-