Class ImmutableTournamentNSGA2Selection.Builder<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.moo.nsga2.spec.ImmutableTournamentNSGA2Selection.Builder<T>
- Direct Known Subclasses:
TournamentNSGA2Selection.Builder
- Enclosing class:
ImmutableTournamentNSGA2Selection<T extends Comparable<T>>
public static class ImmutableTournamentNSGA2Selection.Builder<T extends Comparable<T>>
extends Object
Builds instances of type
ImmutableTournamentNSGA2Selection
.
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 static final long
private long
private int
private int
private Function
<Integer, Comparator<T>> -
Constructor Summary
ConstructorDescriptionBuilder()
Creates a builder forImmutableTournamentNSGA2Selection
instances. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newImmutableTournamentNSGA2Selection
.deduplicate
(Optional<Comparator<Genotype>> deduplicate) Initializes the value for thededuplicate
attribute.distance
(ObjectiveDistance<T> distance) Initializes the value for thedistance
attribute.dominance
(Comparator<T> dominance) Initializes the value for thedominance
attribute.private String
from
(TournamentNSGA2Selection<T> instance) Fill a builder with attribute values from the providedTournamentNSGA2Selection
instance.numberObjectives
(int numberObjectives) Initializes the value for thenumberObjectives
attribute.numCandidates
(int numCandidates) Initializes the value for thenumCandidates
attribute.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:
-
INIT_BIT_NUM_CANDIDATES
private static final long INIT_BIT_NUM_CANDIDATES- See Also:
-
initBits
private long initBits -
numberObjectives
private int numberObjectives -
dominance
-
deduplicate
-
objectiveComparator
-
distance
-
numCandidates
private int numCandidates
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forImmutableTournamentNSGA2Selection
instances.new TournamentNSGA2Selection.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
.numCandidates(int) // requirednumCandidates
.build();
-
-
Method Details
-
from
Fill a builder with attribute values from the providedTournamentNSGA2Selection
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
public final TournamentNSGA2Selection.Builder<T> deduplicate(Optional<Comparator<Genotype>> 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 TournamentNSGA2Selection.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
-
numCandidates
Initializes the value for thenumCandidates
attribute.- Parameters:
numCandidates
- The value for numCandidates- Returns:
this
builder for use in a chained invocation
-
build
Builds a newImmutableTournamentNSGA2Selection
.- Returns:
- An immutable instance of TournamentNSGA2Selection
- Throws:
IllegalStateException
- if any required attributes are missing
-
formatRequiredAttributesMessage
-