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

java.lang.Object
net.bmahe.genetics4j.extras.evolutionlisteners.CSVEvolutionListener<T,U>
net.bmahe.genetics4j.extras.evolutionlisteners.ImmutableCSVEvolutionListener<T,U>
All Implemented Interfaces:
EvolutionListener<T>

@Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableCSVEvolutionListener<T extends Comparable<T>,U> extends CSVEvolutionListener<T,U>
Immutable implementation of CSVEvolutionListener.

Use the builder to create immutable instances: new CSVEvolutionListener.Builder(). Use the static factory method to create immutable instances: ImmutableCSVEvolutionListener.of().

  • Field Details

  • Constructor Details

  • Method Details

    • autoFlush

      public boolean autoFlush()
      Whether or not the CSV writer has auto flush enabled. Defaults to true<T extends Comparable<T>,U>
      Overrides:
      autoFlush in class CSVEvolutionListener<T extends Comparable<T>,U>
      Returns:
    • evolutionContextSupplier

      public GenerationFunction<T,U> evolutionContextSupplier()
      User defined function to provide some additional information when computing the value to write. Defaults to null
      Overrides:
      evolutionContextSupplier in class CSVEvolutionListener<T extends Comparable<T>,U>
      Returns:
    • skipN

      public int skipN()
      How many generations to skip between each writes. Defaults to writing every generations
      Overrides:
      skipN in class CSVEvolutionListener<T extends Comparable<T>,U>
      Returns:
    • filter

      Users can supply an optional set of filters to control which individuals get written and in which order. Default to have no impact.
      Overrides:
      filter in class CSVEvolutionListener<T extends Comparable<T>,U>
      Returns:
    • filename

      public String filename()
      Destination file name for the CSV file
      Specified by:
      filename in class CSVEvolutionListener<T extends Comparable<T>,U>
      Returns:
    • columnExtractors

      public List<ColumnExtractor<T,U>> columnExtractors()
      List of Column Extractors. They specify how and what to write from each individual at a given generation
      Specified by:
      columnExtractors in class CSVEvolutionListener<T extends Comparable<T>,U>
      Returns:
    • withAutoFlush

      public final ImmutableCSVEvolutionListener<T,U> withAutoFlush(boolean value)
      Copy the current immutable object by setting a value for the autoFlush attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for autoFlush
      Returns:
      A modified copy of the this object
    • withEvolutionContextSupplier

      public final ImmutableCSVEvolutionListener<T,U> withEvolutionContextSupplier(GenerationFunction<T,U> value)
      Copy the current immutable object by setting a value for the evolutionContextSupplier attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for evolutionContextSupplier
      Returns:
      A modified copy of the this object
    • withSkipN

      public final ImmutableCSVEvolutionListener<T,U> withSkipN(int value)
      Copy the current immutable object by setting a value for the skipN attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for skipN
      Returns:
      A modified copy of the this object
    • withFilter

      Copy the current immutable object by setting a value for the filter attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for filter
      Returns:
      A modified copy of the this object
    • withFilename

      public final ImmutableCSVEvolutionListener<T,U> withFilename(String value)
      Copy the current immutable object by setting a value for the filename attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for filename
      Returns:
      A modified copy of the this object
    • withColumnExtractors

      @SafeVarargs public final ImmutableCSVEvolutionListener<T,U> withColumnExtractors(ColumnExtractor<T,U>... elements)
      Copy the current immutable object with elements that replace the content of columnExtractors.
      Parameters:
      elements - The elements to set
      Returns:
      A modified copy of this object
    • withColumnExtractors

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

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

      public int hashCode()
      Computes a hash code from attributes: autoFlush, evolutionContextSupplier, skipN, filter, filename, columnExtractors.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public static <T extends Comparable<T>, U> ImmutableCSVEvolutionListener<T,U> of(String filename, List<ColumnExtractor<T,U>> columnExtractors)
      Construct a new immutable CSVEvolutionListener instance.
      Type Parameters:
      T - generic parameter T
      U - generic parameter U
      Parameters:
      filename - The value for the filename attribute
      columnExtractors - The value for the columnExtractors attribute
      Returns:
      An immutable CSVEvolutionListener instance
    • of

      public static <T extends Comparable<T>, U> ImmutableCSVEvolutionListener<T,U> of(String filename, Iterable<? extends ColumnExtractor<T,U>> columnExtractors)
      Construct a new immutable CSVEvolutionListener instance.
      Type Parameters:
      T - generic parameter T
      U - generic parameter U
      Parameters:
      filename - The value for the filename attribute
      columnExtractors - The value for the columnExtractors attribute
      Returns:
      An immutable CSVEvolutionListener instance
    • copyOf

      public static <T extends Comparable<T>, U> ImmutableCSVEvolutionListener<T,U> copyOf(CSVEvolutionListener<T,U> instance)
      Creates an immutable copy of a CSVEvolutionListener 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
      U - generic parameter U
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable CSVEvolutionListener instance
    • 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)