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
public abstract class AbstractCollectionDecorator extends Object implements Collection
Decorates anotherCollection
to provide additional behaviour.Each method call made on this
Collection
is forwarded to the decoratedCollection
. 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 ofCollection
, 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 Modifier and Type Field Description protected Collection
collection
The collection being decorated
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCollectionDecorator()
Constructor only used in deserialization, do not use otherwise.protected
AbstractCollectionDecorator(Collection coll)
Constructor that wraps (not copies).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(Object object)
boolean
addAll(Collection coll)
void
clear()
boolean
contains(Object object)
boolean
containsAll(Collection coll)
boolean
equals(Object object)
protected Collection
getCollection()
Gets the collection being decorated.int
hashCode()
boolean
isEmpty()
Iterator
iterator()
boolean
remove(Object object)
boolean
removeAll(Collection coll)
boolean
retainAll(Collection coll)
int
size()
Object[]
toArray()
Object[]
toArray(Object[] object)
String
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 Detail
-
collection
protected Collection collection
The collection being decorated
-
-
Constructor Detail
-
AbstractCollectionDecorator
protected AbstractCollectionDecorator()
Constructor only used in deserialization, do not use otherwise.- Since:
- Commons Collections 3.1
-
AbstractCollectionDecorator
protected AbstractCollectionDecorator(Collection coll)
Constructor that wraps (not copies).- Parameters:
coll
- the collection to decorate, must not be null- Throws:
IllegalArgumentException
- if the collection is null
-
-
Method Detail
-
getCollection
protected Collection getCollection()
Gets the collection being decorated.- Returns:
- the decorated collection
-
add
public boolean add(Object object)
- Specified by:
add
in interfaceCollection
-
addAll
public boolean addAll(Collection coll)
- Specified by:
addAll
in interfaceCollection
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection
-
contains
public boolean contains(Object object)
- Specified by:
contains
in interfaceCollection
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection
-
iterator
public Iterator iterator()
- Specified by:
iterator
in interfaceCollection
- Specified by:
iterator
in interfaceIterable
-
remove
public boolean remove(Object object)
- Specified by:
remove
in interfaceCollection
-
size
public int size()
- Specified by:
size
in interfaceCollection
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection
-
toArray
public Object[] toArray(Object[] object)
- Specified by:
toArray
in interfaceCollection
-
containsAll
public boolean containsAll(Collection coll)
- Specified by:
containsAll
in interfaceCollection
-
removeAll
public boolean removeAll(Collection coll)
- Specified by:
removeAll
in interfaceCollection
-
retainAll
public boolean retainAll(Collection coll)
- Specified by:
retainAll
in interfaceCollection
-
equals
public boolean equals(Object object)
- Specified by:
equals
in interfaceCollection
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection
- Overrides:
hashCode
in classObject
-
-