Class ImmutableEvolutionResult.Builder<T extends Comparable<T>>

java.lang.Object
net.bmahe.genetics4j.core.spec.ImmutableEvolutionResult.Builder<T>
Enclosing class:
ImmutableEvolutionResult<T extends Comparable<T>>

public static final class ImmutableEvolutionResult.Builder<T extends Comparable<T>> extends Object
Builds instances of type ImmutableEvolutionResult. Initialize attributes and then invoke the build() method to create an immutable instance.

Builder is not thread-safe and generally should not be stored in a field or collection, but instead used immediately to create instances.

  • Field Details

  • Constructor Details

    • Builder

      private Builder()
  • Method Details

    • from

      public final ImmutableEvolutionResult.Builder<T> from(EvolutionResult<T> instance)
      Fill a builder with attribute values from the provided EvolutionResult instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values. Collection elements and entries will be added, not replaced.
      Parameters:
      instance - The instance from which to copy values
      Returns:
      this builder for use in a chained invocation
    • eaConfiguration

      public final ImmutableEvolutionResult.Builder<T> eaConfiguration(AbstractEAConfiguration<T> eaConfiguration)
      Initializes the value for the eaConfiguration attribute.
      Parameters:
      eaConfiguration - The value for eaConfiguration
      Returns:
      this builder for use in a chained invocation
    • generation

      public final ImmutableEvolutionResult.Builder<T> generation(long generation)
      Initializes the value for the generation attribute.
      Parameters:
      generation - The value for generation
      Returns:
      this builder for use in a chained invocation
    • addPopulation

      public final ImmutableEvolutionResult.Builder<T> addPopulation(Genotype element)
      Adds one element to population list.
      Parameters:
      element - A population element
      Returns:
      this builder for use in a chained invocation
    • addPopulation

      public final ImmutableEvolutionResult.Builder<T> addPopulation(Genotype... elements)
      Adds elements to population list.
      Parameters:
      elements - An array of population elements
      Returns:
      this builder for use in a chained invocation
    • population

      public final ImmutableEvolutionResult.Builder<T> population(Iterable<? extends Genotype> elements)
      Sets or replaces all elements for population list.
      Parameters:
      elements - An iterable of population elements
      Returns:
      this builder for use in a chained invocation
    • addAllPopulation

      public final ImmutableEvolutionResult.Builder<T> addAllPopulation(Iterable<? extends Genotype> elements)
      Adds elements to population list.
      Parameters:
      elements - An iterable of population elements
      Returns:
      this builder for use in a chained invocation
    • addFitness

      public final ImmutableEvolutionResult.Builder<T> addFitness(T element)
      Adds one element to fitness list.
      Parameters:
      element - A fitness element
      Returns:
      this builder for use in a chained invocation
    • addFitness

      @SafeVarargs public final ImmutableEvolutionResult.Builder<T> addFitness(T... elements)
      Adds elements to fitness list.
      Parameters:
      elements - An array of fitness elements
      Returns:
      this builder for use in a chained invocation
    • fitness

      public final ImmutableEvolutionResult.Builder<T> fitness(Iterable<? extends T> elements)
      Sets or replaces all elements for fitness list.
      Parameters:
      elements - An iterable of fitness elements
      Returns:
      this builder for use in a chained invocation
    • addAllFitness

      public final ImmutableEvolutionResult.Builder<T> addAllFitness(Iterable<? extends T> elements)
      Adds elements to fitness list.
      Parameters:
      elements - An iterable of fitness elements
      Returns:
      this builder for use in a chained invocation
    • build

      public ImmutableEvolutionResult<T> build()
      Returns:
      An immutable instance of EvolutionResult
      Throws:
      IllegalStateException - if any required attributes are missing
    • formatRequiredAttributesMessage

      private String formatRequiredAttributesMessage()