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(from="Tournament",
generator="Immutables")
@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
Nested ClassesModifier and TypeClassDescriptionstatic classImmutableTournament.Builder<T extends Comparable<T>>Builds instances of typeTournament. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableTournament(int numCandidates) privateImmutableTournament(int numCandidates, Comparator<Individual<T>> comparator) privateImmutableTournament(ImmutableTournament.Builder<T> builder) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
Tournament<T> copyOf(Tournament<T> instance) Creates an immutable copy of aTournamentvalue.booleanThis instance is equal to all instances ofImmutableTournamentthat have equal attribute values.private booleanequalsByValue(ImmutableTournament<?> another) inthashCode()Computes a hash code from attributes:numCandidates,comparator.intstatic <T extends Comparable<T>>
Tournament<T> of(int numCandidates) Construct a new immutableTournamentinstance.toString()Prints the immutable valueTournamentwith attribute values.final ImmutableTournament<T> withComparator(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for thecomparatorattribute.final ImmutableTournament<T> withNumCandidates(int value) Copy the current immutable object by setting a value for thenumCandidatesattribute.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:
numCandidatesin classTournament<T extends Comparable<T>>- Returns:
- The value of the
numCandidatesattribute
-
comparator
- Overrides:
comparatorin classTournament<T extends Comparable<T>>- Returns:
- The value of the
comparatorattribute
-
withNumCandidates
Copy the current immutable object by setting a value for thenumCandidatesattribute. 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 or the
thisobject
-
withComparator
Copy the current immutable object by setting a value for thecomparatorattribute. 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 or the
thisobject
-
equals
This instance is equal to all instances ofImmutableTournamentthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:numCandidates,comparator. -
toString
Prints the immutable valueTournamentwith attribute values. -
of
Construct a new immutableTournamentinstance.- Type Parameters:
T- generic parameter T- Parameters:
numCandidates- The value for thenumCandidatesattribute- Returns:
- An immutable Tournament instance
-
copyOf
Creates an immutable copy of aTournamentvalue. 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
-