Class ImmutableElitism.Builder

java.lang.Object
net.bmahe.genetics4j.core.spec.replacement.ImmutableElitism.Builder
Direct Known Subclasses:
Elitism.Builder
Enclosing class:
ImmutableElitism

public static class ImmutableElitism.Builder extends Object
Builds instances of type ImmutableElitism. 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

    • INIT_BIT_OFFSPRING_SELECTION_POLICY

      private static final long INIT_BIT_OFFSPRING_SELECTION_POLICY
      See Also:
    • INIT_BIT_SURVIVOR_SELECTION_POLICY

      private static final long INIT_BIT_SURVIVOR_SELECTION_POLICY
      See Also:
    • OPT_BIT_AT_LEAST_NUM_OFFSPRINGS

      private static final long OPT_BIT_AT_LEAST_NUM_OFFSPRINGS
      See Also:
    • OPT_BIT_AT_LEAST_NUM_SURVIVORS

      private static final long OPT_BIT_AT_LEAST_NUM_SURVIVORS
      See Also:
    • OPT_BIT_OFFSPRING_RATIO

      private static final long OPT_BIT_OFFSPRING_RATIO
      See Also:
    • initBits

      private long initBits
    • optBits

      private long optBits
    • offspringSelectionPolicy

      private SelectionPolicy offspringSelectionPolicy
    • atLeastNumOffsprings

      private int atLeastNumOffsprings
    • survivorSelectionPolicy

      private SelectionPolicy survivorSelectionPolicy
    • atLeastNumSurvivors

      private int atLeastNumSurvivors
    • offspringRatio

      private double offspringRatio
  • Constructor Details

  • Method Details

    • from

      public final Elitism.Builder from(Elitism instance)
      Fill a builder with attribute values from the provided Elitism instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values.
      Parameters:
      instance - The instance from which to copy values
      Returns:
      this builder for use in a chained invocation
    • offspringSelectionPolicy

      public final Elitism.Builder offspringSelectionPolicy(SelectionPolicy offspringSelectionPolicy)
      Initializes the value for the offspringSelectionPolicy attribute.
      Parameters:
      offspringSelectionPolicy - The value for offspringSelectionPolicy
      Returns:
      this builder for use in a chained invocation
    • atLeastNumOffsprings

      public final Elitism.Builder atLeastNumOffsprings(int atLeastNumOffsprings)
      Initializes the value for the atLeastNumOffsprings attribute.

      If not set, this attribute will have a default value as returned by the initializer of atLeastNumOffsprings.

      Parameters:
      atLeastNumOffsprings - The value for atLeastNumOffsprings
      Returns:
      this builder for use in a chained invocation
    • survivorSelectionPolicy

      public final Elitism.Builder survivorSelectionPolicy(SelectionPolicy survivorSelectionPolicy)
      Initializes the value for the survivorSelectionPolicy attribute.
      Parameters:
      survivorSelectionPolicy - The value for survivorSelectionPolicy
      Returns:
      this builder for use in a chained invocation
    • atLeastNumSurvivors

      public final Elitism.Builder atLeastNumSurvivors(int atLeastNumSurvivors)
      Initializes the value for the atLeastNumSurvivors attribute.

      If not set, this attribute will have a default value as returned by the initializer of atLeastNumSurvivors.

      Parameters:
      atLeastNumSurvivors - The value for atLeastNumSurvivors
      Returns:
      this builder for use in a chained invocation
    • offspringRatio

      public final Elitism.Builder offspringRatio(double offspringRatio)
      Initializes the value for the offspringRatio attribute.

      If not set, this attribute will have a default value as returned by the initializer of offspringRatio.

      Parameters:
      offspringRatio - The value for offspringRatio
      Returns:
      this builder for use in a chained invocation
    • build

      public ImmutableElitism build()
      Builds a new ImmutableElitism.
      Returns:
      An immutable instance of Elitism
      Throws:
      IllegalStateException - if any required attributes are missing
    • atLeastNumOffspringsIsSet

      private boolean atLeastNumOffspringsIsSet()
    • atLeastNumSurvivorsIsSet

      private boolean atLeastNumSurvivorsIsSet()
    • offspringRatioIsSet

      private boolean offspringRatioIsSet()
    • formatRequiredAttributesMessage

      private String formatRequiredAttributesMessage()