Class ImmutableNSGA2Selection.Builder<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.moo.nsga2.spec.ImmutableNSGA2Selection.Builder<T>
- Direct Known Subclasses:
NSGA2Selection.Builder
- Enclosing class:
ImmutableNSGA2Selection<T extends Comparable<T>>
Builds instances of type
ImmutableNSGA2Selection
.
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 ObjectiveDistance
<T> private Comparator
<T> private static final long
private static final long
private static final long
private long
private int
private Function
<Integer, Comparator<T>> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newImmutableNSGA2Selection
.final NSGA2Selection.Builder
<T> deduplicate
(Optional<Comparator<Genotype>> deduplicate) Initializes the value for thededuplicate
attribute.final NSGA2Selection.Builder
<T> distance
(ObjectiveDistance<T> distance) Initializes the value for thedistance
attribute.final NSGA2Selection.Builder
<T> dominance
(Comparator<T> dominance) Initializes the value for thedominance
attribute.private String
final NSGA2Selection.Builder
<T> from
(NSGA2Selection<T> instance) Fill a builder with attribute values from the providedNSGA2Selection
instance.final NSGA2Selection.Builder
<T> numberObjectives
(int numberObjectives) Initializes the value for thenumberObjectives
attribute.final NSGA2Selection.Builder
<T> objectiveComparator
(Function<Integer, Comparator<T>> objectiveComparator) Initializes the value for theobjectiveComparator
attribute.
-
Field Details
-
INIT_BIT_NUMBER_OBJECTIVES
private static final long INIT_BIT_NUMBER_OBJECTIVES- See Also:
-
INIT_BIT_OBJECTIVE_COMPARATOR
private static final long INIT_BIT_OBJECTIVE_COMPARATOR- See Also:
-
INIT_BIT_DISTANCE
private static final long INIT_BIT_DISTANCE- See Also:
-
initBits
private long initBits -
numberObjectives
private int numberObjectives -
dominance
-
deduplicate
-
objectiveComparator
-
distance
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forImmutableNSGA2Selection
instances.new NSGA2Selection.Builder<T>() .numberObjectives(int) // required
numberObjectives
.dominance(Comparator<T>) // optionaldominance
.deduplicate(Optional<Comparator<net.bmahe.genetics4j.core.Genotype>>) // optionaldeduplicate
.objectiveComparator(function.Function<Integer, Comparator<T>>) // requiredobjectiveComparator
.distance(net.bmahe.genetics4j.moo.ObjectiveDistance<T>) // requireddistance
.build();
-
-
Method Details
-
from
Fill a builder with attribute values from the providedNSGA2Selection
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
-
numberObjectives
Initializes the value for thenumberObjectives
attribute.- Parameters:
numberObjectives
- The value for numberObjectives- 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
-
objectiveComparator
public final NSGA2Selection.Builder<T> objectiveComparator(Function<Integer, Comparator<T>> objectiveComparator) Initializes the value for theobjectiveComparator
attribute.- Parameters:
objectiveComparator
- The value for objectiveComparator- 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 newImmutableNSGA2Selection
.- Returns:
- An immutable instance of NSGA2Selection
- Throws:
IllegalStateException
- if any required attributes are missing
-
formatRequiredAttributesMessage
-