Class ImmutableInputSpec.Builder

java.lang.Object
net.bmahe.genetics4j.gp.ImmutableInputSpec.Builder
Enclosing class:
ImmutableInputSpec

public static final class ImmutableInputSpec.Builder extends Object
Builds instances of type ImmutableInputSpec. 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.

  • Field Details

  • Constructor Details

    • Builder

      private Builder()
  • Method Details

    • from

      public final ImmutableInputSpec.Builder from(InputSpec instance)
      Fill a builder with attribute values from the provided InputSpec 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
    • addTypes

      public final ImmutableInputSpec.Builder addTypes(Class element)
      Adds one element to types list.
      Parameters:
      element - A types element
      Returns:
      this builder for use in a chained invocation
    • addTypes

      public final ImmutableInputSpec.Builder addTypes(Class... elements)
      Adds elements to types list.
      Parameters:
      elements - An array of types elements
      Returns:
      this builder for use in a chained invocation
    • types

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

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

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