Class ImmutableEvolutionStep.Builder<T extends Comparable<T>,U>
java.lang.Object
net.bmahe.genetics4j.extras.evolutionlisteners.ImmutableEvolutionStep.Builder<T,U>
- Direct Known Subclasses:
EvolutionStep.Builder
- Enclosing class:
ImmutableEvolutionStep<T extends Comparable<T>,
U>
Builds instances of type
ImmutableEvolutionStep
.
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newImmutableEvolutionStep
.final EvolutionStep.Builder
<T, U> Initializes the optional valuecontext
to context.final EvolutionStep.Builder
<T, U> Initializes the optional valuecontext
to context.final EvolutionStep.Builder
<T, U> Initializes the value for thefitness
attribute.private String
final EvolutionStep.Builder
<T, U> from
(EvolutionStep<T, U> instance) Fill a builder with attribute values from the providedEvolutionStep
instance.final EvolutionStep.Builder
<T, U> generation
(long generation) Initializes the value for thegeneration
attribute.final EvolutionStep.Builder
<T, U> individual
(Genotype individual) Initializes the value for theindividual
attribute.final EvolutionStep.Builder
<T, U> individualIndex
(int individualIndex) Initializes the value for theindividualIndex
attribute.final EvolutionStep.Builder
<T, U> isDone
(boolean isDone) Initializes the value for theisDone
attribute.
-
Field Details
-
INIT_BIT_GENERATION
private static final long INIT_BIT_GENERATION- See Also:
-
INIT_BIT_INDIVIDUAL_INDEX
private static final long INIT_BIT_INDIVIDUAL_INDEX- See Also:
-
INIT_BIT_INDIVIDUAL
private static final long INIT_BIT_INDIVIDUAL- See Also:
-
INIT_BIT_FITNESS
private static final long INIT_BIT_FITNESS- See Also:
-
INIT_BIT_IS_DONE
private static final long INIT_BIT_IS_DONE- See Also:
-
initBits
private long initBits -
context
-
generation
private long generation -
individualIndex
private int individualIndex -
individual
-
fitness
-
isDone
private boolean isDone
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forImmutableEvolutionStep
instances.new EvolutionStep.Builder<T, U>() .context(U) // optional
context
.generation(long) // requiredgeneration
.individualIndex(int) // requiredindividualIndex
.individual(net.bmahe.genetics4j.core.Genotype) // requiredindividual
.fitness(T) // requiredfitness
.isDone(boolean) // requiredisDone
.build();
-
-
Method Details
-
from
Fill a builder with attribute values from the providedEvolutionStep
instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values.- Parameters:
instance
- The instance from which to copy values- Returns:
this
builder for use in a chained invocation
-
context
Initializes the optional valuecontext
to context.- Parameters:
context
- The value for context- Returns:
this
builder for chained invocation
-
context
Initializes the optional valuecontext
to context.- Parameters:
context
- The value for context- Returns:
this
builder for use in a chained invocation
-
generation
Initializes the value for thegeneration
attribute.- Parameters:
generation
- The value for generation- Returns:
this
builder for use in a chained invocation
-
individualIndex
Initializes the value for theindividualIndex
attribute.- Parameters:
individualIndex
- The value for individualIndex- Returns:
this
builder for use in a chained invocation
-
individual
Initializes the value for theindividual
attribute.- Parameters:
individual
- The value for individual- Returns:
this
builder for use in a chained invocation
-
fitness
Initializes the value for thefitness
attribute.- Parameters:
fitness
- The value for fitness- Returns:
this
builder for use in a chained invocation
-
isDone
Initializes the value for theisDone
attribute.- Parameters:
isDone
- The value for isDone- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableEvolutionStep
.- Returns:
- An immutable instance of EvolutionStep
- Throws:
IllegalStateException
- if any required attributes are missing
-
formatRequiredAttributesMessage
-