Class CompositeCollection
java.lang.Object
org.apache.commons.collections.collection.CompositeCollection
- All Implemented Interfaces:
Iterable,Collection
- Direct Known Subclasses:
CompositeSet
@Deprecated(since="2021-04-30")
public class CompositeCollection
extends Object
implements Collection
Deprecated.
Apache Commons Collections version 3.x is being deprecated from AEMaaCS. The upgraded version 4.4 of Commons Collections is already included as replacement. Customers are advised to upgrade to this version of the library. Please note: the package name was changed to org.apache.commons.collections4. Further note that there are AEM APIs currently exposing the old collections classes; these will be updated in upcoming releases.
Decorates a collection of other collections to provide a single unified view.
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.
- Since:
- Commons Collections 3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDeprecated.Apache Commons Collections version 3.x is being deprecated from AEMaaCS. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Create an empty CompositeCollection.Deprecated.Create a Composite Collection with only coll composited.CompositeCollection(Collection[] colls) Deprecated.Create a CompositeCollection with colls as the initial list of composited collections. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.Adds an object to the collection, throwing UnsupportedOperationException unless a CollectionMutator strategy is specified.booleanaddAll(Collection coll) Deprecated.Adds a collection of elements to this collection, throwing UnsupportedOperationException unless a CollectionMutator strategy is specified.voidDeprecated.Add an additional collection to this composite.voidaddComposited(Collection[] comps) Deprecated.Add these Collections to the list of collections in this compositevoidDeprecated.Add two additional collections to this composite.voidclear()Deprecated.Removes all of the elements from this collection .booleanDeprecated.Checks whether this composite collection contains the object.booleancontainsAll(Collection coll) Deprecated.Checks whether this composite contains all the elements in the specified collection.Deprecated.Gets the collections being decorated.booleanisEmpty()Deprecated.Checks whether this composite collection is empty.iterator()Deprecated.Gets an iterator over all the collections in this composite.booleanDeprecated.Removes an object from the collection, throwing UnsupportedOperationException unless a CollectionMutator strategy is specified.booleanremoveAll(Collection coll) Deprecated.Removes the elements in the specified collection from this composite collection.voidremoveComposited(Collection coll) Deprecated.Removes a collection from the those being decorated in this composite.booleanretainAll(Collection coll) Deprecated.Retains all the elements in the specified collection in this composite collection, removing all others.voidDeprecated.Specify a CollectionMutator strategy instance to handle changes.intsize()Deprecated.Gets the size of this composite collection.Object[]toArray()Deprecated.Returns an array containing all of the elements in this composite.Object[]Deprecated.Returns an object array, populating the supplied array if possible.Deprecated.Returns a new collection containing all of the elementsMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
CompositeCollection
public CompositeCollection()Deprecated.Create an empty CompositeCollection. -
CompositeCollection
Deprecated.Create a Composite Collection with only coll composited.- Parameters:
coll- a collection to decorate
-
CompositeCollection
Deprecated.Create a CompositeCollection with colls as the initial list of composited collections.- Parameters:
colls- an array of collections to decorate
-
-
Method Details
-
size
public int size()Deprecated.Gets the size of this composite collection.This implementation calls
size()on each collection.- Specified by:
sizein interfaceCollection- Returns:
- total number of elements in all contained containers
-
isEmpty
public boolean isEmpty()Deprecated.Checks whether this composite collection is empty.This implementation calls
isEmpty()on each collection.- Specified by:
isEmptyin interfaceCollection- Returns:
- true if all of the contained collections are empty
-
contains
Deprecated.Checks whether this composite collection contains the object.This implementation calls
contains()on each collection.- Specified by:
containsin interfaceCollection- Parameters:
obj- the object to search for- Returns:
- true if obj is contained in any of the contained collections
-
iterator
Deprecated.Gets an iterator over all the collections in this composite.This implementation uses an
IteratorChain.- Specified by:
iteratorin interfaceCollection- Specified by:
iteratorin interfaceIterable- Returns:
- an
IteratorChaininstance which supportsremove(). Iteration occurs over contained collections in the order they were added, but this behavior should not be relied upon. - See Also:
-
toArray
Deprecated.Returns an array containing all of the elements in this composite.- Specified by:
toArrayin interfaceCollection- Returns:
- an object array of all the elements in the collection
-
toArray
Deprecated.Returns an object array, populating the supplied array if possible. SeeCollectioninterface for full details.- Specified by:
toArrayin interfaceCollection- Parameters:
array- the array to use, populating if possible- Returns:
- an array of all the elements in the collection
-
add
Deprecated.Adds an object to the collection, throwing UnsupportedOperationException unless a CollectionMutator strategy is specified.- Specified by:
addin interfaceCollection- Parameters:
obj- the object to add- Returns:
- true if the collection was modified
- Throws:
UnsupportedOperationException- 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 added
-
remove
Deprecated.Removes an object from the collection, throwing UnsupportedOperationException unless a CollectionMutator strategy is specified.- Specified by:
removein interfaceCollection- Parameters:
obj- the object being removed- Returns:
- true if the collection is changed
- Throws:
UnsupportedOperationException- 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 removed
-
containsAll
Deprecated.Checks whether this composite contains all the elements in the specified collection.This implementation calls
contains()for each element in the specified collection.- Specified by:
containsAllin interfaceCollection- Parameters:
coll- the collection to check for- Returns:
- true if all elements contained
-
addAll
Deprecated.Adds a collection of elements to this collection, throwing UnsupportedOperationException unless a CollectionMutator strategy is specified.- Specified by:
addAllin interfaceCollection- Parameters:
coll- the collection to add- Returns:
- true if the collection was modified
- Throws:
UnsupportedOperationException- 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 added
-
removeAll
Deprecated.Removes the elements in the specified collection from this composite collection.This implementation calls
removeAllon each collection.- Specified by:
removeAllin interfaceCollection- Parameters:
coll- the collection to remove- Returns:
- true if the collection was modified
- Throws:
UnsupportedOperationException- if removeAll is unsupported
-
retainAll
Deprecated.Retains all the elements in the specified collection in this composite collection, removing all others.This implementation calls
retainAll()on each collection.- Specified by:
retainAllin interfaceCollection- Parameters:
coll- the collection to remove- Returns:
- true if the collection was modified
- Throws:
UnsupportedOperationException- if retainAll is unsupported
-
clear
public void clear()Deprecated.Removes all of the elements from this collection .This implementation calls
clear()on each collection.- Specified by:
clearin interfaceCollection- Throws:
UnsupportedOperationException- if clear is unsupported
-
setMutator
Deprecated.Specify a CollectionMutator strategy instance to handle changes.- Parameters:
mutator- the mutator to use
-
addComposited
Deprecated.Add these Collections to the list of collections in this composite- Parameters:
comps- Collections to be appended to the composite
-
addComposited
Deprecated.Add an additional collection to this composite.- Parameters:
c- the collection to add
-
addComposited
Deprecated.Add two additional collections to this composite.- Parameters:
c- the first collection to addd- the second collection to add
-
removeComposited
Deprecated.Removes a collection from the those being decorated in this composite.- Parameters:
coll- collection to be removed
-
toCollection
Deprecated.Returns a new collection containing all of the elements- Returns:
- A new ArrayList containing all of the elements in this composite. The new collection is not backed by this composite.
-
getCollections
Deprecated.Gets the collections being decorated.- Returns:
- Unmodifiable collection of all collections in this composite.
-