net.walend.collection
Interface Collection

All Superinterfaces:
HasState
All Known Subinterfaces:
CollectionOfFreezables, FreezableSet, List, MutableCollection, MutableCollectionOfFreezables, MutableList, MutableSet, MutableSetOfFreezables, Set, SetOfFreezables
All Known Implementing Classes:
AbstractArrayList, AbstractFreezerHashSet, AbstractHashSet, AbstractHashSetOfFreezables, DelegatingMutableSet, FreezableDelegatingMutableSet, JDBCBackedMutableSet, MemSet, MutableArrayList, MutableFreezerHashSet, MutableHashSet, MutableHashSetOfFreezables

public interface Collection
extends HasState

This interface is the root interface in the javasupport.collection package. Use it for immutable Collections of Objects.

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

All implementations of javasupport.collection.Collection should include two constructors. One should have a single argument Collection (or a sub interface) which creates a copy of the argument. The second should have a single argument of java.util.Collection.

javasupport.collection.Collection implementations should not mess with the normal java equals() and hashCode() methods. Doing so prevents creating a mutable Collection of mutable Collections.

A Collection has the same state as another collection (for the HasState interface) if sameContentsAs() is true and the two collection's non-private state is the same.

Since:
20010216
Author:
David Walend

Method Summary
 boolean contains(java.lang.Object object)
          Returns true if this collection contains the specified Object.
 boolean containsAll(Collection c)
          Returns true if this collection contains all of the Objects in the specified collection.
 Identitor getIdentitor()
          Returns the Identitor for this Collection.
 java.util.Collection getJavaCollection()
          Return a java.util.Collection of these Objects.
 boolean isEmpty()
          Returns true if this collection contains no elements.
 java.util.Iterator iterator()
          Returns an iterator over the Objects in this collection.
 boolean sameContentsAs(Collection c)
          Returns true if this Collection's contents are equal to c's.
 int size()
          Returns the number of elements in this collection.
 
Methods inherited from interface net.walend.collection.HasState
getPrincipleInterface, sameStateAs
 

Method Detail

getIdentitor

public Identitor getIdentitor()
Returns the Identitor for this Collection.


size

public int size()
Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.


isEmpty

public boolean isEmpty()
Returns true if this collection contains no elements.


contains

public boolean contains(java.lang.Object object)
Returns true if this collection contains the specified Object.


iterator

public java.util.Iterator iterator()
Returns an iterator over the Objects in this collection.


containsAll

public boolean containsAll(Collection c)
Returns true if this collection contains all of the Objects in the specified collection. This method uses the contains() method.


sameContentsAs

public boolean sameContentsAs(Collection c)
Returns true if this Collection's contents are equal to c's.


getJavaCollection

public java.util.Collection getJavaCollection()
Return a java.util.Collection of these Objects.



Copyright (c) 2000, 2001, David Walend