Class CompositeSet
- java.lang.Object
-
- org.apache.commons.collections.collection.CompositeCollection
-
- org.apache.commons.collections.set.CompositeSet
-
- All Implemented Interfaces:
java.lang.Iterable,java.util.Collection,java.util.Set
public class CompositeSet extends CompositeCollection implements java.util.Set
Decorates a set of other sets to provide a single unified view.Changes made to this set will actually be made on the decorated set. Add operations require the use of a pluggable strategy. If no strategy is provided then add is unsupported.
- Since:
- Commons Collections 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCompositeSet.SetMutatorDefine callbacks for mutation operations.-
Nested classes/interfaces inherited from class org.apache.commons.collections.collection.CompositeCollection
CompositeCollection.CollectionMutator
-
-
Constructor Summary
Constructors Constructor Description CompositeSet()Create an empty CompositeSetCompositeSet(java.util.Set set)Create a CompositeSet with justsetcompositedCompositeSet(java.util.Set[] sets)Create a composite set with sets as the initial set of composited Sets
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddComposited(java.util.Collection c)Add a Set to this compositevoidaddComposited(java.util.Collection[] comps)Add an array of sets to this compositevoidaddComposited(java.util.Collection c, java.util.Collection d)Add two sets to this compositebooleanequals(java.lang.Object obj)inthashCode()booleanremove(java.lang.Object obj)If aCollectionMutatoris defined for this CompositeSet then this method will be called anyway.voidsetMutator(CompositeCollection.CollectionMutator mutator)This can receive either aCompositeCollection.CollectionMutatoror aCompositeSet.SetMutator.-
Methods inherited from class org.apache.commons.collections.collection.CompositeCollection
add, addAll, clear, contains, containsAll, getCollections, isEmpty, iterator, removeAll, removeComposited, retainAll, size, toArray, toArray, toCollection
-
-
-
-
Constructor Detail
-
CompositeSet
public CompositeSet()
Create an empty CompositeSet
-
CompositeSet
public CompositeSet(java.util.Set set)
Create a CompositeSet with justsetcomposited- Parameters:
set- The initial set in the composite
-
CompositeSet
public CompositeSet(java.util.Set[] sets)
Create a composite set with sets as the initial set of composited Sets
-
-
Method Detail
-
addComposited
public void addComposited(java.util.Collection c)
Add a Set to this composite- Overrides:
addCompositedin classCompositeCollection- Parameters:
c- Must implement Set- Throws:
java.lang.IllegalArgumentException- if c does not implement java.util.Set or if a SetMutator is set, but fails to resolve a collisionjava.lang.UnsupportedOperationException- if there is no SetMutator set, or a CollectionMutator is set instead of a SetMutator- See Also:
CompositeCollection.CollectionMutator,CompositeSet.SetMutator
-
addComposited
public void addComposited(java.util.Collection c, java.util.Collection d)Add two sets to this composite- Overrides:
addCompositedin classCompositeCollection- Parameters:
c- the first collection to addd- the second collection to add- Throws:
java.lang.IllegalArgumentException- if c or d does not implement java.util.Set
-
addComposited
public void addComposited(java.util.Collection[] comps)
Add an array of sets to this composite- Overrides:
addCompositedin classCompositeCollection- Parameters:
comps-- Throws:
java.lang.IllegalArgumentException- if any of the collections in comps do not implement Set
-
setMutator
public void setMutator(CompositeCollection.CollectionMutator mutator)
This can receive either aCompositeCollection.CollectionMutatoror aCompositeSet.SetMutator. If aCompositeCollection.CollectionMutatoris used than conflicts when adding composited sets will throw IllegalArgumentException- Overrides:
setMutatorin classCompositeCollection- Parameters:
mutator- the mutator to use
-
remove
public boolean remove(java.lang.Object obj)
If aCollectionMutatoris defined for this CompositeSet then this method will be called anyway.- Specified by:
removein interfacejava.util.Collection- Specified by:
removein interfacejava.util.Set- Overrides:
removein classCompositeCollection- Parameters:
obj- Object to be removed- Returns:
- true if the object is removed, false otherwise
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfacejava.util.Collection- Specified by:
equalsin interfacejava.util.Set- Overrides:
equalsin classjava.lang.Object- See Also:
Set.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Collection- Specified by:
hashCodein interfacejava.util.Set- Overrides:
hashCodein classjava.lang.Object- See Also:
Set.hashCode()
-
-