com.jgpruitt.datamodeler.core
Class ForeignKeySet

java.lang.Object
  extended by com.jgpruitt.datamodeler.core.ForeignKeySet
All Implemented Interfaces:
java.lang.Iterable<ForeignKey>

public class ForeignKeySet
extends java.lang.Object
implements java.lang.Iterable<ForeignKey>

ForeignKeySet is a collection of ForeignKeys in which each column must have a unique name. The collection maintains the order in which the elements are added. The implementation guarantees constant time getting of ForeignKeys by name or ordinal.

Author:
John Pruitt
See Also:
ForeignKey

Field Summary
protected  java.util.List<ForeignKey> list
           
protected  java.util.Map<java.lang.String,ForeignKey> map
           
 
Constructor Summary
ForeignKeySet()
          Constructor.
 
Method Summary
 ForeignKey add(ForeignKey fk)
          Adds a ForeignKey to the set.
 boolean contains(ForeignKey fk)
          Tests whether the ForeignKey is in the set.
 boolean contains(java.lang.String name)
          Tests whether a ForeignKey is in the set by name.
 ForeignKey get(int index)
          Gets a ForeignKey from the set by the ordinal.
 ForeignKey get(java.lang.String name)
          Gets a ForeignKey from the set by the ForeignKey's name.
 boolean isEmpty()
          Returns true if the set is empty.
 java.util.Iterator<ForeignKey> iterator()
          Gets an Iterator over the ForeignKeys in the set
 int size()
          Gets the number of elements in the set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected final java.util.Map<java.lang.String,ForeignKey> map

list

protected final java.util.List<ForeignKey> list
Constructor Detail

ForeignKeySet

public ForeignKeySet()
Constructor.

Method Detail

add

public ForeignKey add(ForeignKey fk)
Adds a ForeignKey to the set. Argument must not be null and must not have a name equal to any other ForeignKey's name already in the set.

Parameters:
fk - The ForeignKey to add to the set.
Returns:
Returns the ForeignKey that was added.
See Also:
ForeignKey

get

public ForeignKey get(int index)
Gets a ForeignKey from the set by the ordinal.

Parameters:
index - The ordinal.
Returns:
The ForeignKey at the requested ordinal
See Also:
ForeignKey

get

public ForeignKey get(java.lang.String name)
Gets a ForeignKey from the set by the ForeignKey's name.

Parameters:
name - The name of the ForeignKey
Returns:
The ForeignKey
See Also:
ForeignKey

contains

public boolean contains(java.lang.String name)
Tests whether a ForeignKey is in the set by name.

Parameters:
name - the name of the ForeignKey
Returns:
true if a ForeignKey is in the set with a matching name

contains

public boolean contains(ForeignKey fk)
Tests whether the ForeignKey is in the set.

Parameters:
fk - The ForeignKey
Returns:
true if the ForeignKey is in the set.

iterator

public java.util.Iterator<ForeignKey> iterator()
Gets an Iterator over the ForeignKeys in the set

Specified by:
iterator in interface java.lang.Iterable<ForeignKey>
Returns:
The Iterator

isEmpty

public boolean isEmpty()
Returns true if the set is empty.

Returns:
true if the set is empty.

size

public int size()
Gets the number of elements in the set.

Returns:
the number of elements in the set.