Package com.opencloud.rem.common.form
Class FormBuilder
- java.lang.Object
-
- com.opencloud.rem.common.form.FormBuilder
-
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();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
FormBuilder.FieldBuilder
Used to build aField
for a particularFormBuilder
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Form
build()
Builds a newForm
using the values provided by thisFormBuilder
.static FormBuilder
newForm()
Starts building a new, unnamedForm
.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.
-
-
-
Method Detail
-
newForm
public static FormBuilder newForm()
Starts building a new, unnamedForm
.- Returns:
- a new
FormBuilder
-
newForm
public static FormBuilder newForm(String name)
Starts building a new form with the specified name.- Parameters:
name
- the name of the form- Returns:
- a new
FormBuilder
-
withName
public FormBuilder withName(String name)
Sets a name for the form to be built.- Parameters:
name
- the name of the form- Returns:
- the
FormBuilder
being used to construct this form
-
withField
public FormBuilder.FieldBuilder withField(String name, FieldType fieldType)
- Parameters:
name
- the name of this field - must not benull
fieldType
- theFieldType
of this field - must not benull
- Returns:
- a new
FormBuilder.FieldBuilder
linked to thisFormBuilder
-
build
public Form build()
Builds a newForm
using the values provided by thisFormBuilder
.- Returns:
- the new
Form
-
-