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(from="CSVEvolutionListener",
generator="Immutables")
@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
Nested ClassesModifier and TypeClassDescriptionstatic classImmutableCSVEvolutionListener.Builder<T extends Comparable<T>,U> Builds instances of typeCSVEvolutionListener.private final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanprivate final List<ColumnExtractor<T, U>> private final GenerationFunction<T, U> private final Stringprivate final Function<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> private ImmutableCSVEvolutionListener<T,U>.InitShim private final intprivate static final byteprivate static final byteprivate static final byteFields inherited from class net.bmahe.genetics4j.extras.evolutionlisteners.CSVEvolutionListener
DEFAULT_AUTO_FLUSH, logger -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableCSVEvolutionListener(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) privateImmutableCSVEvolutionListener(String filename, Iterable<? extends ColumnExtractor<T, U>> columnExtractors) private -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether or not the CSV writer has auto flush enabled.List of Column Extractors.static <T extends Comparable<T>,U>
CSVEvolutionListener<T, U> copyOf(CSVEvolutionListener<T, U> instance) Creates an immutable copy of aCSVEvolutionListenervalue.private static <T> List<T> createSafeList(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls) private static <T> List<T> createUnmodifiableList(boolean clone, List<? extends T> list) booleanThis instance is equal to all instances ofImmutableCSVEvolutionListenerthat have equal attribute values.private booleanequalsByValue(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.inthashCode()Computes a hash code from attributes:autoFlush,evolutionContextSupplier,skipN,filter,filename,columnExtractors.static <T extends Comparable<T>,U>
CSVEvolutionListener<T, U> of(String filename, Iterable<? extends ColumnExtractor<T, U>> columnExtractors) Construct a new immutableCSVEvolutionListenerinstance.static <T extends Comparable<T>,U>
CSVEvolutionListener<T, U> of(String filename, List<ColumnExtractor<T, U>> columnExtractors) Construct a new immutableCSVEvolutionListenerinstance.intskipN()How many generations to skip between each writes.toString()Prints the immutable valueCSVEvolutionListenerwith attribute values.final ImmutableCSVEvolutionListener<T, U> withAutoFlush(boolean value) Copy the current immutable object by setting a value for theautoFlushattribute.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 theevolutionContextSupplierattribute.final ImmutableCSVEvolutionListener<T, U> withFilename(String value) Copy the current immutable object by setting a value for thefilenameattribute.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 thefilterattribute.final ImmutableCSVEvolutionListener<T, U> withSkipN(int value) Copy the current immutable object by setting a value for theskipNattribute.Methods inherited from class net.bmahe.genetics4j.extras.evolutionlisteners.CSVEvolutionListener
of, of, ofTopN, ofTopN, onEvolution, openPrinterMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.bmahe.genetics4j.core.evolutionlisteners.EvolutionListener
postEvaluation, preEvaluation
-
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:
autoFlushin 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:
evolutionContextSupplierin 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:
skipNin 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:
filterin classCSVEvolutionListener<T extends Comparable<T>,U> - Returns:
-
filename
Destination file name for the CSV file- Specified by:
filenamein 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:
columnExtractorsin classCSVEvolutionListener<T extends Comparable<T>,U> - Returns:
-
withAutoFlush
Copy the current immutable object by setting a value for theautoFlushattribute. 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 or the
thisobject
-
withEvolutionContextSupplier
public final ImmutableCSVEvolutionListener<T,U> withEvolutionContextSupplier(GenerationFunction<T, U> value) Copy the current immutable object by setting a value for theevolutionContextSupplierattribute. 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 or the
thisobject
-
withSkipN
Copy the current immutable object by setting a value for theskipNattribute. 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 or the
thisobject
-
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 thefilterattribute. 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 or the
thisobject
-
withFilename
Copy the current immutable object by setting a value for thefilenameattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for filename- Returns:
- A modified copy or the
thisobject
-
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
thisobject
-
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 or
thisif not changed
-
equals
This instance is equal to all instances ofImmutableCSVEvolutionListenerthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:autoFlush,evolutionContextSupplier,skipN,filter,filename,columnExtractors. -
toString
Prints the immutable valueCSVEvolutionListenerwith attribute values. -
of
public static <T extends Comparable<T>,U> CSVEvolutionListener<T,U> of(String filename, List<ColumnExtractor<T, U>> columnExtractors) Construct a new immutableCSVEvolutionListenerinstance.- Type Parameters:
T- generic parameter TU- generic parameter U- Parameters:
filename- The value for thefilenameattributecolumnExtractors- The value for thecolumnExtractorsattribute- Returns:
- An immutable CSVEvolutionListener instance
-
of
public static <T extends Comparable<T>,U> CSVEvolutionListener<T,U> of(String filename, Iterable<? extends ColumnExtractor<T, U>> columnExtractors) Construct a new immutableCSVEvolutionListenerinstance.- Type Parameters:
T- generic parameter TU- generic parameter U- Parameters:
filename- The value for thefilenameattributecolumnExtractors- The value for thecolumnExtractorsattribute- Returns:
- An immutable CSVEvolutionListener instance
-
copyOf
public static <T extends Comparable<T>,U> CSVEvolutionListener<T,U> copyOf(CSVEvolutionListener<T, U> instance) Creates an immutable copy of aCSVEvolutionListenervalue. 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
-