Class ImmutableElitism.Builder
java.lang.Object
net.bmahe.genetics4j.core.spec.replacement.ImmutableElitism.Builder
- Direct Known Subclasses:
Elitism.Builder
- Enclosing class:
ImmutableElitism
Builds instances of type
ImmutableElitism
.
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 int
private int
private static final long
private static final long
private long
private double
private SelectionPolicy
private static final long
private static final long
private static final long
private long
private SelectionPolicy
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal Elitism.Builder
atLeastNumOffsprings
(int atLeastNumOffsprings) Initializes the value for theatLeastNumOffsprings
attribute.private boolean
final Elitism.Builder
atLeastNumSurvivors
(int atLeastNumSurvivors) Initializes the value for theatLeastNumSurvivors
attribute.private boolean
build()
Builds a newImmutableElitism
.private String
final Elitism.Builder
Fill a builder with attribute values from the providedElitism
instance.final Elitism.Builder
offspringRatio
(double offspringRatio) Initializes the value for theoffspringRatio
attribute.private boolean
final Elitism.Builder
offspringSelectionPolicy
(SelectionPolicy offspringSelectionPolicy) Initializes the value for theoffspringSelectionPolicy
attribute.final Elitism.Builder
survivorSelectionPolicy
(SelectionPolicy survivorSelectionPolicy) Initializes the value for thesurvivorSelectionPolicy
attribute.
-
Field Details
-
INIT_BIT_OFFSPRING_SELECTION_POLICY
private static final long INIT_BIT_OFFSPRING_SELECTION_POLICY- See Also:
-
INIT_BIT_SURVIVOR_SELECTION_POLICY
private static final long INIT_BIT_SURVIVOR_SELECTION_POLICY- See Also:
-
OPT_BIT_AT_LEAST_NUM_OFFSPRINGS
private static final long OPT_BIT_AT_LEAST_NUM_OFFSPRINGS- See Also:
-
OPT_BIT_AT_LEAST_NUM_SURVIVORS
private static final long OPT_BIT_AT_LEAST_NUM_SURVIVORS- See Also:
-
OPT_BIT_OFFSPRING_RATIO
private static final long OPT_BIT_OFFSPRING_RATIO- See Also:
-
initBits
private long initBits -
optBits
private long optBits -
offspringSelectionPolicy
-
atLeastNumOffsprings
private int atLeastNumOffsprings -
survivorSelectionPolicy
-
atLeastNumSurvivors
private int atLeastNumSurvivors -
offspringRatio
private double offspringRatio
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forImmutableElitism
instances.new Elitism.Builder() .offspringSelectionPolicy(net.bmahe.genetics4j.core.spec.selection.SelectionPolicy) // required
offspringSelectionPolicy
.atLeastNumOffsprings(int) // optionalatLeastNumOffsprings
.survivorSelectionPolicy(net.bmahe.genetics4j.core.spec.selection.SelectionPolicy) // requiredsurvivorSelectionPolicy
.atLeastNumSurvivors(int) // optionalatLeastNumSurvivors
.offspringRatio(double) // optionaloffspringRatio
.build();
-
-
Method Details
-
from
Fill a builder with attribute values from the providedElitism
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
-
offspringSelectionPolicy
Initializes the value for theoffspringSelectionPolicy
attribute.- Parameters:
offspringSelectionPolicy
- The value for offspringSelectionPolicy- Returns:
this
builder for use in a chained invocation
-
atLeastNumOffsprings
Initializes the value for theatLeastNumOffsprings
attribute.If not set, this attribute will have a default value as returned by the initializer of
atLeastNumOffsprings
.- Parameters:
atLeastNumOffsprings
- The value for atLeastNumOffsprings- Returns:
this
builder for use in a chained invocation
-
survivorSelectionPolicy
Initializes the value for thesurvivorSelectionPolicy
attribute.- Parameters:
survivorSelectionPolicy
- The value for survivorSelectionPolicy- Returns:
this
builder for use in a chained invocation
-
atLeastNumSurvivors
Initializes the value for theatLeastNumSurvivors
attribute.If not set, this attribute will have a default value as returned by the initializer of
atLeastNumSurvivors
.- Parameters:
atLeastNumSurvivors
- The value for atLeastNumSurvivors- Returns:
this
builder for use in a chained invocation
-
offspringRatio
Initializes the value for theoffspringRatio
attribute.If not set, this attribute will have a default value as returned by the initializer of
offspringRatio
.- Parameters:
offspringRatio
- The value for offspringRatio- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableElitism
.- Returns:
- An immutable instance of Elitism
- Throws:
IllegalStateException
- if any required attributes are missing
-
atLeastNumOffspringsIsSet
private boolean atLeastNumOffspringsIsSet() -
atLeastNumSurvivorsIsSet
private boolean atLeastNumSurvivorsIsSet() -
offspringRatioIsSet
private boolean offspringRatioIsSet() -
formatRequiredAttributesMessage
-