Class ImmutableCSVEvolutionListener.Builder<T extends Comparable<T>,U>

java.lang.Object
net.bmahe.genetics4j.extras.evolutionlisteners.ImmutableCSVEvolutionListener.Builder<T,U>
Direct Known Subclasses:
CSVEvolutionListener.Builder
Enclosing class:
ImmutableCSVEvolutionListener<T extends Comparable<T>,U>

public static class ImmutableCSVEvolutionListener.Builder<T extends Comparable<T>,U> extends Object
Builds instances of type ImmutableCSVEvolutionListener. 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

      public Builder()
      Creates a builder for ImmutableCSVEvolutionListener instances.
       new CSVEvolutionListener.Builder&lt;T, U&gt;()
          .autoFlush(boolean) // optional autoFlush
          .evolutionContextSupplier(net.bmahe.genetics4j.extras.evolutionlisteners.GenerationFunction&lt;T, U&gt;) // optional evolutionContextSupplier
          .skipN(int) // optional skipN
          .filter(function.Function&lt;stream.Stream&lt;net.bmahe.genetics4j.extras.evolutionlisteners.EvolutionStep&lt;T, U&gt;&gt;, stream.Stream&lt;net.bmahe.genetics4j.extras.evolutionlisteners.EvolutionStep&lt;T, U&gt;&gt;&gt;) // optional filter
          .filename(String) // required filename
          .addColumnExtractors|addAllColumnExtractors(net.bmahe.genetics4j.extras.evolutionlisteners.ColumnExtractor&lt;T, U&gt;) // columnExtractors elements
          .build();
       
  • Method Details

    • from

      public final CSVEvolutionListener.Builder<T,U> from(CSVEvolutionListener<T,U> instance)
      Fill a builder with attribute values from the provided CSVEvolutionListener 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
    • autoFlush

      public final CSVEvolutionListener.Builder<T,U> autoFlush(boolean autoFlush)
      Initializes the value for the autoFlush attribute.

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

      Parameters:
      autoFlush - The value for autoFlush
      Returns:
      this builder for use in a chained invocation
    • evolutionContextSupplier

      public final CSVEvolutionListener.Builder<T,U> evolutionContextSupplier(GenerationFunction<T,U> evolutionContextSupplier)
      Initializes the value for the evolutionContextSupplier attribute.

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

      Parameters:
      evolutionContextSupplier - The value for evolutionContextSupplier
      Returns:
      this builder for use in a chained invocation
    • skipN

      public final CSVEvolutionListener.Builder<T,U> skipN(int skipN)
      Initializes the value for the skipN attribute.

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

      Parameters:
      skipN - The value for skipN
      Returns:
      this builder for use in a chained invocation
    • filter

      Initializes the value for the filter attribute.

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

      Parameters:
      filter - The value for filter
      Returns:
      this builder for use in a chained invocation
    • filename

      public final CSVEvolutionListener.Builder<T,U> filename(String filename)
      Initializes the value for the filename attribute.
      Parameters:
      filename - The value for filename
      Returns:
      this builder for use in a chained invocation
    • addColumnExtractors

      public final CSVEvolutionListener.Builder<T,U> addColumnExtractors(ColumnExtractor<T,U> element)
      Adds one element to columnExtractors list.
      Parameters:
      element - A columnExtractors element
      Returns:
      this builder for use in a chained invocation
    • addColumnExtractors

      @SafeVarargs public final CSVEvolutionListener.Builder<T,U> addColumnExtractors(ColumnExtractor<T,U>... elements)
      Adds elements to columnExtractors list.
      Parameters:
      elements - An array of columnExtractors elements
      Returns:
      this builder for use in a chained invocation
    • columnExtractors

      public final CSVEvolutionListener.Builder<T,U> columnExtractors(Iterable<? extends ColumnExtractor<T,U>> elements)
      Sets or replaces all elements for columnExtractors list.
      Parameters:
      elements - An iterable of columnExtractors elements
      Returns:
      this builder for use in a chained invocation
    • addAllColumnExtractors

      public final CSVEvolutionListener.Builder<T,U> addAllColumnExtractors(Iterable<? extends ColumnExtractor<T,U>> elements)
      Adds elements to columnExtractors list.
      Parameters:
      elements - An iterable of columnExtractors elements
      Returns:
      this builder for use in a chained invocation
    • build

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

      private boolean autoFlushIsSet()
    • skipNIsSet

      private boolean skipNIsSet()
    • formatRequiredAttributesMessage

      private String formatRequiredAttributesMessage()