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
ConstructorsModifierConstructorDescriptionprotected
Constructor only used in deserialization, do not use otherwise.protected
Constructor that wraps (not copies). -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection coll) void
clear()
boolean
boolean
containsAll
(Collection coll) boolean
protected Collection
Gets the collection being decorated.int
hashCode()
boolean
isEmpty()
iterator()
boolean
boolean
removeAll
(Collection coll) boolean
retainAll
(Collection coll) int
size()
Object[]
toArray()
Object[]
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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:
add
in interfaceCollection
-
addAll
- Specified by:
addAll
in interfaceCollection
-
clear
public void clear()- Specified by:
clear
in interfaceCollection
-
contains
- Specified by:
contains
in interfaceCollection
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection
-
iterator
- Specified by:
iterator
in interfaceCollection
- Specified by:
iterator
in interfaceIterable
-
remove
- Specified by:
remove
in interfaceCollection
-
size
public int size()- Specified by:
size
in interfaceCollection
-
toArray
- Specified by:
toArray
in interfaceCollection
-
toArray
- Specified by:
toArray
in interfaceCollection
-
containsAll
- Specified by:
containsAll
in interfaceCollection
-
removeAll
- Specified by:
removeAll
in interfaceCollection
-
retainAll
- Specified by:
retainAll
in interfaceCollection
-
equals
- Specified by:
equals
in interfaceCollection
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection
- Overrides:
hashCode
in classObject
-
toString
-