public class CompositeCollection<E> extends Object implements Collection<E>
Changes made to this collection will actually be made on the decorated collection. Add and remove operations require the use of a pluggable strategy. If no strategy is provided then add and remove are unsupported.
| Modifier and Type | Field and Description |
|---|---|
protected ArrayList<Collection<E>> |
all
Collections in the composite
|
| Constructor and Description |
|---|
CompositeCollection()
Create an empty CompositeCollection.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Object obj)
Adds an object to the collection, throwing UnsupportedOperationException
unless a CollectionMutator strategy is specified.
|
boolean |
addAll(Collection<? extends E> coll)
Adds a collection of elements to this collection, throwing
UnsupportedOperationException unless a CollectionMutator strategy is specified.
|
void |
addComposited(Collection<E> c)
Add an additional collection to this composite.
|
void |
clear()
Removes all of the elements from this collection .
|
boolean |
contains(Object obj)
Checks whether this composite collection contains the object.
|
boolean |
containsAll(Collection<?> coll)
Checks whether this composite contains all the elements in the specified collection.
|
Collection<Collection<E>> |
getCollections()
Gets the collections being decorated.
|
boolean |
isEmpty()
Checks whether this composite collection is empty.
|
Iterator<E> |
iterator()
Gets an iterator over all the collections in this composite.
|
boolean |
remove(Object obj)
Removes an object from the collection, throwing UnsupportedOperationException
unless a CollectionMutator strategy is specified.
|
boolean |
removeAll(Collection<?> coll)
Removes the elements in the specified collection from this composite collection.
|
void |
removeComposited(Collection<E> coll)
Removes a collection from the those being decorated in this composite.
|
boolean |
retainAll(Collection<?> coll)
Retains all the elements in the specified collection in this composite collection,
removing all others.
|
int |
size()
Gets the size of this composite collection.
|
Object[] |
toArray()
Returns an array containing all of the elements in this composite.
|
<T> T[] |
toArray(T[] array)
Returns an object array, populating the supplied array if possible.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequals, hashCode, parallelStream, removeIf, spliterator, streamprotected ArrayList<Collection<E>> all
public CompositeCollection()
public int size()
This implementation calls size() on each collection.
size in interface Collection<E>public boolean isEmpty()
This implementation calls isEmpty() on each collection.
isEmpty in interface Collection<E>public boolean contains(Object obj)
This implementation calls contains() on each collection.
contains in interface Collection<E>obj - the object to search forpublic Iterator<E> iterator()
This implementation uses an IteratorChain.
iterator in interface Iterable<E>iterator in interface Collection<E>IteratorChain instance which supports
remove(). Iteration occurs over contained collections in
the order they were added, but this behavior should not be relied upon.IteratorChainpublic Object[] toArray()
toArray in interface Collection<E>public <T> T[] toArray(T[] array)
Collection interface for full details.toArray in interface Collection<E>array - the array to use, populating if possiblepublic boolean add(Object obj)
add in interface Collection<E>obj - the object to addUnsupportedOperationException - if CollectionMutator hasn't been setUnsupportedOperationException - if add is unsupportedClassCastException - if the object cannot be added due to its typeNullPointerException - if the object cannot be added because its nullIllegalArgumentException - if the object cannot be addedpublic boolean remove(Object obj)
remove in interface Collection<E>obj - the object being removedUnsupportedOperationException - if removed is unsupportedClassCastException - if the object cannot be removed due to its typeNullPointerException - if the object cannot be removed because its nullIllegalArgumentException - if the object cannot be removedpublic boolean containsAll(Collection<?> coll)
This implementation calls contains() for each element in the
specified collection.
containsAll in interface Collection<E>coll - the collection to check forpublic boolean addAll(Collection<? extends E> coll)
addAll in interface Collection<E>coll - the collection to addUnsupportedOperationException - if CollectionMutator hasn't been setUnsupportedOperationException - if add is unsupportedClassCastException - if the object cannot be added due to its typeNullPointerException - if the object cannot be added because its nullIllegalArgumentException - if the object cannot be addedpublic boolean removeAll(Collection<?> coll)
This implementation calls removeAll on each collection.
removeAll in interface Collection<E>coll - the collection to removeUnsupportedOperationException - if removeAll is unsupportedpublic boolean retainAll(Collection<?> coll)
This implementation calls retainAll() on each collection.
retainAll in interface Collection<E>coll - the collection to removeUnsupportedOperationException - if retainAll is unsupportedpublic void clear()
This implementation calls clear() on each collection.
clear in interface Collection<E>UnsupportedOperationException - if clear is unsupportedpublic void addComposited(Collection<E> c)
c - the collection to addpublic void removeComposited(Collection<E> coll)
coll - collection to be removedpublic Collection<Collection<E>> getCollections()
Copyright © 2001–2018 Apache Cayenne. All rights reserved.