com.jgpruitt.datamodeler.core
Class ColumnSet

java.lang.Object
  extended by com.jgpruitt.datamodeler.core.ColumnSet
All Implemented Interfaces:
java.lang.Iterable<Column>
Direct Known Subclasses:
PrimaryKey, Table, UniqueKey

public class ColumnSet
extends java.lang.Object
implements java.lang.Iterable<Column>

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

Author:
John Pruitt
See Also:
Column

Field Summary
protected  java.util.List<Column> list
           
protected  java.util.Map<java.lang.String,Column> map
           
 
Constructor Summary
ColumnSet()
          Constructor.
 
Method Summary
 Column add(Column col)
          Add a Column to the set.
 boolean contains(Column col)
          Tests to see if a Column is already in the set.
 boolean contains(java.lang.String name)
          Tests to see if a Column exists in the set by a particular name.
 Column get(int index)
          Gets a Column from the set by the ordinal.
 Column get(java.lang.String name)
          Gets a Column from the set by the Column name.
 boolean isEmpty()
          Is the set empty?
 java.util.Iterator<Column> iterator()
          Gets an iterator.
 int size()
          Gets the number of Columns 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,Column> map

list

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

ColumnSet

public ColumnSet()
Constructor.

Method Detail

add

public Column add(Column col)
Add a Column to the set. Argument must not be null, and must not have a name equal to any other Column's name already in the set.

Parameters:
col - The Column to add to the set.
Returns:
The Column that was added.
See Also:
Column

get

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

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

get

public Column get(java.lang.String name)
Gets a Column from the set by the Column name.

Parameters:
name - The name of the Column to retrieve.
Returns:
The Column with the requested name.
See Also:
Column

contains

public boolean contains(java.lang.String name)
Tests to see if a Column exists in the set by a particular name.

Parameters:
name - The name of the Column.
Returns:
Returns true if the set contains a Column with the name passed.
See Also:
Column

contains

public boolean contains(Column col)
Tests to see if a Column is already in the set.

Parameters:
col - The Column.
Returns:
Returns true if the Column is in the set.
See Also:
Column

iterator

public java.util.Iterator<Column> iterator()
Gets an iterator.

Specified by:
iterator in interface java.lang.Iterable<Column>
Returns:
Returns a Iterator over the Columns in the set.
See Also:
Iterator

isEmpty

public boolean isEmpty()
Is the set empty?

Returns:
Returns true if the set contains no Columns.

size

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

Returns:
The number of Columns in the set.