Class ImmutableProportionalTournament<T extends Comparable<T>>
java.lang.Object
net.bmahe.genetics4j.core.spec.selection.ImmutableProportionalTournament<T>
- All Implemented Interfaces:
ProportionalTournament<T>,SelectionPolicy
@Generated(from="ProportionalTournament",
generator="Immutables")
@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
Nested ClassesModifier and TypeClassDescriptionstatic final classImmutableProportionalTournament.Builder<T extends Comparable<T>>Builds instances of typeProportionalTournament. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator<Individual<T>> private final intprivate final doubleprivate final Comparator<Individual<T>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableProportionalTournament(int numCandidates, double proportionFirst, Comparator<Individual<T>> firstComparator, Comparator<Individual<T>> secondComparator) privateImmutableProportionalTournament(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 aProportionalTournamentvalue.booleanThis instance is equal to all instances ofImmutableProportionalTournamentthat have equal attribute values.private booleanequalsByValue(ImmutableProportionalTournament<?> another) inthashCode()Computes a hash code from attributes:numCandidates,proportionFirst,firstComparator,secondComparator.intstatic <T extends Comparable<T>>
ProportionalTournament<T> of(int numCandidates, double proportionFirst, Comparator<Individual<T>> firstComparator, Comparator<Individual<T>> secondComparator) Construct a new immutableProportionalTournamentinstance.doubletoString()Prints the immutable valueProportionalTournamentwith 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 thefirstComparatorattribute.final ImmutableProportionalTournament<T> withNumCandidates(int value) Copy the current immutable object by setting a value for thenumCandidatesattribute.final ImmutableProportionalTournament<T> withProportionFirst(double value) Copy the current immutable object by setting a value for theproportionFirstattribute.final ImmutableProportionalTournament<T> withSecondComparator(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for thesecondComparatorattribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:
numCandidatesin interfaceProportionalTournament<T extends Comparable<T>>- Returns:
- The value of the
numCandidatesattribute
-
proportionFirst
public double proportionFirst()- Specified by:
proportionFirstin interfaceProportionalTournament<T extends Comparable<T>>- Returns:
- The value of the
proportionFirstattribute
-
firstComparator
- Specified by:
firstComparatorin interfaceProportionalTournament<T extends Comparable<T>>- Returns:
- The value of the
firstComparatorattribute
-
secondComparator
- Specified by:
secondComparatorin interfaceProportionalTournament<T extends Comparable<T>>- Returns:
- The value of the
secondComparatorattribute
-
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
-
withProportionFirst
Copy the current immutable object by setting a value for theproportionFirstattribute. 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 or the
thisobject
-
withFirstComparator
public final ImmutableProportionalTournament<T> withFirstComparator(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for thefirstComparatorattribute. 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 or the
thisobject
-
withSecondComparator
public final ImmutableProportionalTournament<T> withSecondComparator(Comparator<Individual<T>> value) Copy the current immutable object by setting a value for thesecondComparatorattribute. 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 or the
thisobject
-
equals
This instance is equal to all instances ofImmutableProportionalTournamentthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:numCandidates,proportionFirst,firstComparator,secondComparator. -
toString
Prints the immutable valueProportionalTournamentwith 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 immutableProportionalTournamentinstance.- Type Parameters:
T- generic parameter T- Parameters:
numCandidates- The value for thenumCandidatesattributeproportionFirst- The value for theproportionFirstattributefirstComparator- The value for thefirstComparatorattributesecondComparator- The value for thesecondComparatorattribute- 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 aProportionalTournamentvalue. 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) // requirednumCandidates.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
-