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

  • Field Details

  • Constructor Details

    • ImmutableTournament

      private ImmutableTournament(int numCandidates)
    • ImmutableTournament

      private ImmutableTournament(ImmutableTournament.Builder<T> builder)
    • ImmutableTournament

      private ImmutableTournament(int numCandidates, Comparator<Individual<T>> comparator)
  • Method Details

    • numCandidates

      public int numCandidates()
      Specified by:
      numCandidates in class Tournament<T extends Comparable<T>>
      Returns:
      The value of the numCandidates attribute
    • comparator

      public Comparator<Individual<T>> comparator()
      Overrides:
      comparator in class Tournament<T extends Comparable<T>>
      Returns:
      The value of the comparator attribute
    • withNumCandidates

      public final ImmutableTournament<T> withNumCandidates(int value)
      Copy the current immutable object by setting a value for the numCandidates attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for numCandidates
      Returns:
      A modified copy of the this object
    • withComparator

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

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableTournament 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, ImmutableTournament<?> another)
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: numCandidates, comparator.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public static <T extends Comparable<T>> Tournament<T> of(int numCandidates)
      Construct a new immutable Tournament instance.
      Type Parameters:
      T - generic parameter T
      Parameters:
      numCandidates - The value for the numCandidates attribute
      Returns:
      An immutable Tournament instance
    • copyOf

      public static <T extends Comparable<T>> Tournament<T> copyOf(Tournament<T> instance)
      Creates an immutable copy of a Tournament 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