Record Class AllelePair<V>

java.lang.Object
java.lang.Record
forestry.api.core.genetics.alleles.AllelePair<V>
Type Parameters:
V - The type of value held by this pair's alleles.
Record Components:
active - The active (expressed) allele for the chromosome.
inactive - The inactive allele for the chromosome.

public record AllelePair<V>(Allele<V> active, Allele<V> inactive) extends Record
A pair of an active allele and an inactive allele for one chromosome of a IGenome.

Alleles are inline values (Allele); the pair is serialized per-chromosome by the karyotype's genome codec, built from each chromosome's value codec. There is no global allele registry.

  • Constructor Details

    • AllelePair

      public AllelePair(Allele<V> active, Allele<V> inactive)
      Creates an instance of a AllelePair record class.
      Parameters:
      active - the value for the active record component
      inactive - the value for the inactive record component
  • Method Details

    • both

      public static <V> AllelePair<V> both(Allele<V> allele)
      Creates an allele pair where both the active and inactive alleles are the same.
    • inheritOther

      public AllelePair<V> inheritOther(net.minecraft.util.RandomSource rand, AllelePair<V> other)
      Creates a new pair out of one allele from this pair and one from the other pair, ordered by dominance.
    • inheritHaploid

      public AllelePair<V> inheritHaploid(net.minecraft.util.RandomSource rand)
    • isSameAlleles

      public boolean isSameAlleles()
      Returns:
      true if the active allele equals the inactive allele.
    • create

      public static <V> AllelePair<V> create(Allele<V> first, Allele<V> second)
      A pair where the active allele is the first dominant allele and the inactive allele is the other. THIS IS DIFFERENT THAN THE CONSTRUCTOR.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • active

      public Allele<V> active()
      Returns the value of the active record component.
      Returns:
      the value of the active record component
    • inactive

      public Allele<V> inactive()
      Returns the value of the inactive record component.
      Returns:
      the value of the inactive record component