Class ImmutableProgram

java.lang.Object
net.bmahe.genetics4j.gp.program.Program
net.bmahe.genetics4j.gp.program.ImmutableProgram

@Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableProgram extends Program
Immutable implementation of Program.

Use the builder to create immutable instances: ImmutableProgram.builder(). Use the static factory method to create immutable instances: ImmutableProgram.of().

  • Field Details

  • Constructor Details

  • Method Details

    • functions

      public Set<OperationFactory> functions()
      Specified by:
      functions in class Program
      Returns:
      The value of the functions attribute
    • terminal

      public Set<OperationFactory> terminal()
      Specified by:
      terminal in class Program
      Returns:
      The value of the terminal attribute
    • inputSpec

      public InputSpec inputSpec()
      Specified by:
      inputSpec in class Program
      Returns:
      The value of the inputSpec attribute
    • maxDepth

      public int maxDepth()
      Specified by:
      maxDepth in class Program
      Returns:
      The value of the maxDepth attribute
    • withFunctions

      public final ImmutableProgram withFunctions(OperationFactory... elements)
      Copy the current immutable object with elements that replace the content of functions.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withFunctions

      public final ImmutableProgram withFunctions(Iterable<? extends OperationFactory> elements)
      Copy the current immutable object with elements that replace the content of functions. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of functions elements to set
      Returns:
      A modified copy of this object
    • withTerminal

      public final ImmutableProgram withTerminal(OperationFactory... elements)
      Copy the current immutable object with elements that replace the content of terminal.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withTerminal

      public final ImmutableProgram withTerminal(Iterable<? extends OperationFactory> elements)
      Copy the current immutable object with elements that replace the content of terminal. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      elements - An iterable of terminal elements to set
      Returns:
      A modified copy of this object
    • withInputSpec

      public final ImmutableProgram withInputSpec(InputSpec value)
      Copy the current immutable object by setting a value for the inputSpec attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for inputSpec
      Returns:
      A modified copy of the this object
    • withMaxDepth

      public final ImmutableProgram withMaxDepth(int value)
      Copy the current immutable object by setting a value for the maxDepth attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for maxDepth
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableProgram that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • equalTo

      private boolean equalTo(int synthetic, ImmutableProgram another)
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: functions, terminal, inputSpec, maxDepth.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value Program with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • of

      public static ImmutableProgram of(Set<OperationFactory> functions, Set<OperationFactory> terminal, InputSpec inputSpec, int maxDepth)
      Construct a new immutable Program instance.
      Parameters:
      functions - The value for the functions attribute
      terminal - The value for the terminal attribute
      inputSpec - The value for the inputSpec attribute
      maxDepth - The value for the maxDepth attribute
      Returns:
      An immutable Program instance
    • of

      public static ImmutableProgram of(Iterable<? extends OperationFactory> functions, Iterable<? extends OperationFactory> terminal, InputSpec inputSpec, int maxDepth)
      Construct a new immutable Program instance.
      Parameters:
      functions - The value for the functions attribute
      terminal - The value for the terminal attribute
      inputSpec - The value for the inputSpec attribute
      maxDepth - The value for the maxDepth attribute
      Returns:
      An immutable Program instance
    • validate

      private static ImmutableProgram validate(ImmutableProgram instance)
    • copyOf

      public static ImmutableProgram copyOf(Program instance)
      Creates an immutable copy of a Program value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable Program instance
    • builder

      public static ImmutableProgram.Builder builder()
      Creates a builder for ImmutableProgram.
       ImmutableProgram.builder()
          .addFunctions|addAllFunctions(net.bmahe.genetics4j.gp.OperationFactory) // functions elements
          .addTerminal|addAllTerminal(net.bmahe.genetics4j.gp.OperationFactory) // terminal elements
          .inputSpec(net.bmahe.genetics4j.gp.InputSpec) // required inputSpec
          .maxDepth(int) // required maxDepth
          .build();
       
      Returns:
      A new ImmutableProgram builder
    • createSafeList

      private static <T> List<T> createSafeList(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls)
    • createUnmodifiableSet

      private static <T> Set<T> createUnmodifiableSet(List<T> list)
      Unmodifiable set constructed from list to avoid rehashing.