⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.collections.set

Class CompositeSet

java.lang.Object
|
+--org.apache.commons.collections.collection.CompositeCollection
   |
   +--org.apache.commons.collections.set.CompositeSet

All Implemented Interfaces:
Collection, Set


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 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
Author:
Brian McCallister

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

synchronized void

addComposited(Collection c)

Add a Set to this composite

synchronized void

addComposited(Collection c, Collection d)

Add two sets to this composite

synchronized void

addComposited(Collection[] comps)

Add an array of sets to this composite

boolean

equals(Object obj)

int

hashCode()

boolean

remove(Object obj)

If a CollectionMutator is defined for this CompositeSet then this method will be called anyway.

void

setMutator(CompositeCollection.CollectionMutator mutator)

This can receive either a CompositeCollection.CollectionMutator or a CompositeSet.SetMutator.

Constructor Details

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

Parameters:
sets

Method Details

addComposited

public synchronized void addComposited(Collection c, Collection d)

Add two sets to this composite

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

addComposited

public synchronized void addComposited(Collection c)

Add a Set to this composite

Parameters:
c - Must implement Set
Throws:
- if c does not implement java.util.Set or if a SetMutator is set, but fails to resolve a collision
- if there is no SetMutator set, or a CollectionMutator is set instead of a SetMutator
See Also:
org.apache.commons.collections.collection.CompositeCollection.CollectionMutator
SetMutator

addComposited

public synchronized void addComposited(Collection[] comps)

Add an array of sets to this composite

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

equals

public boolean equals(Object obj)

Parameters:
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(CompositeCollection.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

Parameters:
mutator