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().

  • Field Details

    • fitnessTournament

      private final Tournament<T extends Comparable<T>> fitnessTournament
    • parsimonyComparator

      private final Comparator<Individual<T extends Comparable<T>>> parsimonyComparator
    • parsimonyTournamentSize

      private final double parsimonyTournamentSize
    • doFitnessFirst

      private final boolean doFitnessFirst
  • Constructor Details

  • Method Details

    • fitnessTournament

      public Tournament<T> fitnessTournament()
      Specified by:
      fitnessTournament in class DoubleTournament<T extends Comparable<T>>
      Returns:
      The value of the fitnessTournament attribute
    • parsimonyComparator

      public Comparator<Individual<T>> parsimonyComparator()
      Specified by:
      parsimonyComparator in class DoubleTournament<T extends Comparable<T>>
      Returns:
      The value of the parsimonyComparator attribute
    • parsimonyTournamentSize

      public double parsimonyTournamentSize()
      Specified by:
      parsimonyTournamentSize in class DoubleTournament<T extends Comparable<T>>
      Returns:
      The value of the parsimonyTournamentSize attribute
    • doFitnessFirst

      public boolean doFitnessFirst()
      Overrides:
      doFitnessFirst in class DoubleTournament<T extends Comparable<T>>
      Returns:
      The value of the doFitnessFirst attribute
    • withFitnessTournament

      public final ImmutableDoubleTournament<T> withFitnessTournament(Tournament<T> value)
      Copy the current immutable object by setting a value for the fitnessTournament attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for fitnessTournament
      Returns:
      A modified copy of the this object
    • withParsimonyComparator

      public final ImmutableDoubleTournament<T> withParsimonyComparator(Comparator<Individual<T>> value)
      Copy the current immutable object by setting a value for the parsimonyComparator attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for parsimonyComparator
      Returns:
      A modified copy of the this object
    • withParsimonyTournamentSize

      public final ImmutableDoubleTournament<T> withParsimonyTournamentSize(double value)
      Copy the current immutable object by setting a value for the parsimonyTournamentSize attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for parsimonyTournamentSize
      Returns:
      A modified copy of the this object
    • withDoFitnessFirst

      public final ImmutableDoubleTournament<T> withDoFitnessFirst(boolean value)
      Copy the current immutable object by setting a value for the doFitnessFirst attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for doFitnessFirst
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableDoubleTournament that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • equalTo

      private boolean equalTo(int synthetic, ImmutableDoubleTournament<?> another)
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: fitnessTournament, parsimonyComparator, parsimonyTournamentSize, doFitnessFirst.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value DoubleTournament with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • of

      public static <T extends Comparable<T>> ImmutableDoubleTournament<T> of(Tournament<T> fitnessTournament, Comparator<Individual<T>> parsimonyComparator, double parsimonyTournamentSize)
      Construct a new immutable DoubleTournament instance.
      Type Parameters:
      T - generic parameter T
      Parameters:
      fitnessTournament - The value for the fitnessTournament attribute
      parsimonyComparator - The value for the parsimonyComparator attribute
      parsimonyTournamentSize - The value for the parsimonyTournamentSize 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 a DoubleTournament 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

      public static <T extends Comparable<T>> ImmutableDoubleTournament.Builder<T> builder()
      Creates a builder for ImmutableDoubleTournament.
       ImmutableDoubleTournament.&lt;T&gt;builder()
          .fitnessTournament(net.bmahe.genetics4j.core.spec.selection.Tournament&lt;T&gt;) // required fitnessTournament
          .parsimonyComparator(Comparator&lt;net.bmahe.genetics4j.core.Individual&lt;T&gt;&gt;) // required parsimonyComparator
          .parsimonyTournamentSize(double) // required parsimonyTournamentSize
          .doFitnessFirst(boolean) // optional doFitnessFirst
          .build();
       
      Type Parameters:
      T - generic parameter T
      Returns:
      A new ImmutableDoubleTournament builder