org.norther.tammi.acorn.util
Class ModifiableSet<E>

java.lang.Object
  extended by org.norther.tammi.acorn.util.UnmodifiableCollection<E>
      extended by org.norther.tammi.acorn.util.UnmodifiableSet<E>
          extended by org.norther.tammi.acorn.util.ModifiableSet<E>
Type Parameters:
E - the element type.
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Set<E>, Modifiable

public class ModifiableSet<E>
extends UnmodifiableSet<E>
implements Modifiable

Extends UnmodifiableSet by supporting modifications after cloning.

Version:
$Id: ModifiableSet.java,v 1.15 2009/09/28 15:08:49 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.norther.tammi.acorn.util.Modifiable
MODIFIABLE_ADAPTEE, MODIFIABLE_ADAPTER, MODIFIABLE_COLLECTION, MODIFIABLE_MASK
 
Constructor Summary
ModifiableSet(boolean... modifiable)
          Constructs an empty set.
ModifiableSet(Collection<E> c, boolean... modifiable)
          Constructs a new set for a collection.
ModifiableSet(Set<E> s, boolean... modifiable)
          Constructs a new set.
 
Method Summary
 boolean add(E o)
           
 boolean addAll(Collection<? extends E> x)
           
 void clear()
           
 Object clone()
           
protected  Set<E> getModifiableSet(boolean... modifiable)
          Gets a modifiable instance of the wrapped set.
 boolean isModifiable()
          Checks whether this collection is modifiable.
 Iterator<E> iterator()
           
protected  void setCollection(Collection<E> c)
          Sets the collection adaptee.
 
Methods inherited from class org.norther.tammi.acorn.util.UnmodifiableSet
getSet, setSet
 
Methods inherited from class org.norther.tammi.acorn.util.UnmodifiableCollection
contains, containsAll, equals, getCollection, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

ModifiableSet

public ModifiableSet(boolean... modifiable)
Constructs an empty set.

Parameters:
modifiable - the modifiable states of the collection, adapter and adaptee.

ModifiableSet

public ModifiableSet(Set<E> s,
                     boolean... modifiable)
Constructs a new set.

Parameters:
s - a set to wrap.
modifiable - the modifiable states of the collection, adapter and adaptee.

ModifiableSet

public ModifiableSet(Collection<E> c,
                     boolean... modifiable)
Constructs a new set for a collection.

Parameters:
c - a collection to wrap.
modifiable - the modifiable states of the collection, adapter and adaptee.
Method Detail

clone

public Object clone()
Overrides:
clone in class UnmodifiableCollection<E>

isModifiable

public boolean isModifiable()
Description copied from interface: Modifiable
Checks whether this collection is modifiable.

Specified by:
isModifiable in interface Modifiable
Returns:
true for a modifiable collection, false otherwise.

add

public boolean add(E o)
Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>
Overrides:
add in class UnmodifiableCollection<E>

addAll

public boolean addAll(Collection<? extends E> x)
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface Set<E>
Overrides:
addAll in class UnmodifiableCollection<E>

clear

public void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>
Overrides:
clear in class UnmodifiableCollection<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Set<E>
Overrides:
iterator in class UnmodifiableCollection<E>

setCollection

protected void setCollection(Collection<E> c)
Description copied from class: UnmodifiableCollection
Sets the collection adaptee.

Overrides:
setCollection in class UnmodifiableSet<E>
Parameters:
c - the wrapped collection.

getModifiableSet

protected Set<E> getModifiableSet(boolean... modifiable)
Gets a modifiable instance of the wrapped set.

Parameters:
modifiable - the modifiable states of the collection, adapter and adaptee.
Returns:
a modifiable set or null.


Copyright © 2004 The Norther Organization. All rights reserved.