Class ImmutableEvolutionStep<T extends Comparable<T>,U>

java.lang.Object
net.bmahe.genetics4j.extras.evolutionlisteners.ImmutableEvolutionStep<T,U>
All Implemented Interfaces:
EvolutionStep<T,U>

@Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableEvolutionStep<T extends Comparable<T>,U> extends Object implements EvolutionStep<T,U>
Immutable implementation of EvolutionStep.

Use the builder to create immutable instances: new EvolutionStep.Builder(). Use the static factory method to create immutable instances: ImmutableEvolutionStep.of().

  • Field Details

    • context

      private final U context
    • generation

      private final long generation
    • individualIndex

      private final int individualIndex
    • individual

      private final Genotype individual
    • fitness

      private final T extends Comparable<T> fitness
    • isDone

      private final boolean isDone
  • Constructor Details

    • ImmutableEvolutionStep

      private ImmutableEvolutionStep(Optional<? extends U> context, long generation, int individualIndex, Genotype individual, T fitness, boolean isDone)
    • ImmutableEvolutionStep

      private ImmutableEvolutionStep(ImmutableEvolutionStep<T,U> original, U context, long generation, int individualIndex, Genotype individual, T fitness, boolean isDone)
  • Method Details

    • context

      public Optional<U> context()
      Specified by:
      context in interface EvolutionStep<T extends Comparable<T>,U>
      Returns:
      The value of the context attribute
    • generation

      public long generation()
      Specified by:
      generation in interface EvolutionStep<T extends Comparable<T>,U>
      Returns:
      The value of the generation attribute
    • individualIndex

      public int individualIndex()
      Specified by:
      individualIndex in interface EvolutionStep<T extends Comparable<T>,U>
      Returns:
      The value of the individualIndex attribute
    • individual

      public Genotype individual()
      Specified by:
      individual in interface EvolutionStep<T extends Comparable<T>,U>
      Returns:
      The value of the individual attribute
    • fitness

      public T fitness()
      Specified by:
      fitness in interface EvolutionStep<T extends Comparable<T>,U>
      Returns:
      The value of the fitness attribute
    • isDone

      public boolean isDone()
      Specified by:
      isDone in interface EvolutionStep<T extends Comparable<T>,U>
      Returns:
      The value of the isDone attribute
    • withContext

      public final ImmutableEvolutionStep<T,U> withContext(U value)
      Copy the current immutable object by setting a present value for the optional context attribute.
      Parameters:
      value - The value for context
      Returns:
      A modified copy of this object
    • withContext

      public final ImmutableEvolutionStep<T,U> withContext(Optional<? extends U> optional)
      Copy the current immutable object by setting an optional value for the context attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for context
      Returns:
      A modified copy of this object
    • withGeneration

      public final ImmutableEvolutionStep<T,U> withGeneration(long value)
      Copy the current immutable object by setting a value for the generation attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for generation
      Returns:
      A modified copy of the this object
    • withIndividualIndex

      public final ImmutableEvolutionStep<T,U> withIndividualIndex(int value)
      Copy the current immutable object by setting a value for the individualIndex attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for individualIndex
      Returns:
      A modified copy of the this object
    • withIndividual

      public final ImmutableEvolutionStep<T,U> withIndividual(Genotype value)
      Copy the current immutable object by setting a value for the individual attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for individual
      Returns:
      A modified copy of the this object
    • withFitness

      public final ImmutableEvolutionStep<T,U> withFitness(T value)
      Copy the current immutable object by setting a value for the fitness attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for fitness
      Returns:
      A modified copy of the this object
    • withIsDone

      public final ImmutableEvolutionStep<T,U> withIsDone(boolean value)
      Copy the current immutable object by setting a value for the isDone attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for isDone
      Returns:
      A modified copy of the this object
    • equals

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

      public int hashCode()
      Computes a hash code from attributes: context, generation, individualIndex, individual, fitness, isDone.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public static <T extends Comparable<T>, U> ImmutableEvolutionStep<T,U> of(Optional<? extends U> context, long generation, int individualIndex, Genotype individual, T fitness, boolean isDone)
      Construct a new immutable EvolutionStep instance.
      Type Parameters:
      T - generic parameter T
      U - generic parameter U
      Parameters:
      context - The value for the context attribute
      generation - The value for the generation attribute
      individualIndex - The value for the individualIndex attribute
      individual - The value for the individual attribute
      fitness - The value for the fitness attribute
      isDone - The value for the isDone attribute
      Returns:
      An immutable EvolutionStep instance
    • copyOf

      public static <T extends Comparable<T>, U> ImmutableEvolutionStep<T,U> copyOf(EvolutionStep<T,U> instance)
      Creates an immutable copy of a EvolutionStep value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Type Parameters:
      T - generic parameter T
      U - generic parameter U
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable EvolutionStep instance