org.apache.commons.collections.set

Class CompositeSet

public class CompositeSet extends CompositeCollection implements 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

Version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $

Author: Brian McCallister

Nested Class Summary
static interfaceCompositeSet.SetMutator
Define callbacks for mutation operations.
Constructor Summary
CompositeSet()
Create an empty CompositeSet
CompositeSet(Set set)
Create a CompositeSet with just set composited
CompositeSet(Set[] sets)
Create a composite set with sets as the initial set of composited Sets
Method Summary
voidaddComposited(Collection c)
Add a Set to this composite
voidaddComposited(Collection c, Collection d)
Add two sets to this composite
voidaddComposited(Collection[] comps)
Add an array of sets to this composite
booleanequals(Object obj)
inthashCode()
booleanremove(Object obj)
If a CollectionMutator is defined for this CompositeSet then this method will be called anyway.
voidsetMutator(CollectionMutator mutator)
This can receive either a CompositeCollection.CollectionMutator or a CompositeSet.SetMutator.

Constructor Detail

CompositeSet

public CompositeSet()
Create an empty CompositeSet

CompositeSet

public CompositeSet(Set set)
Create a CompositeSet with just set composited

Parameters: set The initial set in the composite

CompositeSet

public CompositeSet(Set[] sets)
Create a composite set with sets as the initial set of composited Sets

Method Detail

addComposited

public void addComposited(Collection c)
Add a Set to this composite

Parameters: c Must implement Set

Throws: IllegalArgumentException if c does not implement java.util.Set or if a SetMutator is set, but fails to resolve a collision UnsupportedOperationException if there is no SetMutator set, or a CollectionMutator is set instead of a SetMutator

See Also: CollectionMutator SetMutator

addComposited

public void addComposited(Collection c, Collection d)
Add two sets to this composite

Throws: IllegalArgumentException if c or d does not implement java.util.Set

addComposited

public void addComposited(Collection[] comps)
Add an array of sets to this composite

Parameters: comps

Throws: IllegalArgumentException if any of the collections in comps do not implement Set

equals

public boolean equals(Object obj)

See Also: Set#equals

hashCode

public int hashCode()

See Also: Set#hashCode

remove

public boolean remove(Object obj)
If a CollectionMutator is defined for this CompositeSet then this method will be called anyway.

Parameters: obj Object to be removed

Returns: true if the object is removed, false otherwise

setMutator

public void setMutator(CollectionMutator mutator)
This can receive either a CompositeCollection.CollectionMutator or a CompositeSet.SetMutator. If a CompositeCollection.CollectionMutator is used than conflicts when adding composited sets will throw IllegalArgumentException

Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.