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>
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 Summary
Modifier and TypeFieldDescriptionprivate boolean
private List
<ColumnExtractor<T, U>> private GenerationFunction
<T, U> private String
private Function
<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> private static final long
private long
private static final long
private static final long
private long
private int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal CSVEvolutionListener.Builder
<T, U> addAllColumnExtractors
(Iterable<? extends ColumnExtractor<T, U>> elements) Adds elements tocolumnExtractors
list.final CSVEvolutionListener.Builder
<T, U> addColumnExtractors
(ColumnExtractor<T, U> element) Adds one element tocolumnExtractors
list.final CSVEvolutionListener.Builder
<T, U> addColumnExtractors
(ColumnExtractor<T, U>... elements) Adds elements tocolumnExtractors
list.final CSVEvolutionListener.Builder
<T, U> autoFlush
(boolean autoFlush) Initializes the value for theautoFlush
attribute.private boolean
build()
Builds a newImmutableCSVEvolutionListener
.final CSVEvolutionListener.Builder
<T, U> columnExtractors
(Iterable<? extends ColumnExtractor<T, U>> elements) Sets or replaces all elements forcolumnExtractors
list.final CSVEvolutionListener.Builder
<T, U> evolutionContextSupplier
(GenerationFunction<T, U> evolutionContextSupplier) Initializes the value for theevolutionContextSupplier
attribute.final CSVEvolutionListener.Builder
<T, U> Initializes the value for thefilename
attribute.final CSVEvolutionListener.Builder
<T, U> filter
(Function<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> filter) Initializes the value for thefilter
attribute.private String
final CSVEvolutionListener.Builder
<T, U> from
(CSVEvolutionListener<T, U> instance) Fill a builder with attribute values from the providedCSVEvolutionListener
instance.final CSVEvolutionListener.Builder
<T, U> skipN
(int skipN) Initializes the value for theskipN
attribute.private boolean
-
Field Details
-
INIT_BIT_FILENAME
private static final long INIT_BIT_FILENAME- See Also:
-
OPT_BIT_AUTO_FLUSH
private static final long OPT_BIT_AUTO_FLUSH- See Also:
-
OPT_BIT_SKIP_N
private static final long OPT_BIT_SKIP_N- See Also:
-
initBits
private long initBits -
optBits
private long optBits -
autoFlush
private boolean autoFlush -
evolutionContextSupplier
-
skipN
private int skipN -
filter
private Function<Stream<EvolutionStep<T extends Comparable<T>,U>>, filterStream<EvolutionStep<T extends Comparable<T>, U>>> -
filename
-
columnExtractors
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forImmutableCSVEvolutionListener
instances.new CSVEvolutionListener.Builder<T, U>() .autoFlush(boolean) // optional
autoFlush
.evolutionContextSupplier(net.bmahe.genetics4j.extras.evolutionlisteners.GenerationFunction<T, U>) // optionalevolutionContextSupplier
.skipN(int) // optionalskipN
.filter(function.Function<stream.Stream<net.bmahe.genetics4j.extras.evolutionlisteners.EvolutionStep<T, U>>, stream.Stream<net.bmahe.genetics4j.extras.evolutionlisteners.EvolutionStep<T, U>>>) // optionalfilter
.filename(String) // requiredfilename
.addColumnExtractors|addAllColumnExtractors(net.bmahe.genetics4j.extras.evolutionlisteners.ColumnExtractor<T, U>) //columnExtractors
elements .build();
-
-
Method Details
-
from
Fill a builder with attribute values from the providedCSVEvolutionListener
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
Initializes the value for theautoFlush
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 theevolutionContextSupplier
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
Initializes the value for theskipN
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
public final CSVEvolutionListener.Builder<T,U> filter(Function<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> filter) Initializes the value for thefilter
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
Initializes the value for thefilename
attribute.- Parameters:
filename
- The value for filename- Returns:
this
builder for use in a chained invocation
-
addColumnExtractors
Adds one element tocolumnExtractors
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 tocolumnExtractors
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 forcolumnExtractors
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 tocolumnExtractors
list.- Parameters:
elements
- An iterable of columnExtractors elements- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableCSVEvolutionListener
.- Returns:
- An immutable instance of CSVEvolutionListener
- Throws:
IllegalStateException
- if any required attributes are missing
-
autoFlushIsSet
private boolean autoFlushIsSet() -
skipNIsSet
private boolean skipNIsSet() -
formatRequiredAttributesMessage
-