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 type ImmutableForm. Initialize attributes and then invoke the build() method to create an immutable instance.

Builder is not thread-safe and generally should not be stored in a field or collection, but instead used immediately to create instances.

  • Method Details

    • from

      public final ImmutableForm.Builder from(ModifiableForm instance)
      Fill a builder with attribute values from the provided ModifiableForm instance.
      Parameters:
      instance - The instance from which to copy values
      Returns:
      this builder for use in a chained invocation
    • from

      public final ImmutableForm.Builder from(Form instance)
      Fill a builder with attribute values from the provided Form instance. 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:
      this builder for use in a chained invocation
    • id

      public final ImmutableForm.Builder id(String id)
      Initializes the value for the id attribute.
      Parameters:
      id - The value for id (can be null)
      Returns:
      this builder for use in a chained invocation
    • rev

      public final ImmutableForm.Builder rev(String rev)
      Initializes the value for the rev attribute.
      Parameters:
      rev - The value for rev (can be null)
      Returns:
      this builder for use in a chained invocation
    • name

      public final ImmutableForm.Builder name(String name)
      Initializes the value for the name attribute.
      Parameters:
      name - The value for name (can be null)
      Returns:
      this builder for use in a chained invocation
    • putData

      public final ImmutableForm.Builder putData(@Nullable String key, @Nullable FormItem value)
      Put one entry to the data map.
      Parameters:
      key - The key in the data map
      value - The associated value in the data map
      Returns:
      this builder for use in a chained invocation
    • putData

      public final ImmutableForm.Builder putData(Map.Entry<String,? extends FormItem> entry)
      Put one entry to the data map. Nulls are not permitted
      Parameters:
      entry - The key and value entry
      Returns:
      this builder 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 the data map. Nulls are not permitted
      Parameters:
      entries - The entries that will be added to the data map
      Returns:
      this builder 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 to data map. Nulls are not permitted
      Parameters:
      entries - The entries that will be added to the data map
      Returns:
      this builder for use in a chained invocation
    • metadata

      public final ImmutableForm.Builder metadata(Form.Metadata metadata)
      Initializes the value for the metadata attribute.
      Parameters:
      metadata - The value for metadata (can be null)
      Returns:
      this builder for use in a chained invocation
    • addVariables

      public final ImmutableForm.Builder addVariables(@Nullable Variable element)
      Adds one element to variables list.
      Parameters:
      element - A variables element
      Returns:
      this builder for use in a chained invocation
    • addVariables

      public final ImmutableForm.Builder addVariables(Variable... elements)
      Adds elements to variables list.
      Parameters:
      elements - An array of variables elements
      Returns:
      this builder for use in a chained invocation
    • variables

      public final ImmutableForm.Builder variables(Iterable<? extends Variable> elements)
      Sets or replaces all elements for variables list.
      Parameters:
      elements - An iterable of variables elements
      Returns:
      this builder for use in a chained invocation
    • addAllVariables

      public final ImmutableForm.Builder addAllVariables(Iterable<? extends Variable> elements)
      Adds elements to variables list.
      Parameters:
      elements - An iterable of variables elements
      Returns:
      this builder for use in a chained invocation
    • putNamespaces

      public final ImmutableForm.Builder putNamespaces(@Nullable String key, @Nullable Form value)
      Put one entry to the namespaces map.
      Parameters:
      key - The key in the namespaces map
      value - The associated value in the namespaces map
      Returns:
      this builder for use in a chained invocation
    • putNamespaces

      public final ImmutableForm.Builder putNamespaces(Map.Entry<String,? extends Form> entry)
      Put one entry to the namespaces map. Nulls are not permitted
      Parameters:
      entry - The key and value entry
      Returns:
      this builder 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 the namespaces map. Nulls are not permitted
      Parameters:
      entries - The entries that will be added to the namespaces map
      Returns:
      this builder 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 to namespaces map. Nulls are not permitted
      Parameters:
      entries - The entries that will be added to the namespaces map
      Returns:
      this builder for use in a chained invocation
    • addValueSets

      public final ImmutableForm.Builder addValueSets(@Nullable FormValueSet element)
      Adds one element to valueSets list.
      Parameters:
      element - A valueSets element
      Returns:
      this builder for use in a chained invocation
    • addValueSets

      public final ImmutableForm.Builder addValueSets(FormValueSet... elements)
      Adds elements to valueSets list.
      Parameters:
      elements - An array of valueSets elements
      Returns:
      this builder for use in a chained invocation
    • valueSets

      public final ImmutableForm.Builder valueSets(Iterable<? extends FormValueSet> elements)
      Sets or replaces all elements for valueSets list.
      Parameters:
      elements - An iterable of valueSets elements
      Returns:
      this builder for use in a chained invocation
    • addAllValueSets

      public final ImmutableForm.Builder addAllValueSets(Iterable<? extends FormValueSet> elements)
      Adds elements to valueSets list.
      Parameters:
      elements - An iterable of valueSets elements
      Returns:
      this builder for use in a chained invocation
    • putRequiredErrorText

      public final ImmutableForm.Builder putRequiredErrorText(@Nullable String key, @Nullable String value)
      Put one entry to the requiredErrorText map.
      Parameters:
      key - The key in the requiredErrorText map
      value - The associated value in the requiredErrorText map
      Returns:
      this builder for use in a chained invocation
    • putRequiredErrorText

      public final ImmutableForm.Builder putRequiredErrorText(Map.Entry<String,? extends String> entry)
      Put one entry to the requiredErrorText map. Nulls are not permitted
      Parameters:
      entry - The key and value entry
      Returns:
      this builder 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 the requiredErrorText map. Nulls are not permitted
      Parameters:
      entries - The entries that will be added to the requiredErrorText map
      Returns:
      this builder 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 to requiredErrorText map. Nulls are not permitted
      Parameters:
      entries - The entries that will be added to the requiredErrorText map
      Returns:
      this builder for use in a chained invocation
    • build

      public ImmutableForm build()
      Builds a new ImmutableForm.
      Returns:
      An immutable instance of Form
      Throws:
      IllegalStateException - if any required attributes are missing