Class ImmutableTournament<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.spec.selection.Tournament<T>
net.bmahe.genetics4j.core.spec.selection.ImmutableTournament<T>
- All Implemented Interfaces:
SelectionPolicy
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableTournament<T extends Comparable<T>>
extends Tournament<T>
Immutable implementation of
Tournament
.
Use the builder to create immutable instances:
new Tournament.Builder()
.
Use the static factory method to create immutable instances:
ImmutableTournament.of()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ImmutableTournament.Builder<T extends Comparable<T>>
Builds instances of typeTournament
. -
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableTournament
(int numCandidates) private
ImmutableTournament
(int numCandidates, Comparator<Individual<T>> comparator) private
ImmutableTournament
(ImmutableTournament.Builder<T> builder) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
Tournament<T> copyOf
(Tournament<T> instance) Creates an immutable copy of aTournament
value.boolean
This instance is equal to all instances ofImmutableTournament
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableTournament<?> another) int
hashCode()
Computes a hash code from attributes:numCandidates
,comparator
.int
static <T extends Comparable<T>>
Tournament<T> of
(int numCandidates) Construct a new immutableTournament
instance.toString()
Prints the immutable valueTournament
with attribute values.final ImmutableTournament
<T> withComparator
(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for thecomparator
attribute.final ImmutableTournament
<T> withNumCandidates
(int value) Copy the current immutable object by setting a value for thenumCandidates
attribute.Methods inherited from class net.bmahe.genetics4j.core.spec.selection.Tournament
of
-
Field Details
-
numCandidates
private final int numCandidates -
comparator
-
-
Constructor Details
-
ImmutableTournament
private ImmutableTournament(int numCandidates) -
ImmutableTournament
-
ImmutableTournament
-
-
Method Details
-
numCandidates
public int numCandidates()- Specified by:
numCandidates
in classTournament<T extends Comparable<T>>
- Returns:
- The value of the
numCandidates
attribute
-
comparator
- Overrides:
comparator
in classTournament<T extends Comparable<T>>
- Returns:
- The value of the
comparator
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
-
withComparator
Copy the current immutable object by setting a value for thecomparator
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for comparator- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableTournament
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:numCandidates
,comparator
. -
toString
Prints the immutable valueTournament
with attribute values. -
of
Construct a new immutableTournament
instance.- Type Parameters:
T
- generic parameter T- Parameters:
numCandidates
- The value for thenumCandidates
attribute- Returns:
- An immutable Tournament instance
-
copyOf
Creates an immutable copy of aTournament
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 Tournament instance
-