Package net.bmahe.genetics4j.core.spec
Class ImmutableEvolutionResult.Builder<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.spec.ImmutableEvolutionResult.Builder<T>
- Enclosing class:
ImmutableEvolutionResult<T extends Comparable<T>>
Builds instances of type
ImmutableEvolutionResult
.
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 AbstractEAConfiguration
<T> private long
private static final long
private static final long
private long
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddAllFitness
(Iterable<? extends T> elements) Adds elements tofitness
list.addAllPopulation
(Iterable<? extends Genotype> elements) Adds elements topopulation
list.addFitness
(T element) Adds one element tofitness
list.addFitness
(T... elements) Adds elements tofitness
list.addPopulation
(Genotype element) Adds one element topopulation
list.addPopulation
(Genotype... elements) Adds elements topopulation
list.build()
Builds a newImmutableEvolutionResult
.eaConfiguration
(AbstractEAConfiguration<T> eaConfiguration) Initializes the value for theeaConfiguration
attribute.Sets or replaces all elements forfitness
list.private String
from
(EvolutionResult<T> instance) Fill a builder with attribute values from the providedEvolutionResult
instance.generation
(long generation) Initializes the value for thegeneration
attribute.population
(Iterable<? extends Genotype> elements) Sets or replaces all elements forpopulation
list.
-
Field Details
-
INIT_BIT_EA_CONFIGURATION
private static final long INIT_BIT_EA_CONFIGURATION- See Also:
-
INIT_BIT_GENERATION
private static final long INIT_BIT_GENERATION- See Also:
-
initBits
private long initBits -
eaConfiguration
-
generation
private long generation -
population
-
fitness
-
-
Constructor Details
-
Builder
private Builder()
-
-
Method Details
-
from
Fill a builder with attribute values from the providedEvolutionResult
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
-
eaConfiguration
public final ImmutableEvolutionResult.Builder<T> eaConfiguration(AbstractEAConfiguration<T> eaConfiguration) Initializes the value for theeaConfiguration
attribute.- Parameters:
eaConfiguration
- The value for eaConfiguration- 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
-
addPopulation
Adds one element topopulation
list.- Parameters:
element
- A population element- Returns:
this
builder for use in a chained invocation
-
addPopulation
Adds elements topopulation
list.- Parameters:
elements
- An array of population elements- Returns:
this
builder for use in a chained invocation
-
population
Sets or replaces all elements forpopulation
list.- Parameters:
elements
- An iterable of population elements- Returns:
this
builder for use in a chained invocation
-
addAllPopulation
public final ImmutableEvolutionResult.Builder<T> addAllPopulation(Iterable<? extends Genotype> elements) Adds elements topopulation
list.- Parameters:
elements
- An iterable of population elements- Returns:
this
builder for use in a chained invocation
-
addFitness
Adds one element tofitness
list.- Parameters:
element
- A fitness element- Returns:
this
builder for use in a chained invocation
-
addFitness
Adds elements tofitness
list.- Parameters:
elements
- An array of fitness elements- Returns:
this
builder for use in a chained invocation
-
fitness
Sets or replaces all elements forfitness
list.- Parameters:
elements
- An iterable of fitness elements- Returns:
this
builder for use in a chained invocation
-
addAllFitness
Adds elements tofitness
list.- Parameters:
elements
- An iterable of fitness elements- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableEvolutionResult
.- Returns:
- An immutable instance of EvolutionResult
- Throws:
IllegalStateException
- if any required attributes are missing
-
formatRequiredAttributesMessage
-