- All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>
This class does not implement RandomAccess. If the delegate supports random
access, the ForwardingList subclass should implement the RandomAccess interface.
Warning: The methods of ForwardingList forward indiscriminately to the
methods of the delegate. For example, overriding add(int, E) alone will not change the
behavior of addAll(int, 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 ForwardingList.
The standard methods and any 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
- Author:
- Mike Bostock, Louis Wasserman
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanaddAll(int index, Collection<? extends E> elements) delegate()Returns the backing delegate instance that methods are forwarded to.booleanget(int index) inthashCode()intintlastIndexOf(@Nullable Object element) listIterator(int index) remove(int index) protected booleanstandardAdd(E element) A sensible default implementation ofForwardingCollection.add(Object), in terms ofadd(int, Object).protected booleanstandardAddAll(int index, Iterable<? extends E> elements) A sensible default implementation ofaddAll(int, Collection), in terms of theaddmethod oflistIterator(int).protected booleanstandardEquals(@Nullable Object object) A sensible definition ofequals(Object)in terms ofForwardingCollection.size()andForwardingCollection.iterator().protected intA sensible definition ofhashCode()in terms ofForwardingCollection.iterator().protected intstandardIndexOf(@Nullable Object element) A sensible default implementation ofindexOf(Object), in terms oflistIterator().A sensible default implementation ofForwardingCollection.iterator(), in terms oflistIterator().protected intstandardLastIndexOf(@Nullable Object element) A sensible default implementation oflastIndexOf(Object), in terms oflistIterator(int).protected ListIterator<E> A sensible default implementation oflistIterator(), in terms oflistIterator(int).protected ListIterator<E> standardListIterator(int start) A sensible default implementation oflistIterator(int), in terms ofForwardingCollection.size(),get(int),set(int, Object),add(int, Object), andremove(int).standardSubList(int fromIndex, int toIndex) A sensible default implementation ofsubList(int, int).subList(int fromIndex, int toIndex) Methods inherited from class ForwardingCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRemoveAll, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArrayMethods inherited from class ForwardingObject
toStringMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface List
add, addAll, addFirst, addLast, clear, contains, containsAll, getFirst, getLast, isEmpty, iterator, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, size, sort, spliterator, toArray, toArray
-
Constructor Details
-
ForwardingList
protected ForwardingList()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 asForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.- Specified by:
delegatein classForwardingCollection<E extends @Nullable Object>
-
add
-
addAll
-
get
-
indexOf
-
lastIndexOf
-
listIterator
- Specified by:
listIteratorin interfaceList<E extends @Nullable Object>
-
listIterator
- Specified by:
listIteratorin interfaceList<E extends @Nullable Object>
-
remove
-
set
-
subList
-
equals
-
hashCode
-
standardAdd
A sensible default implementation ofForwardingCollection.add(Object), in terms ofadd(int, Object). If you overrideadd(int, Object), you may wish to overrideForwardingCollection.add(Object)to forward to this implementation.- Since:
- 7.0
-
standardAddAll
A sensible default implementation ofaddAll(int, Collection), in terms of theaddmethod oflistIterator(int). If you overridelistIterator(int), you may wish to overrideaddAll(int, Collection)to forward to this implementation.- Since:
- 7.0
-
standardIndexOf
A sensible default implementation ofindexOf(Object), in terms oflistIterator(). If you overridelistIterator(), you may wish to overrideindexOf(Object)to forward to this implementation.- Since:
- 7.0
-
standardLastIndexOf
A sensible default implementation oflastIndexOf(Object), in terms oflistIterator(int). If you overridelistIterator(int), you may wish to overridelastIndexOf(Object)to forward to this implementation.- Since:
- 7.0
-
standardIterator
A sensible default implementation ofForwardingCollection.iterator(), in terms oflistIterator(). If you overridelistIterator(), you may wish to overrideForwardingCollection.iterator()to forward to this implementation.- Since:
- 7.0
-
standardListIterator
A sensible default implementation oflistIterator(), in terms oflistIterator(int). If you overridelistIterator(int), you may wish to overridelistIterator()to forward to this implementation.- Since:
- 7.0
-
standardListIterator
A sensible default implementation oflistIterator(int), in terms ofForwardingCollection.size(),get(int),set(int, Object),add(int, Object), andremove(int). If you override any of these methods, you may wish to overridelistIterator(int)to forward to this implementation.- Since:
- 7.0
-
standardSubList
A sensible default implementation ofsubList(int, int). If you override any other methods, you may wish to overridesubList(int, int)to forward to this implementation.- Since:
- 7.0
-
standardEquals
A sensible definition ofequals(Object)in terms ofForwardingCollection.size()andForwardingCollection.iterator(). 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 overridehashCode()to forward to this implementation.- Since:
- 7.0
-