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()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ImmutableCSVEvolutionListener.Builder<T extends Comparable<T>,
U> Builds instances of typeImmutableCSVEvolutionListener
.private final class
-
Field Summary
Modifier and TypeFieldDescriptionprivate final boolean
private final List
<ColumnExtractor<T, U>> private final GenerationFunction
<T, U> private final String
private final Function
<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> private ImmutableCSVEvolutionListener<T,
U>.InitShim private final int
private static final byte
private static final byte
private static final byte
Fields inherited from class net.bmahe.genetics4j.extras.evolutionlisteners.CSVEvolutionListener
DEFAULT_AUTO_FLUSH, logger
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableCSVEvolutionListener
(boolean autoFlush, GenerationFunction<T, U> evolutionContextSupplier, int skipN, Function<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> filter, String filename, List<ColumnExtractor<T, U>> columnExtractors) private
ImmutableCSVEvolutionListener
(String filename, Iterable<? extends ColumnExtractor<T, U>> columnExtractors) private
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether or not the CSV writer has auto flush enabled.List of Column Extractors.static <T extends Comparable<T>,
U>
ImmutableCSVEvolutionListener<T, U> copyOf
(CSVEvolutionListener<T, U> instance) Creates an immutable copy of aCSVEvolutionListener
value.private static <T> List
<T> createSafeList
(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls) private static <T> List
<T> createUnmodifiableList
(boolean clone, List<T> list) boolean
This instance is equal to all instances ofImmutableCSVEvolutionListener
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableCSVEvolutionListener<?, ?> another) User defined function to provide some additional information when computing the value to write.filename()
Destination file name for the CSV fileFunction
<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> filter()
Users can supply an optional set of filters to control which individuals get written and in which order.int
hashCode()
Computes a hash code from attributes:autoFlush
,evolutionContextSupplier
,skipN
,filter
,filename
,columnExtractors
.static <T extends Comparable<T>,
U>
ImmutableCSVEvolutionListener<T, U> of
(String filename, Iterable<? extends ColumnExtractor<T, U>> columnExtractors) Construct a new immutableCSVEvolutionListener
instance.static <T extends Comparable<T>,
U>
ImmutableCSVEvolutionListener<T, U> of
(String filename, List<ColumnExtractor<T, U>> columnExtractors) Construct a new immutableCSVEvolutionListener
instance.int
skipN()
How many generations to skip between each writes.toString()
Prints the immutable valueCSVEvolutionListener
with attribute values.final ImmutableCSVEvolutionListener
<T, U> withAutoFlush
(boolean value) Copy the current immutable object by setting a value for theautoFlush
attribute.final ImmutableCSVEvolutionListener
<T, U> withColumnExtractors
(Iterable<? extends ColumnExtractor<T, U>> elements) Copy the current immutable object with elements that replace the content ofcolumnExtractors
.final ImmutableCSVEvolutionListener
<T, U> withColumnExtractors
(ColumnExtractor<T, U>... elements) Copy the current immutable object with elements that replace the content ofcolumnExtractors
.final ImmutableCSVEvolutionListener
<T, U> Copy the current immutable object by setting a value for theevolutionContextSupplier
attribute.final ImmutableCSVEvolutionListener
<T, U> withFilename
(String value) Copy the current immutable object by setting a value for thefilename
attribute.final ImmutableCSVEvolutionListener
<T, U> withFilter
(Function<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> value) Copy the current immutable object by setting a value for thefilter
attribute.final ImmutableCSVEvolutionListener
<T, U> withSkipN
(int value) Copy the current immutable object by setting a value for theskipN
attribute.Methods inherited from class net.bmahe.genetics4j.extras.evolutionlisteners.CSVEvolutionListener
of, of, ofTopN, ofTopN, onEvolution, openPrinter
-
Field Details
-
autoFlush
private final boolean autoFlush -
evolutionContextSupplier
-
skipN
private final int skipN -
filter
private final Function<Stream<EvolutionStep<T extends Comparable<T>,U>>, filterStream<EvolutionStep<T extends Comparable<T>, U>>> -
filename
-
columnExtractors
-
STAGE_INITIALIZING
private static final byte STAGE_INITIALIZING- See Also:
-
STAGE_UNINITIALIZED
private static final byte STAGE_UNINITIALIZED- See Also:
-
STAGE_INITIALIZED
private static final byte STAGE_INITIALIZED- See Also:
-
initShim
private transient volatile ImmutableCSVEvolutionListener<T extends Comparable<T>,U>.InitShim initShim
-
-
Constructor Details
-
ImmutableCSVEvolutionListener
private ImmutableCSVEvolutionListener(String filename, Iterable<? extends ColumnExtractor<T, U>> columnExtractors) -
ImmutableCSVEvolutionListener
-
ImmutableCSVEvolutionListener
private ImmutableCSVEvolutionListener(boolean autoFlush, GenerationFunction<T, U> evolutionContextSupplier, int skipN, Function<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> filter, String filename, List<ColumnExtractor<T, U>> columnExtractors)
-
-
Method Details
-
autoFlush
public boolean autoFlush()- Overrides:
autoFlush
in classCSVEvolutionListener<T extends Comparable<T>,
U> - Returns:
-
evolutionContextSupplier
User defined function to provide some additional information when computing the value to write. Defaults to null- Overrides:
evolutionContextSupplier
in classCSVEvolutionListener<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 classCSVEvolutionListener<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 classCSVEvolutionListener<T extends Comparable<T>,
U> - Returns:
-
filename
Destination file name for the CSV file- Specified by:
filename
in classCSVEvolutionListener<T extends Comparable<T>,
U> - Returns:
-
columnExtractors
List of Column Extractors. They specify how and what to write from each individual at a given generation- Specified by:
columnExtractors
in classCSVEvolutionListener<T extends Comparable<T>,
U> - Returns:
-
withAutoFlush
Copy the current immutable object by setting a value for theautoFlush
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- 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 theevolutionContextSupplier
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for evolutionContextSupplier- Returns:
- A modified copy of the
this
object
-
withSkipN
Copy the current immutable object by setting a value for theskipN
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for skipN- Returns:
- A modified copy of the
this
object
-
withFilter
public final ImmutableCSVEvolutionListener<T,U> withFilter(Function<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> value) Copy the current immutable object by setting a value for thefilter
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for filter- Returns:
- A modified copy of the
this
object
-
withFilename
Copy the current immutable object by setting a value for thefilename
attribute. An equals check used to prevent copying of the same value by returningthis
.- 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 ofcolumnExtractors
.- 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 ofcolumnExtractors
. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
elements
- An iterable of columnExtractors elements to set- Returns:
- A modified copy of
this
object
-
equals
This instance is equal to all instances ofImmutableCSVEvolutionListener
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:autoFlush
,evolutionContextSupplier
,skipN
,filter
,filename
,columnExtractors
. -
toString
Prints the immutable valueCSVEvolutionListener
with attribute values. -
of
public static <T extends Comparable<T>,U> ImmutableCSVEvolutionListener<T,U> of(String filename, List<ColumnExtractor<T, U>> columnExtractors) Construct a new immutableCSVEvolutionListener
instance.- Type Parameters:
T
- generic parameter TU
- generic parameter U- Parameters:
filename
- The value for thefilename
attributecolumnExtractors
- The value for thecolumnExtractors
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 immutableCSVEvolutionListener
instance.- Type Parameters:
T
- generic parameter TU
- generic parameter U- Parameters:
filename
- The value for thefilename
attributecolumnExtractors
- The value for thecolumnExtractors
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 aCSVEvolutionListener
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 TU
- generic parameter U- Parameters:
instance
- The instance to copy- Returns:
- A copied immutable CSVEvolutionListener instance
-
createSafeList
-
createUnmodifiableList
-