Class ImmutableDoubleChromosomeSpec.Builder

java.lang.Object
net.bmahe.genetics4j.core.spec.chromosome.ImmutableDoubleChromosomeSpec.Builder
Direct Known Subclasses:
DoubleChromosomeSpec.Builder
Enclosing class:
ImmutableDoubleChromosomeSpec

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

      private static final long INIT_BIT_SIZE
      See Also:
    • INIT_BIT_MIN_VALUE

      private static final long INIT_BIT_MIN_VALUE
      See Also:
    • INIT_BIT_MAX_VALUE

      private static final long INIT_BIT_MAX_VALUE
      See Also:
    • initBits

      private long initBits
    • size

      private int size
    • minValue

      private double minValue
    • maxValue

      private double maxValue
    • distribution

      private Distribution distribution
  • Constructor Details

    • Builder

      public Builder()
      Creates a builder for ImmutableDoubleChromosomeSpec instances.
       new DoubleChromosomeSpec.Builder()
          .size(int) // required size
          .minValue(double) // required minValue
          .maxValue(double) // required maxValue
          .distribution(net.bmahe.genetics4j.core.spec.statistics.distributions.Distribution) // optional distribution
          .build();
       
  • Method Details

    • from

      public final DoubleChromosomeSpec.Builder from(DoubleChromosomeSpec instance)
      Fill a builder with attribute values from the provided DoubleChromosomeSpec 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
    • size

      public final DoubleChromosomeSpec.Builder size(int size)
      Initializes the value for the size attribute.
      Parameters:
      size - The value for size
      Returns:
      this builder for use in a chained invocation
    • minValue

      public final DoubleChromosomeSpec.Builder minValue(double minValue)
      Initializes the value for the minValue attribute.
      Parameters:
      minValue - The value for minValue
      Returns:
      this builder for use in a chained invocation
    • maxValue

      public final DoubleChromosomeSpec.Builder maxValue(double maxValue)
      Initializes the value for the maxValue attribute.
      Parameters:
      maxValue - The value for maxValue
      Returns:
      this builder for use in a chained invocation
    • distribution

      public final DoubleChromosomeSpec.Builder distribution(Distribution distribution)
      Initializes the value for the distribution attribute.

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

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

      Returns:
      An immutable instance of DoubleChromosomeSpec
      Throws:
      IllegalStateException - if any required attributes are missing
    • formatRequiredAttributesMessage

      private String formatRequiredAttributesMessage()