Class ImmutableSwapMutation

java.lang.Object
net.bmahe.genetics4j.core.spec.mutation.SwapMutation
net.bmahe.genetics4j.core.spec.mutation.ImmutableSwapMutation
All Implemented Interfaces:
MutationPolicy

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

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

  • Field Details

    • populationMutationProbability

      private final double populationMutationProbability
    • numSwap

      private final int numSwap
    • isNumSwapFixed

      private final boolean isNumSwapFixed
  • Constructor Details

    • ImmutableSwapMutation

      private ImmutableSwapMutation(double populationMutationProbability, int numSwap, boolean isNumSwapFixed)
  • Method Details

    • populationMutationProbability

      public double populationMutationProbability()
      Specified by:
      populationMutationProbability in class SwapMutation
      Returns:
      The value of the populationMutationProbability attribute
    • numSwap

      public int numSwap()
      Specified by:
      numSwap in class SwapMutation
      Returns:
      The value of the numSwap attribute
    • isNumSwapFixed

      public boolean isNumSwapFixed()
      Specified by:
      isNumSwapFixed in class SwapMutation
      Returns:
      The value of the isNumSwapFixed attribute
    • withPopulationMutationProbability

      public final ImmutableSwapMutation withPopulationMutationProbability(double value)
      Copy the current immutable object by setting a value for the populationMutationProbability attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for populationMutationProbability
      Returns:
      A modified copy of the this object
    • withNumSwap

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

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

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableSwapMutation 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, ImmutableSwapMutation another)
    • hashCode

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

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

      public static ImmutableSwapMutation of(double populationMutationProbability, int numSwap, boolean isNumSwapFixed)
      Construct a new immutable SwapMutation instance.
      Parameters:
      populationMutationProbability - The value for the populationMutationProbability attribute
      numSwap - The value for the numSwap attribute
      isNumSwapFixed - The value for the isNumSwapFixed attribute
      Returns:
      An immutable SwapMutation instance
    • validate

      private static ImmutableSwapMutation validate(ImmutableSwapMutation instance)
    • copyOf

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

      public static ImmutableSwapMutation.Builder builder()
      Creates a builder for ImmutableSwapMutation.
       ImmutableSwapMutation.builder()
          .populationMutationProbability(double) // required populationMutationProbability
          .numSwap(int) // required numSwap
          .isNumSwapFixed(boolean) // required isNumSwapFixed
          .build();
       
      Returns:
      A new ImmutableSwapMutation builder