com.jgpruitt.datamodeler.core
Class TableBuilder

java.lang.Object
  extended by com.jgpruitt.datamodeler.core.TableBuilder

public class TableBuilder
extends java.lang.Object

A Fluent Builder class for constructing Table objects

Author:
John Pruitt

Nested Class Summary
 class TableBuilder.ForeignKeyBuilder
          A Fluent Builder class for constructing ForeignKey constraints
 
Field Summary
protected  SchemaBuilder schemaBuilder
           
protected  Table table
           
 
Constructor Summary
protected TableBuilder(java.lang.String name, SchemaBuilder schemaBuilder)
          Constructor
 
Method Summary
 ColumnBuilder column(java.lang.String name)
          Adds a Column to the Table
 TableBuilder comment(java.lang.String comment)
          Sets the comment describing the Table
 SchemaBuilder done()
          Gets the SchemaBuilder
 TableBuilder.ForeignKeyBuilder foreignKey(java.lang.String name)
          Creates a ForeignKey constraint on the Table.
 IndexBuilder index(java.lang.String name)
          Creates an Index on Columns of the Table
 TableBuilder primaryKey(java.lang.String name, java.lang.String... columns)
          Creates a PrimaryKey constraint on the Table
 TableBuilder uniqueKey(java.lang.String name, java.lang.String... columns)
          Creates a UniqueKey constraint on Columns of the Table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected final Table table

schemaBuilder

protected final SchemaBuilder schemaBuilder
Constructor Detail

TableBuilder

protected TableBuilder(java.lang.String name,
                       SchemaBuilder schemaBuilder)
Constructor

Parameters:
name - the name of the new Table to create
schemaBuilder - the SchemaBuilder of the Schema to which the Table should be added
Method Detail

done

public SchemaBuilder done()
Gets the SchemaBuilder

Returns:
the SchemaBuilder

comment

public TableBuilder comment(java.lang.String comment)
Sets the comment describing the Table

Parameters:
comment - the comment
Returns:
this TableBuilder

column

public ColumnBuilder column(java.lang.String name)
Adds a Column to the Table

Parameters:
name - the name of the Column
Returns:
a ColumnBuilder used to construct the Column

primaryKey

public TableBuilder primaryKey(java.lang.String name,
                               java.lang.String... columns)
Creates a PrimaryKey constraint on the Table

Parameters:
name - the name of the PrimaryKey constraint
columns - the names of the Columns in the Table that make up the primary key
Returns:
this TableBuilder

uniqueKey

public TableBuilder uniqueKey(java.lang.String name,
                              java.lang.String... columns)
Creates a UniqueKey constraint on Columns of the Table

Parameters:
name - the name of the UniqueKey constraint
columns - the names of the Columns that make up the unique key constraint
Returns:
this TableBuilder

foreignKey

public TableBuilder.ForeignKeyBuilder foreignKey(java.lang.String name)
Creates a ForeignKey constraint on the Table.

Parameters:
name - the name of the ForeignKey to create
Returns:
a ForeignKeyBuilder

index

public IndexBuilder index(java.lang.String name)
Creates an Index on Columns of the Table

Parameters:
name - the name of the Index
Returns:
an IndexBuilder to construct the Index