Package io.dialob.api.form
Class ImmutableForm.Builder
- java.lang.Object
-
- io.dialob.api.form.ImmutableForm.Builder
-
- Enclosing class:
- ImmutableForm
@NotThreadSafe public static final class ImmutableForm.Builder extends Object
Builds instances of typeImmutableForm. Initialize attributes and then invoke thebuild()method to create an immutable instance.Builderis not thread-safe and generally should not be stored in a field or collection, but instead used immediately to create instances.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableForm.BuilderaddAllValueSets(Iterable<? extends FormValueSet> elements)Adds elements tovalueSetslist.ImmutableForm.BuilderaddAllVariables(Iterable<? extends Variable> elements)Adds elements tovariableslist.ImmutableForm.BuilderaddValueSets(FormValueSet element)Adds one element tovalueSetslist.ImmutableForm.BuilderaddValueSets(FormValueSet... elements)Adds elements tovalueSetslist.ImmutableForm.BuilderaddVariables(Variable element)Adds one element tovariableslist.ImmutableForm.BuilderaddVariables(Variable... elements)Adds elements tovariableslist.ImmutableFormbuild()Builds a newImmutableForm.ImmutableForm.Builderdata(Map<String,? extends FormItem> entries)Sets or replaces all mappings from the specified map as entries for thedatamap.ImmutableForm.Builderfrom(Form instance)Fill a builder with attribute values from the providedForminstance.ImmutableForm.Builderfrom(ModifiableForm instance)Fill a builder with attribute values from the providedModifiableForminstance.ImmutableForm.Builderid(String id)Initializes the value for theidattribute.ImmutableForm.Buildermetadata(Form.Metadata metadata)Initializes the value for themetadataattribute.ImmutableForm.Buildername(String name)Initializes the value for thenameattribute.ImmutableForm.Buildernamespaces(Map<String,? extends Form> entries)Sets or replaces all mappings from the specified map as entries for thenamespacesmap.ImmutableForm.BuilderputAllData(Map<String,? extends FormItem> entries)Put all mappings from the specified map as entries todatamap.ImmutableForm.BuilderputAllNamespaces(Map<String,? extends Form> entries)Put all mappings from the specified map as entries tonamespacesmap.ImmutableForm.BuilderputAllRequiredErrorText(Map<String,? extends String> entries)Put all mappings from the specified map as entries torequiredErrorTextmap.ImmutableForm.BuilderputData(String key, FormItem value)Put one entry to thedatamap.ImmutableForm.BuilderputData(Map.Entry<String,? extends FormItem> entry)Put one entry to thedatamap.ImmutableForm.BuilderputNamespaces(String key, Form value)Put one entry to thenamespacesmap.ImmutableForm.BuilderputNamespaces(Map.Entry<String,? extends Form> entry)Put one entry to thenamespacesmap.ImmutableForm.BuilderputRequiredErrorText(String key, String value)Put one entry to therequiredErrorTextmap.ImmutableForm.BuilderputRequiredErrorText(Map.Entry<String,? extends String> entry)Put one entry to therequiredErrorTextmap.ImmutableForm.BuilderrequiredErrorText(Map<String,? extends String> entries)Sets or replaces all mappings from the specified map as entries for therequiredErrorTextmap.ImmutableForm.Builderrev(String rev)Initializes the value for therevattribute.ImmutableForm.BuildervalueSets(Iterable<? extends FormValueSet> elements)Sets or replaces all elements forvalueSetslist.ImmutableForm.Buildervariables(Iterable<? extends Variable> elements)Sets or replaces all elements forvariableslist.
-
-
-
Method Detail
-
from
public final ImmutableForm.Builder from(ModifiableForm instance)
Fill a builder with attribute values from the providedModifiableForminstance.- Parameters:
instance- The instance from which to copy values- Returns:
thisbuilder for use in a chained invocation
-
from
public final ImmutableForm.Builder from(Form instance)
Fill a builder with attribute values from the providedForminstance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values. Collection elements and entries will be added, not replaced.- Parameters:
instance- The instance from which to copy values- Returns:
thisbuilder for use in a chained invocation
-
id
public final ImmutableForm.Builder id(String id)
Initializes the value for theidattribute.- Parameters:
id- The value for id (can benull)- Returns:
thisbuilder for use in a chained invocation
-
rev
public final ImmutableForm.Builder rev(String rev)
Initializes the value for therevattribute.- Parameters:
rev- The value for rev (can benull)- Returns:
thisbuilder for use in a chained invocation
-
name
public final ImmutableForm.Builder name(String name)
Initializes the value for thenameattribute.- Parameters:
name- The value for name (can benull)- Returns:
thisbuilder for use in a chained invocation
-
putData
public final ImmutableForm.Builder putData(String key, FormItem value)
Put one entry to thedatamap.- Parameters:
key- The key in the data mapvalue- The associated value in the data map- Returns:
thisbuilder for use in a chained invocation
-
putData
public final ImmutableForm.Builder putData(Map.Entry<String,? extends FormItem> entry)
Put one entry to thedatamap. Nulls are not permitted- Parameters:
entry- The key and value entry- Returns:
thisbuilder for use in a chained invocation
-
data
public final ImmutableForm.Builder data(Map<String,? extends FormItem> entries)
Sets or replaces all mappings from the specified map as entries for thedatamap. Nulls are not permitted- Parameters:
entries- The entries that will be added to the data map- Returns:
thisbuilder for use in a chained invocation
-
putAllData
public final ImmutableForm.Builder putAllData(Map<String,? extends FormItem> entries)
Put all mappings from the specified map as entries todatamap. Nulls are not permitted- Parameters:
entries- The entries that will be added to the data map- Returns:
thisbuilder for use in a chained invocation
-
metadata
public final ImmutableForm.Builder metadata(Form.Metadata metadata)
Initializes the value for themetadataattribute.- Parameters:
metadata- The value for metadata (can benull)- Returns:
thisbuilder for use in a chained invocation
-
addVariables
public final ImmutableForm.Builder addVariables(@Nullable Variable element)
Adds one element tovariableslist.- Parameters:
element- A variables element- Returns:
thisbuilder for use in a chained invocation
-
addVariables
public final ImmutableForm.Builder addVariables(Variable... elements)
Adds elements tovariableslist.- Parameters:
elements- An array of variables elements- Returns:
thisbuilder for use in a chained invocation
-
variables
public final ImmutableForm.Builder variables(Iterable<? extends Variable> elements)
Sets or replaces all elements forvariableslist.- Parameters:
elements- An iterable of variables elements- Returns:
thisbuilder for use in a chained invocation
-
addAllVariables
public final ImmutableForm.Builder addAllVariables(Iterable<? extends Variable> elements)
Adds elements tovariableslist.- Parameters:
elements- An iterable of variables elements- Returns:
thisbuilder for use in a chained invocation
-
putNamespaces
public final ImmutableForm.Builder putNamespaces(String key, Form value)
Put one entry to thenamespacesmap.- Parameters:
key- The key in the namespaces mapvalue- The associated value in the namespaces map- Returns:
thisbuilder for use in a chained invocation
-
putNamespaces
public final ImmutableForm.Builder putNamespaces(Map.Entry<String,? extends Form> entry)
Put one entry to thenamespacesmap. Nulls are not permitted- Parameters:
entry- The key and value entry- Returns:
thisbuilder for use in a chained invocation
-
namespaces
public final ImmutableForm.Builder namespaces(Map<String,? extends Form> entries)
Sets or replaces all mappings from the specified map as entries for thenamespacesmap. Nulls are not permitted- Parameters:
entries- The entries that will be added to the namespaces map- Returns:
thisbuilder for use in a chained invocation
-
putAllNamespaces
public final ImmutableForm.Builder putAllNamespaces(Map<String,? extends Form> entries)
Put all mappings from the specified map as entries tonamespacesmap. Nulls are not permitted- Parameters:
entries- The entries that will be added to the namespaces map- Returns:
thisbuilder for use in a chained invocation
-
addValueSets
public final ImmutableForm.Builder addValueSets(@Nullable FormValueSet element)
Adds one element tovalueSetslist.- Parameters:
element- A valueSets element- Returns:
thisbuilder for use in a chained invocation
-
addValueSets
public final ImmutableForm.Builder addValueSets(FormValueSet... elements)
Adds elements tovalueSetslist.- Parameters:
elements- An array of valueSets elements- Returns:
thisbuilder for use in a chained invocation
-
valueSets
public final ImmutableForm.Builder valueSets(Iterable<? extends FormValueSet> elements)
Sets or replaces all elements forvalueSetslist.- Parameters:
elements- An iterable of valueSets elements- Returns:
thisbuilder for use in a chained invocation
-
addAllValueSets
public final ImmutableForm.Builder addAllValueSets(Iterable<? extends FormValueSet> elements)
Adds elements tovalueSetslist.- Parameters:
elements- An iterable of valueSets elements- Returns:
thisbuilder for use in a chained invocation
-
putRequiredErrorText
public final ImmutableForm.Builder putRequiredErrorText(String key, String value)
Put one entry to therequiredErrorTextmap.- Parameters:
key- The key in the requiredErrorText mapvalue- The associated value in the requiredErrorText map- Returns:
thisbuilder for use in a chained invocation
-
putRequiredErrorText
public final ImmutableForm.Builder putRequiredErrorText(Map.Entry<String,? extends String> entry)
Put one entry to therequiredErrorTextmap. Nulls are not permitted- Parameters:
entry- The key and value entry- Returns:
thisbuilder for use in a chained invocation
-
requiredErrorText
public final ImmutableForm.Builder requiredErrorText(Map<String,? extends String> entries)
Sets or replaces all mappings from the specified map as entries for therequiredErrorTextmap. Nulls are not permitted- Parameters:
entries- The entries that will be added to the requiredErrorText map- Returns:
thisbuilder for use in a chained invocation
-
putAllRequiredErrorText
public final ImmutableForm.Builder putAllRequiredErrorText(Map<String,? extends String> entries)
Put all mappings from the specified map as entries torequiredErrorTextmap. Nulls are not permitted- Parameters:
entries- The entries that will be added to the requiredErrorText map- Returns:
thisbuilder for use in a chained invocation
-
build
public ImmutableForm build()
Builds a newImmutableForm.- Returns:
- An immutable instance of Form
- Throws:
IllegalStateException- if any required attributes are missing
-
-