Class ImmutableTrimTree

java.lang.Object
net.bmahe.genetics4j.gp.spec.mutation.ImmutableTrimTree
All Implemented Interfaces:
MutationPolicy, TrimTree

@Generated(from="TrimTree", generator="Immutables") @Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableTrimTree extends Object implements TrimTree
Immutable implementation of TrimTree.

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

  • Field Details

    • maxDepth

      private final Integer maxDepth
  • Constructor Details

  • Method Details

    • maxDepth

      public Optional<Integer> maxDepth()
      Override the max depth to enforce
      Specified by:
      maxDepth in interface TrimTree
      Returns:
    • withMaxDepth

      public final ImmutableTrimTree withMaxDepth(int value)
      Copy the current immutable object by setting a present value for the optional maxDepth attribute.
      Parameters:
      value - The value for maxDepth
      Returns:
      A modified copy or this if not changed
    • withMaxDepth

      public final ImmutableTrimTree withMaxDepth(Optional<Integer> optional)
      Copy the current immutable object by setting an optional value for the maxDepth attribute. An equality check is used on inner value to prevent copying of the same value by returning this.
      Parameters:
      optional - An optional value for maxDepth
      Returns:
      A modified copy or this if not changed
    • equals

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

      private boolean equalsByValue(ImmutableTrimTree another)
    • hashCode

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

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

      public static ImmutableTrimTree of(Optional<Integer> maxDepth)
      Construct a new immutable TrimTree instance.
      Parameters:
      maxDepth - The value for the maxDepth attribute
      Returns:
      An immutable TrimTree instance
    • validate

      private static ImmutableTrimTree validate(ImmutableTrimTree instance)
    • copyOf

      public static ImmutableTrimTree copyOf(TrimTree instance)
      Creates an immutable copy of a TrimTree 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 TrimTree instance
    • builder

      public static ImmutableTrimTree.Builder builder()
      Creates a builder for ImmutableTrimTree.
       ImmutableTrimTree.builder()
          .maxDepth(Optional<Integer>) // optional maxDepth
          .build();
       
      Returns:
      A new ImmutableTrimTree builder