Class ImmutableProportionalTournament<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.spec.selection.ImmutableProportionalTournament<T>
- All Implemented Interfaces:
ProportionalTournament<T>
,SelectionPolicy
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableProportionalTournament<T extends Comparable<T>>
extends Object
implements ProportionalTournament<T>
Immutable implementation of
ProportionalTournament
.
Use the builder to create immutable instances:
ImmutableProportionalTournament.builder()
.
Use the static factory method to create immutable instances:
ImmutableProportionalTournament.of()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
ImmutableProportionalTournament.Builder<T extends Comparable<T>>
Builds instances of typeProportionalTournament
. -
Field Summary
Modifier and TypeFieldDescriptionprivate final Comparator
<Individual<T>> private final int
private final double
private final Comparator
<Individual<T>> -
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableProportionalTournament
(int numCandidates, double proportionFirst, Comparator<Individual<T>> firstComparator, Comparator<Individual<T>> secondComparator) private
ImmutableProportionalTournament
(ImmutableProportionalTournament<T> original, int numCandidates, double proportionFirst, Comparator<Individual<T>> firstComparator, Comparator<Individual<T>> secondComparator) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
ImmutableProportionalTournament.Builder<T> builder()
Creates a builder forProportionalTournament
.static <T extends Comparable<T>>
ProportionalTournament<T> copyOf
(ProportionalTournament<T> instance) Creates an immutable copy of aProportionalTournament
value.boolean
This instance is equal to all instances ofImmutableProportionalTournament
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableProportionalTournament<?> another) int
hashCode()
Computes a hash code from attributes:numCandidates
,proportionFirst
,firstComparator
,secondComparator
.int
static <T extends Comparable<T>>
ProportionalTournament<T> of
(int numCandidates, double proportionFirst, Comparator<Individual<T>> firstComparator, Comparator<Individual<T>> secondComparator) Construct a new immutableProportionalTournament
instance.double
toString()
Prints the immutable valueProportionalTournament
with attribute values.private static <T extends Comparable<T>>
ImmutableProportionalTournament<T> validate
(ImmutableProportionalTournament<T> instance) final ImmutableProportionalTournament
<T> withFirstComparator
(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for thefirstComparator
attribute.final ImmutableProportionalTournament
<T> withNumCandidates
(int value) Copy the current immutable object by setting a value for thenumCandidates
attribute.final ImmutableProportionalTournament
<T> withProportionFirst
(double value) Copy the current immutable object by setting a value for theproportionFirst
attribute.final ImmutableProportionalTournament
<T> withSecondComparator
(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for thesecondComparator
attribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.bmahe.genetics4j.core.spec.selection.ProportionalTournament
check
-
Field Details
-
numCandidates
private final int numCandidates -
proportionFirst
private final double proportionFirst -
firstComparator
-
secondComparator
-
-
Constructor Details
-
ImmutableProportionalTournament
private ImmutableProportionalTournament(int numCandidates, double proportionFirst, Comparator<Individual<T>> firstComparator, Comparator<Individual<T>> secondComparator) -
ImmutableProportionalTournament
private ImmutableProportionalTournament(ImmutableProportionalTournament<T> original, int numCandidates, double proportionFirst, Comparator<Individual<T>> firstComparator, Comparator<Individual<T>> secondComparator)
-
-
Method Details
-
numCandidates
public int numCandidates()- Specified by:
numCandidates
in interfaceProportionalTournament<T extends Comparable<T>>
- Returns:
- The value of the
numCandidates
attribute
-
proportionFirst
public double proportionFirst()- Specified by:
proportionFirst
in interfaceProportionalTournament<T extends Comparable<T>>
- Returns:
- The value of the
proportionFirst
attribute
-
firstComparator
- Specified by:
firstComparator
in interfaceProportionalTournament<T extends Comparable<T>>
- Returns:
- The value of the
firstComparator
attribute
-
secondComparator
- Specified by:
secondComparator
in interfaceProportionalTournament<T extends Comparable<T>>
- Returns:
- The value of the
secondComparator
attribute
-
withNumCandidates
Copy the current immutable object by setting a value for thenumCandidates
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for numCandidates- Returns:
- A modified copy of the
this
object
-
withProportionFirst
Copy the current immutable object by setting a value for theproportionFirst
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for proportionFirst- Returns:
- A modified copy of the
this
object
-
withFirstComparator
public final ImmutableProportionalTournament<T> withFirstComparator(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for thefirstComparator
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for firstComparator- Returns:
- A modified copy of the
this
object
-
withSecondComparator
public final ImmutableProportionalTournament<T> withSecondComparator(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for thesecondComparator
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for secondComparator- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableProportionalTournament
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:numCandidates
,proportionFirst
,firstComparator
,secondComparator
. -
toString
Prints the immutable valueProportionalTournament
with attribute values. -
of
public static <T extends Comparable<T>> ProportionalTournament<T> of(int numCandidates, double proportionFirst, Comparator<Individual<T>> firstComparator, Comparator<Individual<T>> secondComparator) Construct a new immutableProportionalTournament
instance.- Type Parameters:
T
- generic parameter T- Parameters:
numCandidates
- The value for thenumCandidates
attributeproportionFirst
- The value for theproportionFirst
attributefirstComparator
- The value for thefirstComparator
attributesecondComparator
- The value for thesecondComparator
attribute- Returns:
- An immutable ProportionalTournament instance
-
validate
private static <T extends Comparable<T>> ImmutableProportionalTournament<T> validate(ImmutableProportionalTournament<T> instance) -
copyOf
public static <T extends Comparable<T>> ProportionalTournament<T> copyOf(ProportionalTournament<T> instance) Creates an immutable copy of aProportionalTournament
value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Type Parameters:
T
- generic parameter T- Parameters:
instance
- The instance to copy- Returns:
- A copied immutable ProportionalTournament instance
-
builder
Creates a builder forProportionalTournament
.ImmutableProportionalTournament.<T>builder() .numCandidates(int) // required
numCandidates
.proportionFirst(double) // requiredproportionFirst
.firstComparator(Comparator<net.bmahe.genetics4j.core.Individual<T>>) // requiredfirstComparator
.secondComparator(Comparator<net.bmahe.genetics4j.core.Individual<T>>) // requiredsecondComparator
.build();- Type Parameters:
T
- generic parameter T- Returns:
- A new ProportionalTournament builder
-