Class ImmutableProportionalTournament<T extends Comparable<T>>

java.lang.Object
net.bmahe.genetics4j.core.spec.selection.ImmutableProportionalTournament<T>
All Implemented Interfaces:
ProportionalTournament<T>, SelectionPolicy

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

  • Field Details

  • Constructor Details

  • Method Details

    • numCandidates

      public int numCandidates()
      Specified by:
      numCandidates in interface ProportionalTournament<T extends Comparable<T>>
      Returns:
      The value of the numCandidates attribute
    • proportionFirst

      public double proportionFirst()
      Specified by:
      proportionFirst in interface ProportionalTournament<T extends Comparable<T>>
      Returns:
      The value of the proportionFirst attribute
    • firstComparator

      public Comparator<Individual<T>> firstComparator()
      Specified by:
      firstComparator in interface ProportionalTournament<T extends Comparable<T>>
      Returns:
      The value of the firstComparator attribute
    • secondComparator

      public Comparator<Individual<T>> secondComparator()
      Specified by:
      secondComparator in interface ProportionalTournament<T extends Comparable<T>>
      Returns:
      The value of the secondComparator attribute
    • withNumCandidates

      public final ImmutableProportionalTournament<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
    • withProportionFirst

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

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

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

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

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

      public String toString()
      Prints the immutable value ProportionalTournament with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • 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 immutable ProportionalTournament instance.
      Type Parameters:
      T - generic parameter T
      Parameters:
      numCandidates - The value for the numCandidates attribute
      proportionFirst - The value for the proportionFirst attribute
      firstComparator - The value for the firstComparator attribute
      secondComparator - The value for the secondComparator attribute
      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 a ProportionalTournament 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 ProportionalTournament instance
    • builder

      public static <T extends Comparable<T>> ImmutableProportionalTournament.Builder<T> builder()
      Creates a builder for ProportionalTournament.
       ImmutableProportionalTournament.&lt;T&gt;builder()
          .numCandidates(int) // required numCandidates
          .proportionFirst(double) // required proportionFirst
          .firstComparator(Comparator&lt;net.bmahe.genetics4j.core.Individual&lt;T&gt;&gt;) // required firstComparator
          .secondComparator(Comparator&lt;net.bmahe.genetics4j.core.Individual&lt;T&gt;&gt;) // required secondComparator
          .build();
       
      Type Parameters:
      T - generic parameter T
      Returns:
      A new ProportionalTournament builder