net.walend.lyophil.collection
Interface MutableCollectionOfFreezables

All Superinterfaces:
Collection, CollectionOfFreezables, HasState, MutableCollection
All Known Subinterfaces:
FreezableSet, MutableSetOfFreezables
All Known Implementing Classes:
DelegatingMutableSet, FreezableDelegatingMutableSet, JDBCBackedMutableSet, MemSet, MutableFreezerHashSet, MutableHashSetOfFreezables

public interface MutableCollectionOfFreezables
extends CollectionOfFreezables, MutableCollection

Use this interface for changable CollectionOfFreezables.

Use a direct implementation of this interface, like Bag, to handle a multiset.

All implementations of lyophil.collection.MutableCollectionOfFreezables should include three standard constructors: a no-argument constructor, a constructor with an initial size, and a constructor with the single argument Collection (or a sub interface) which creates a copy of the argument.

lyophil.collection.MutableCollectionOfFreezables implementations should not mess with the normal java equals() and hashCode() methods. Doing so prevents creating a Map of dynamic Sets, critical for an in-memory Freezer.

Implementations of these interfaces should generally go back to the Freezer for Freezables.

Since:
20010105
Author:
David Walend

Method Summary
 boolean addAllIdentifiedBy(Collection c)
          Adds all the Freezables identified by c to this MutableCollection using the addIdentifiedBy method.
 boolean addIdentifiedBy(java.io.Serializable id)
          Adds a Freezable to the MutableCollection.
 boolean removeAllIdentifiedBy(Collection c)
          Removes all the Freezables identified by c from this MutableCollection using the removeIdentifiedBy method.
 boolean removeIdentifiedBy(java.io.Serializable id)
          Removes a Freezable from the MutableCollection, based on that Freezable's identifier.
 boolean retainAllIdentifiedBy(Collection c)
          Removes all but the Freezables identified by c from this MutableCollection using the removeIdentifiedBy method.
 
Methods inherited from interface net.walend.lyophil.collection.CollectionOfFreezables
containsAllIdentifiedBy, containsIdentifiedBy, freezableIterator, getIdentifiers, identifierIterator
 
Methods inherited from interface net.walend.collection.Collection
contains, containsAll, getIdentitor, getJavaCollection, isEmpty, iterator, sameContentsAs, size
 
Methods inherited from interface net.walend.collection.HasState
getPrincipleInterface, sameStateAs
 
Methods inherited from interface net.walend.collection.MutableCollection
add, addAll, clear, remove, removeAll, retainAll
 

Method Detail

addIdentifiedBy

public boolean addIdentifiedBy(java.io.Serializable id)
Adds a Freezable to the MutableCollection. Sets will only add it to the Set if it's not already there, based on the getIdentifier() and sameIdentifierAs() methods. Lists will tack it on the end of a list.

Returns:
true if the MutableCollection changes, false if not.
Throws:
java.lang.ClassCastException - class of the specified element prevents it from being added to this collection.
java.lang.IllegalArgumentException - some aspect of this element prevents it from being added to this collection.
ZombieIdentifierException - if f is not in the Freezer and this implementation checks on add.

removeIdentifiedBy

public boolean removeIdentifiedBy(java.io.Serializable id)
Removes a Freezable from the MutableCollection, based on that Freezable's identifier. This method uses the getIdentifier() and sameIdentifierAs() methods of the Freezables to find the right one.

Returns:
true if the MutableCollection changes, false if not.

addAllIdentifiedBy

public boolean addAllIdentifiedBy(Collection c)
Adds all the Freezables identified by c to this MutableCollection using the addIdentifiedBy method. Returns true if this MutableCollection changes.

Throws:
java.lang.ClassCastException - if the class of an element of the specified collection prevents it from being added to this collection.
java.lang.IllegalArgumentException - some aspect of an element of the specified collection prevents it from being added to this collection.

removeAllIdentifiedBy

public boolean removeAllIdentifiedBy(Collection c)
Removes all the Freezables identified by c from this MutableCollection using the removeIdentifiedBy method. Returns true if this MutableCollection changes.

Throws:
java.lang.ClassCastException - if the class of an element of the specified collection prevents it from being added to this collection.
java.lang.IllegalArgumentException - some aspect of an element of the specified collection prevents it from being added to this collection.

retainAllIdentifiedBy

public boolean retainAllIdentifiedBy(Collection c)
Removes all but the Freezables identified by c from this MutableCollection using the removeIdentifiedBy method. Returns true if this MutableCollection changes.

Throws:
java.lang.ClassCastException - if the class of an element of the specified collection prevents it from being added to this collection.
java.lang.IllegalArgumentException - some aspect of an element of the specified collection prevents it from being added to this collection.


Copyright (c) 2000, 2001, David Walend