Class ImmutableDoubleTournament<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.spec.selection.DoubleTournament<T>
net.bmahe.genetics4j.core.spec.selection.ImmutableDoubleTournament<T>
- All Implemented Interfaces:
SelectionPolicy
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableDoubleTournament<T extends Comparable<T>>
extends DoubleTournament<T>
Immutable implementation of
DoubleTournament
.
Use the builder to create immutable instances:
ImmutableDoubleTournament.builder()
.
Use the static factory method to create immutable instances:
ImmutableDoubleTournament.of()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
ImmutableDoubleTournament.Builder<T extends Comparable<T>>
Builds instances of typeImmutableDoubleTournament
. -
Field Summary
Modifier and TypeFieldDescriptionprivate final boolean
private final Tournament
<T> private final Comparator
<Individual<T>> private final double
-
Constructor Summary
ModifierConstructorDescriptionprivate
private
ImmutableDoubleTournament
(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize) private
ImmutableDoubleTournament
(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize, boolean doFitnessFirst) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
ImmutableDoubleTournament.Builder<T> builder()
Creates a builder forImmutableDoubleTournament
.static <T extends Comparable<T>>
ImmutableDoubleTournament<T> copyOf
(DoubleTournament<T> instance) Creates an immutable copy of aDoubleTournament
value.boolean
boolean
This instance is equal to all instances ofImmutableDoubleTournament
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableDoubleTournament<?> another) int
hashCode()
Computes a hash code from attributes:fitnessTournament
,parsimonyComparator
,parsimonyTournamentSize
,doFitnessFirst
.static <T extends Comparable<T>>
ImmutableDoubleTournament<T> of
(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize) Construct a new immutableDoubleTournament
instance.double
toString()
Prints the immutable valueDoubleTournament
with attribute values.private static <T extends Comparable<T>>
ImmutableDoubleTournament<T> validate
(ImmutableDoubleTournament<T> instance) final ImmutableDoubleTournament
<T> withDoFitnessFirst
(boolean value) Copy the current immutable object by setting a value for thedoFitnessFirst
attribute.final ImmutableDoubleTournament
<T> withFitnessTournament
(Tournament<T> value) Copy the current immutable object by setting a value for thefitnessTournament
attribute.final ImmutableDoubleTournament
<T> withParsimonyComparator
(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for theparsimonyComparator
attribute.final ImmutableDoubleTournament
<T> withParsimonyTournamentSize
(double value) Copy the current immutable object by setting a value for theparsimonyTournamentSize
attribute.Methods inherited from class net.bmahe.genetics4j.core.spec.selection.DoubleTournament
check
-
Field Details
-
fitnessTournament
-
parsimonyComparator
-
parsimonyTournamentSize
private final double parsimonyTournamentSize -
doFitnessFirst
private final boolean doFitnessFirst
-
-
Constructor Details
-
ImmutableDoubleTournament
private ImmutableDoubleTournament(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize) -
ImmutableDoubleTournament
-
ImmutableDoubleTournament
private ImmutableDoubleTournament(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize, boolean doFitnessFirst)
-
-
Method Details
-
fitnessTournament
- Specified by:
fitnessTournament
in classDoubleTournament<T extends Comparable<T>>
- Returns:
- The value of the
fitnessTournament
attribute
-
parsimonyComparator
- Specified by:
parsimonyComparator
in classDoubleTournament<T extends Comparable<T>>
- Returns:
- The value of the
parsimonyComparator
attribute
-
parsimonyTournamentSize
public double parsimonyTournamentSize()- Specified by:
parsimonyTournamentSize
in classDoubleTournament<T extends Comparable<T>>
- Returns:
- The value of the
parsimonyTournamentSize
attribute
-
doFitnessFirst
public boolean doFitnessFirst()- Overrides:
doFitnessFirst
in classDoubleTournament<T extends Comparable<T>>
- Returns:
- The value of the
doFitnessFirst
attribute
-
withFitnessTournament
Copy the current immutable object by setting a value for thefitnessTournament
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for fitnessTournament- Returns:
- A modified copy of the
this
object
-
withParsimonyComparator
Copy the current immutable object by setting a value for theparsimonyComparator
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for parsimonyComparator- Returns:
- A modified copy of the
this
object
-
withParsimonyTournamentSize
Copy the current immutable object by setting a value for theparsimonyTournamentSize
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for parsimonyTournamentSize- Returns:
- A modified copy of the
this
object
-
withDoFitnessFirst
Copy the current immutable object by setting a value for thedoFitnessFirst
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for doFitnessFirst- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableDoubleTournament
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:fitnessTournament
,parsimonyComparator
,parsimonyTournamentSize
,doFitnessFirst
. -
toString
Prints the immutable valueDoubleTournament
with attribute values. -
of
public static <T extends Comparable<T>> ImmutableDoubleTournament<T> of(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize) Construct a new immutableDoubleTournament
instance.- Type Parameters:
T
- generic parameter T- Parameters:
fitnessTournament
- The value for thefitnessTournament
attributeparsimonyComparator
- The value for theparsimonyComparator
attributeparsimonyTournamentSize
- The value for theparsimonyTournamentSize
attribute- Returns:
- An immutable DoubleTournament instance
-
validate
private static <T extends Comparable<T>> ImmutableDoubleTournament<T> validate(ImmutableDoubleTournament<T> instance) -
copyOf
public static <T extends Comparable<T>> ImmutableDoubleTournament<T> copyOf(DoubleTournament<T> instance) Creates an immutable copy of aDoubleTournament
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 DoubleTournament instance
-
builder
Creates a builder forImmutableDoubleTournament
.ImmutableDoubleTournament.<T>builder() .fitnessTournament(net.bmahe.genetics4j.core.spec.selection.Tournament<T>) // required
fitnessTournament
.parsimonyComparator(Comparator<net.bmahe.genetics4j.core.Individual<T>>) // requiredparsimonyComparator
.parsimonyTournamentSize(double) // requiredparsimonyTournamentSize
.doFitnessFirst(boolean) // optionaldoFitnessFirst
.build();- Type Parameters:
T
- generic parameter T- Returns:
- A new ImmutableDoubleTournament builder
-