Class MManifest.Builder

java.lang.Object
com.io7m.montarre.api.MManifest.Builder
Enclosing class:
MManifest

public static final class MManifest.Builder extends Object
Builds instances of type MManifest. 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 MManifest.Builder from(MManifestType instance)
      Fill a builder with attribute values from the provided MManifestType 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
    • addItems

      public final MManifest.Builder addItems(MManifestItemType element)
      Adds one element to items list.
      Parameters:
      element - A items element
      Returns:
      this builder for use in a chained invocation
    • addItems

      public final MManifest.Builder addItems(MManifestItemType... elements)
      Adds elements to items list.
      Parameters:
      elements - An array of items elements
      Returns:
      this builder for use in a chained invocation
    • setItems

      public final MManifest.Builder setItems(Iterable<? extends MManifestItemType> elements)
      Sets or replaces all elements for items list.
      Parameters:
      elements - An iterable of items elements
      Returns:
      this builder for use in a chained invocation
    • addAllItems

      public final MManifest.Builder addAllItems(Iterable<? extends MManifestItemType> elements)
      Adds elements to items list.
      Parameters:
      elements - An iterable of items elements
      Returns:
      this builder for use in a chained invocation
    • build

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