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>>
@Generated(from="NSGA2Selection",
generator="Immutables")
public static class ImmutableNSGA2Selection.Builder<T extends Comparable<T>>
extends Object
Builds instances of type
NSGA2Selection.
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
FieldsModifier and TypeFieldDescriptionprivate Comparator<Genotype> private ObjectiveDistance<T> private Comparator<T> private static final longprivate static final longprivate static final longprivate longprivate intprivate Function<Integer, Comparator<T>> private static final longprivate long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a newNSGA2Selection.final NSGA2Selection.Builder<T> deduplicate(Comparator<Genotype> deduplicate) Initializes the optional valuededuplicateto deduplicate.final NSGA2Selection.Builder<T> deduplicate(Optional<? extends Comparator<Genotype>> deduplicate) Initializes the optional valuededuplicateto deduplicate.private booleanfinal NSGA2Selection.Builder<T> distance(ObjectiveDistance<T> distance) Initializes the value for thedistanceattribute.final NSGA2Selection.Builder<T> dominance(Comparator<T> dominance) Initializes the value for thedominanceattribute.private Stringfinal NSGA2Selection.Builder<T> from(NSGA2Selection<T> instance) Fill a builder with attribute values from the providedNSGA2Selectioninstance.final NSGA2Selection.Builder<T> numberObjectives(int numberObjectives) Initializes the value for thenumberObjectivesattribute.final NSGA2Selection.Builder<T> objectiveComparator(Function<Integer, Comparator<T>> objectiveComparator) Initializes the value for theobjectiveComparatorattribute.
-
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:
-
OPT_BIT_DEDUPLICATE
private static final long OPT_BIT_DEDUPLICATE- See Also:
-
initBits
private long initBits -
optBits
private long optBits -
numberObjectives
private int numberObjectives -
dominance
-
deduplicate
-
objectiveComparator
-
distance
-
-
Constructor Details
-
Builder
public Builder()Creates a builder forNSGA2Selectioninstances.new NSGA2Selection.Builder<T>() .numberObjectives(int) // requirednumberObjectives.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 providedNSGA2Selectioninstance. 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:
thisbuilder for use in a chained invocation
-
numberObjectives
Initializes the value for thenumberObjectivesattribute.- Parameters:
numberObjectives- The value for numberObjectives- Returns:
thisbuilder for use in a chained invocation
-
dominance
Initializes the value for thedominanceattribute.If not set, this attribute will have a default value as returned by the initializer of
dominance.- Parameters:
dominance- The value for dominance- Returns:
thisbuilder for use in a chained invocation
-
deduplicate
Initializes the optional valuededuplicateto deduplicate.- Parameters:
deduplicate- The value for deduplicate- Returns:
thisbuilder for chained invocation
-
deduplicate
public final NSGA2Selection.Builder<T> deduplicate(Optional<? extends Comparator<Genotype>> deduplicate) Initializes the optional valuededuplicateto deduplicate.- Parameters:
deduplicate- The value for deduplicate- Returns:
thisbuilder for use in a chained invocation
-
objectiveComparator
public final NSGA2Selection.Builder<T> objectiveComparator(Function<Integer, Comparator<T>> objectiveComparator) Initializes the value for theobjectiveComparatorattribute.- Parameters:
objectiveComparator- The value for objectiveComparator- Returns:
thisbuilder for use in a chained invocation
-
distance
Initializes the value for thedistanceattribute.- Parameters:
distance- The value for distance- Returns:
thisbuilder for use in a chained invocation
-
build
Builds a newNSGA2Selection.- Returns:
- An immutable instance of NSGA2Selection
- Throws:
IllegalStateException- if any required attributes are missing
-
deduplicateIsSet
private boolean deduplicateIsSet() -
formatRequiredAttributesMessage
-