org.apache.commons.collections.set
Class CompositeSet<E>

java.lang.Object
  extended by org.apache.commons.collections.collection.CompositeCollection<E>
      extended by org.apache.commons.collections.set.CompositeSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>

public class CompositeSet<E>
extends CompositeCollection<E>
implements Set<E>

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
Version:
$Revision: 1.1.1.1 $ $Date: 2005/05/23 04:36:19 $
Author:
Matt Hall, John Watkinson, Brian McCallister

Nested Class Summary
static interface CompositeSet.SetMutator<E>
          Define callbacks for mutation operations.
 
Nested classes/interfaces inherited from class org.apache.commons.collections.collection.CompositeCollection
CompositeCollection.CollectionMutator<E>
 
Field Summary
 
Fields inherited from class org.apache.commons.collections.collection.CompositeCollection
all, mutator
 
Constructor Summary
CompositeSet()
          Create an empty CompositeSet
CompositeSet(Set<E> set)
          Create a CompositeSet with just set composited
CompositeSet(Set<E>[] sets)
          Create a composite set with sets as the initial set of composited Sets
 
Method Summary
 void addComposited(Collection<? extends E> c)
          Add a Set to this composite
 void addComposited(Collection<? extends E>[] comps)
          Add an array of sets to this composite
 void addComposited(Collection<? extends E> c, Collection<? extends E> d)
          Add two 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<E> mutator)
          This can receive either a CompositeCollection.CollectionMutator or a CompositeSet.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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

CompositeSet

public CompositeSet()
Create an empty CompositeSet


CompositeSet

public CompositeSet(Set<E> set)
Create a CompositeSet with just set composited

Parameters:
set - The initial set in the composite

CompositeSet

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

Method Detail

addComposited

public void addComposited(Collection<? extends E> c)
Add a Set to this composite

Overrides:
addComposited in class CompositeCollection<E>
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:
CompositeCollection.CollectionMutator, CompositeSet.SetMutator

addComposited

public void addComposited(Collection<? extends E> c,
                          Collection<? extends E> d)
Add two sets to this composite

Overrides:
addComposited in class CompositeCollection<E>
Parameters:
c - the first collection to add
d - the second collection to add
Throws:
IllegalArgumentException - if c or d does not implement java.util.Set

addComposited

public void addComposited(Collection<? extends E>[] comps)
Add an array of sets to this composite

Overrides:
addComposited in class CompositeCollection<E>
Parameters:
comps -
Throws:
IllegalArgumentException - if any of the collections in comps do not implement Set

setMutator

public void setMutator(CompositeCollection.CollectionMutator<E> 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

Overrides:
setMutator in class CompositeCollection<E>
Parameters:
mutator - the mutator to use

remove

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

Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Set<E>
Overrides:
remove in class CompositeCollection<E>
Parameters:
obj - Object to be removed
Returns:
true if the object is removed, false otherwise

equals

public boolean equals(Object obj)
Specified by:
equals in interface Collection<E>
Specified by:
equals in interface Set<E>
Overrides:
equals in class Object
See Also:
Set.equals(java.lang.Object)

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<E>
Specified by:
hashCode in interface Set<E>
Overrides:
hashCode in class Object
See Also:
Set.hashCode()


Copyright © 2005-2005 Apache Software Foundation, Matt Hall, John Watkinson. All Rights Reserved.