Class ImmutableProgram.Builder

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

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

      public final ImmutableProgram.Builder addFunctions(OperationFactory element)
      Adds one element to functions set.
      Parameters:
      element - A functions element
      Returns:
      this builder for use in a chained invocation
    • addFunctions

      public final ImmutableProgram.Builder addFunctions(OperationFactory... elements)
      Adds elements to functions set.
      Parameters:
      elements - An array of functions elements
      Returns:
      this builder for use in a chained invocation
    • functions

      public final ImmutableProgram.Builder functions(Iterable<? extends OperationFactory> elements)
      Sets or replaces all elements for functions set.
      Parameters:
      elements - An iterable of functions elements
      Returns:
      this builder for use in a chained invocation
    • addAllFunctions

      public final ImmutableProgram.Builder addAllFunctions(Iterable<? extends OperationFactory> elements)
      Adds elements to functions set.
      Parameters:
      elements - An iterable of functions elements
      Returns:
      this builder for use in a chained invocation
    • addTerminal

      public final ImmutableProgram.Builder addTerminal(OperationFactory element)
      Adds one element to terminal set.
      Parameters:
      element - A terminal element
      Returns:
      this builder for use in a chained invocation
    • addTerminal

      public final ImmutableProgram.Builder addTerminal(OperationFactory... elements)
      Adds elements to terminal set.
      Parameters:
      elements - An array of terminal elements
      Returns:
      this builder for use in a chained invocation
    • terminal

      public final ImmutableProgram.Builder terminal(Iterable<? extends OperationFactory> elements)
      Sets or replaces all elements for terminal set.
      Parameters:
      elements - An iterable of terminal elements
      Returns:
      this builder for use in a chained invocation
    • addAllTerminal

      public final ImmutableProgram.Builder addAllTerminal(Iterable<? extends OperationFactory> elements)
      Adds elements to terminal set.
      Parameters:
      elements - An iterable of terminal elements
      Returns:
      this builder for use in a chained invocation
    • inputSpec

      public final ImmutableProgram.Builder inputSpec(InputSpec inputSpec)
      Initializes the value for the inputSpec attribute.
      Parameters:
      inputSpec - The value for inputSpec
      Returns:
      this builder for use in a chained invocation
    • maxDepth

      public final ImmutableProgram.Builder maxDepth(int maxDepth)
      Initializes the value for the maxDepth attribute.
      Parameters:
      maxDepth - The value for maxDepth
      Returns:
      this builder for use in a chained invocation
    • build

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

      private String formatRequiredAttributesMessage()