Class ImmutableEvolutionResult<T extends Comparable<T>>

java.lang.Object
net.bmahe.genetics4j.core.spec.EvolutionResult<T>
net.bmahe.genetics4j.core.spec.ImmutableEvolutionResult<T>

@Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableEvolutionResult<T extends Comparable<T>> extends EvolutionResult<T>
Immutable implementation of EvolutionResult.

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

  • Field Details

  • Constructor Details

  • Method Details

    • eaConfiguration

      public AbstractEAConfiguration<T> eaConfiguration()
      Specified by:
      eaConfiguration in class EvolutionResult<T extends Comparable<T>>
      Returns:
      The value of the eaConfiguration attribute
    • generation

      public long generation()
      Specified by:
      generation in class EvolutionResult<T extends Comparable<T>>
      Returns:
      The value of the generation attribute
    • population

      public List<Genotype> population()
      Specified by:
      population in class EvolutionResult<T extends Comparable<T>>
      Returns:
      The value of the population attribute
    • fitness

      public List<T> fitness()
      Specified by:
      fitness in class EvolutionResult<T extends Comparable<T>>
      Returns:
      The value of the fitness attribute
    • bestIndividual

      public GenotypeFitness<T> bestIndividual()
      Overrides:
      bestIndividual in class EvolutionResult<T extends Comparable<T>>
      Returns:
      The computed-at-construction value of the bestIndividual attribute
    • withEaConfiguration

      public final ImmutableEvolutionResult<T> withEaConfiguration(AbstractEAConfiguration<T> value)
      Copy the current immutable object by setting a value for the eaConfiguration attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for eaConfiguration
      Returns:
      A modified copy of the this object
    • withGeneration

      public final ImmutableEvolutionResult<T> 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
    • withPopulation

      public final ImmutableEvolutionResult<T> withPopulation(Genotype... elements)
      Copy the current immutable object with elements that replace the content of population.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withPopulation

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

      @SafeVarargs public final ImmutableEvolutionResult<T> withFitness(T... elements)
      Copy the current immutable object with elements that replace the content of fitness.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withFitness

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

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

      public int hashCode()
      Computes a hash code from attributes: eaConfiguration, generation, population, fitness, bestIndividual.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public static <T extends Comparable<T>> ImmutableEvolutionResult<T> of(AbstractEAConfiguration<T> eaConfiguration, long generation, List<Genotype> population, List<T> fitness)
      Construct a new immutable EvolutionResult instance.
      Type Parameters:
      T - generic parameter T
      Parameters:
      eaConfiguration - The value for the eaConfiguration attribute
      generation - The value for the generation attribute
      population - The value for the population attribute
      fitness - The value for the fitness attribute
      Returns:
      An immutable EvolutionResult instance
    • of

      public static <T extends Comparable<T>> ImmutableEvolutionResult<T> of(AbstractEAConfiguration<T> eaConfiguration, long generation, Iterable<? extends Genotype> population, Iterable<? extends T> fitness)
      Construct a new immutable EvolutionResult instance.
      Type Parameters:
      T - generic parameter T
      Parameters:
      eaConfiguration - The value for the eaConfiguration attribute
      generation - The value for the generation attribute
      population - The value for the population attribute
      fitness - The value for the fitness attribute
      Returns:
      An immutable EvolutionResult instance
    • copyOf

      public static <T extends Comparable<T>> ImmutableEvolutionResult<T> copyOf(EvolutionResult<T> instance)
      Creates an immutable copy of a EvolutionResult 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
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable EvolutionResult instance
    • builder

      public static <T extends Comparable<T>> ImmutableEvolutionResult.Builder<T> builder()
      Creates a builder for ImmutableEvolutionResult.
       ImmutableEvolutionResult.&lt;T&gt;builder()
          .eaConfiguration(net.bmahe.genetics4j.core.spec.AbstractEAConfiguration&lt;T&gt;) // required eaConfiguration
          .generation(long) // required generation
          .addPopulation|addAllPopulation(net.bmahe.genetics4j.core.Genotype) // population elements
          .addFitness|addAllFitness(T) // fitness elements
          .build();
       
      Type Parameters:
      T - generic parameter T
      Returns:
      A new ImmutableEvolutionResult builder
    • createSafeList

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

      private static <T> List<T> createUnmodifiableList(boolean clone, List<T> list)