Class ImmutableSPEA2Replacement.Builder<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.moo.spea2.spec.replacement.ImmutableSPEA2Replacement.Builder<T>
- Direct Known Subclasses:
SPEA2Replacement.Builder
- Enclosing class:
ImmutableSPEA2Replacement<T extends Comparable<T>>
Builds instances of type
ImmutableSPEA2Replacement
.
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 Optional
<Comparator<Genotype>> private BiFunction
<T, T, Double> private Comparator
<T> private static final long
private long
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newImmutableSPEA2Replacement
.final SPEA2Replacement.Builder
<T> deduplicate
(Optional<Comparator<Genotype>> deduplicate) Initializes the value for thededuplicate
attribute.final SPEA2Replacement.Builder
<T> distance
(BiFunction<T, T, Double> distance) Initializes the value for thedistance
attribute.final SPEA2Replacement.Builder
<T> dominance
(Comparator<T> dominance) Initializes the value for thedominance
attribute.private String
final SPEA2Replacement.Builder
<T> from
(SPEA2Replacement<T> instance) Fill a builder with attribute values from the providedSPEA2Replacement
instance.final SPEA2Replacement.Builder
<T> Initializes the value for thek
attribute.
-
Field Details
-
INIT_BIT_DISTANCE
private static final long INIT_BIT_DISTANCE- See Also:
-
initBits
private long initBits -
dominance
-
deduplicate
-
k
-
distance
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forImmutableSPEA2Replacement
instances.new SPEA2Replacement.Builder<T>() .dominance(Comparator<T>) // optional
dominance
.deduplicate(Optional<Comparator<net.bmahe.genetics4j.core.Genotype>>) // optionaldeduplicate
.k(Optional<Integer>) // optionalk
.distance(function.BiFunction<T, T, Double>) // requireddistance
.build();
-
-
Method Details
-
from
Fill a builder with attribute values from the providedSPEA2Replacement
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
-
dominance
Initializes the value for thedominance
attribute.If not set, this attribute will have a default value as returned by the initializer of
dominance
.- Parameters:
dominance
- The value for dominance- Returns:
this
builder for use in a chained invocation
-
deduplicate
Initializes the value for thededuplicate
attribute.If not set, this attribute will have a default value as returned by the initializer of
deduplicate
.- Parameters:
deduplicate
- The value for deduplicate- Returns:
this
builder for use in a chained invocation
-
k
Initializes the value for thek
attribute.If not set, this attribute will have a default value as returned by the initializer of
k
.- Parameters:
k
- The value for k- Returns:
this
builder for use in a chained invocation
-
distance
Initializes the value for thedistance
attribute.- Parameters:
distance
- The value for distance- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableSPEA2Replacement
.- Returns:
- An immutable instance of SPEA2Replacement
- Throws:
IllegalStateException
- if any required attributes are missing
-
formatRequiredAttributesMessage
-