Class AbstractCollectionDecorator
java.lang.Object
org.apache.commons.collections.collection.AbstractCollectionDecorator
- All Implemented Interfaces:
Iterable,Collection
- Direct Known Subclasses:
AbstractBagDecorator,AbstractBufferDecorator,AbstractDualBidiMap.View,AbstractListDecorator,AbstractSerializableCollectionDecorator,AbstractSetDecorator
Decorates another
Collection to provide additional behaviour.
Each method call made on this Collection is forwarded to the
decorated Collection. This class is used as a framework on which
to build to extensions such as synchronized and unmodifiable behaviour. The
main advantage of decoration is that one decorator can wrap any implementation
of Collection, whereas sub-classing requires a new class to be
written for each implementation.
This implementation does not perform any special processing with
iterator(). Instead it simply returns the value from the
wrapped collection. This may be undesirable, for example if you are trying
to write an unmodifiable implementation it might provide a loophole.
- Since:
- Commons Collections 3.0
- Version:
- $Revision: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
- Author:
- Stephen Colebourne, Paul Jack
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor only used in deserialization, do not use otherwise.protectedConstructor that wraps (not copies). -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection coll) voidclear()booleanbooleancontainsAll(Collection coll) booleanprotected CollectionGets the collection being decorated.inthashCode()booleanisEmpty()iterator()booleanbooleanremoveAll(Collection coll) booleanretainAll(Collection coll) intsize()Object[]toArray()Object[]toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
collection
The collection being decorated
-
-
Constructor Details
-
AbstractCollectionDecorator
protected AbstractCollectionDecorator()Constructor only used in deserialization, do not use otherwise.- Since:
- Commons Collections 3.1
-
AbstractCollectionDecorator
Constructor that wraps (not copies).- Parameters:
coll- the collection to decorate, must not be null- Throws:
IllegalArgumentException- if the collection is null
-
-
Method Details
-
getCollection
Gets the collection being decorated.- Returns:
- the decorated collection
-
add
- Specified by:
addin interfaceCollection
-
addAll
- Specified by:
addAllin interfaceCollection
-
clear
public void clear()- Specified by:
clearin interfaceCollection
-
contains
- Specified by:
containsin interfaceCollection
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection
-
iterator
- Specified by:
iteratorin interfaceCollection- Specified by:
iteratorin interfaceIterable
-
remove
- Specified by:
removein interfaceCollection
-
size
public int size()- Specified by:
sizein interfaceCollection
-
toArray
- Specified by:
toArrayin interfaceCollection
-
toArray
- Specified by:
toArrayin interfaceCollection
-
containsAll
- Specified by:
containsAllin interfaceCollection
-
removeAll
- Specified by:
removeAllin interfaceCollection
-
retainAll
- Specified by:
retainAllin interfaceCollection
-
equals
- Specified by:
equalsin interfaceCollection- Overrides:
equalsin classObject
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection- Overrides:
hashCodein classObject
-
toString
-