public class FormBuilder extends Object
Used to construct a new Form
schema.
Usage example:
Form form = FormBuilder.newForm("My Form")
.withField("foo", FieldType.STRING)
.displayName("Foo")
.required()
.add()
.withField("bar", FieldType.DATE)
.displayName("Bar")
.add()
.build();
Or similarly:
FormBuilder formBuilder = FormBuilder.newForm("My Form");
formBuilder.withField("foo", FieldType.STRING)
.displayName("Foo")
.required()
.add();
formBuilder.withField("bar", FieldType.DATE)
.displayName("Bar")
.add();
Form form = formBuilder.build();
Modifier and Type | Class and Description |
---|---|
class |
FormBuilder.FieldBuilder
Used to build a
Field for a particular FormBuilder . |
Modifier and Type | Method and Description |
---|---|
Form |
build()
Builds a new
Form using the values provided by this
FormBuilder . |
static FormBuilder |
newForm()
Starts building a new, unnamed
Form . |
static FormBuilder |
newForm(String name)
Starts building a new form with the specified name.
|
FormBuilder.FieldBuilder |
withField(String name,
FieldType fieldType)
|
FormBuilder |
withName(String name)
Sets a name for the form to be built.
|
public static FormBuilder newForm()
Form
.FormBuilder
public static FormBuilder newForm(String name)
name
- the name of the formFormBuilder
public FormBuilder withName(String name)
name
- the name of the formFormBuilder
being used to construct this formpublic FormBuilder.FieldBuilder withField(String name, FieldType fieldType)
name
- the name of this field - must not be null
fieldType
- the FieldType
of this field - must not be
null
FormBuilder.FieldBuilder
linked to this FormBuilder
public Form build()
Form
using the values provided by this
FormBuilder
.Form