step.typedef
Class RecordDef.Builder

java.lang.Object
  |
  +--step.typedef.RecordDef.Builder
Enclosing class:
RecordDef

public static class RecordDef.Builder
extends Object

Create record definitions with the Builder pattern.


Method Summary
 RecordDef.Builder addAttribute(Attribute attribute)
          Add a record attribute to the definition.
 RecordDef.Builder addField(FieldDef fieldDef)
          Add a field to the definition.
 void clear()
          Clear the current build context.
 List getAttributes()
          Get the list of record attributes for the definition.
 String getDescription()
          Get the description for the definition.
 RecordFactory getFactory()
          Get the factory for the definition.
 List getFields()
          Get the list of fields for the definition.
 String getLabel()
          Get the label for the definition.
 List getModifiers()
          Get the list of field modifiers for the definition.
 Type getParent()
          Get the parent for the current definition.
 RecordDef makeRecordDef()
          Obtain the completed record definition.
 RecordDef.Builder modifyField(FieldModifier modifier)
          Add a field modifier to the definition.
 RecordDef.Builder newRecordDef(String name)
          Start building a new record definition with the given name in the ROOT package.
 RecordDef.Builder newRecordDef(String name, Package pkg)
          Start building a new record definition with the given name in the given package.
 RecordDef.Builder newRecordDef(String name, String pkgName)
          Start building a new record definition with the given name in the given package name.
 RecordDef.Builder setDescription(String description)
          Set the description for the definition.
 RecordDef.Builder setFactory(RecordFactory factory)
          Set the factory object for the definition.
 RecordDef.Builder setLabel(String label)
          Set the label for the definition.
 RecordDef.Builder setParent(String parentName)
          Make the definition inherit from another.
 RecordDef.Builder setParent(String parentName, boolean cleanInherit)
          Make the definition inherit from another.
 RecordDef.Builder setParent(Type parent)
          Make the definition inherit from another.
 RecordDef.Builder setParent(Type parent, boolean cleanInherit)
          Make the definition inherit from another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newRecordDef

public RecordDef.Builder newRecordDef(String name)
Start building a new record definition with the given name in the ROOT package.

See Also:
newRecordDef(String,Package)

newRecordDef

public RecordDef.Builder newRecordDef(String name,
                                      String pkgName)
Start building a new record definition with the given name in the given package name.

See Also:
newRecordDef(String,Package)

newRecordDef

public RecordDef.Builder newRecordDef(String name,
                                      Package pkg)
Start building a new record definition with the given name in the given package.

The default record label is the record's name. The default record description is the empty string ("").

Parameters:
name - the brief name of the record type.
pkg - the package containing the record.
Returns:
the current builder.
Throws:
IllegalStateException - if already building a definition.
IllegalArgumentException - if name or pkg are null.

setParent

public RecordDef.Builder setParent(String parentName)
Make the definition inherit from another.

See Also:
setParent(Type,boolean)

setParent

public RecordDef.Builder setParent(String parentName,
                                   boolean cleanInherit)
Make the definition inherit from another.

See Also:
setParent(Type,boolean)

setParent

public RecordDef.Builder setParent(Type parent)
Make the definition inherit from another.

See Also:
setParent(Type,boolean)

setParent

public RecordDef.Builder setParent(Type parent,
                                   boolean cleanInherit)
Make the definition inherit from another.

Parameters:
parent - the type to inherit from
cleanInherit - if true, do not inherit the parent's record attributes
Returns:
the current builder.
Throws:
IllegalStateException - if not building a definition.
IllegalArgumentException - if parent is null.
See Also:
DerivedRecordDef

getParent

public Type getParent()
Get the parent for the current definition.

Returns:
the parent type, or null if no parent is currently defined.

setLabel

public RecordDef.Builder setLabel(String label)
Set the label for the definition.

Returns:
the current builder.
Throws:
IllegalStateException - if not building a definition.
IllegalArgumentException - if label is null.

getLabel

public String getLabel()
Get the label for the definition.

Returns:
the label, or null if no label is currently defined.

setDescription

public RecordDef.Builder setDescription(String description)
Set the description for the definition.

Returns:
the current builder.
Throws:
IllegalStateException - if not building a definition.
IllegalArgumentException - if description is null.

getDescription

public String getDescription()
Get the description for the definition.

Returns:
the description, or null if no description is currently defined.

addAttribute

public RecordDef.Builder addAttribute(Attribute attribute)
Add a record attribute to the definition.

Returns:
the current builder.
Throws:
IllegalStateException - if not building a definition.
IllegalArgumentException - if attribute is null.

getAttributes

public List getAttributes()
Get the list of record attributes for the definition.

Returns:
the current list of attributes, which may be empty.

addField

public RecordDef.Builder addField(FieldDef fieldDef)
Add a field to the definition.

Returns:
the current builder.
Throws:
IllegalStateException - if not building a definition.
IllegalArgumentException - if fieldDef is null.

getFields

public List getFields()
Get the list of fields for the definition.

Returns:
the current list of field definitions, which may be empty.

modifyField

public RecordDef.Builder modifyField(FieldModifier modifier)
Add a field modifier to the definition.

Returns:
the current builder.
Throws:
IllegalStateException - if not building a definition.
IllegalArgumentException - if modifier is null.

getModifiers

public List getModifiers()
Get the list of field modifiers for the definition.

Returns:
the current list of field modifiers, which may be empty.

setFactory

public RecordDef.Builder setFactory(RecordFactory factory)
Set the factory object for the definition.

Returns:
the current builder.
Throws:
IllegalStateException - if not building a definition.
IllegalArgumentException - if factory is null.

getFactory

public RecordFactory getFactory()
Get the factory for the definition.

Returns:
the factory, or null if no factory is currently defined.

makeRecordDef

public RecordDef makeRecordDef()
Obtain the completed record definition.

NOTE: This definition will be set as the default for the type. Also, if the type is derived its parent is set as the parent in the definition.

Returns:
the fully constructed record definition.
Throws:
IllegalStateException - if not building a definition.
See Also:
TypeDef.getDefault(Type), Type.getParent()

clear

public void clear()
Clear the current build context.