Record Class AllelePair<A extends IAllele>

java.lang.Object
java.lang.Record
forestry.api.genetics.alleles.AllelePair<A>
Type Parameters:
A - The generic type of allele this pair holds.
Record Components:
active - The active allele for the chromosome
inactive - The inactive allele for the chromosome

public record AllelePair<A extends IAllele>(A extends IAllele active, A extends IAllele inactive) extends Record
A pair of an active allele and an inactive allele, for use in a IGenome.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<AllelePair<?>>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    AllelePair(A active, A inactive)
    Creates an instance of a AllelePair record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the active record component.
    static <A extends IAllele>
    AllelePair<A>
    both(A allele)
    Creates an allele pair where both the active and inactive alleles are the same.
    static <A extends IAllele>
    AllelePair<A>
    create(A firstAllele, A secondAllele)
    A new chromosome pair where the active allele is the first dominant allele and the inactive allele is the other allele.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the inactive record component.
    inheritHaploid(net.minecraft.util.RandomSource rand)
     
    inheritOther(net.minecraft.util.RandomSource rand, AllelePair<A> other)
    Creates a new chromosome out of the alleles of this chromosome and the other chromosome.
    boolean
     
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<AllelePair<?>> CODEC
  • Constructor Details

    • AllelePair

      public AllelePair(A active, A 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 <A extends IAllele> AllelePair<A> both(A allele)
      Creates an allele pair where both the active and inactive alleles are the same.
      Type Parameters:
      A - The generic type of the allele class.
      Parameters:
      allele - The allele.
      Returns:
      A new pair with the same value for both its active and inactive allele.
    • inheritOther

      public AllelePair<A> inheritOther(net.minecraft.util.RandomSource rand, AllelePair<A> other)
      Creates a new chromosome out of the alleles of this chromosome and the other chromosome. It always uses one allele from this and one from the other chromosome to create the new chromosome.
      Parameters:
      rand - The instance of random it should uses to figure out which of the two alleles if should use.
      other - The other chromosome that this chromosome uses to create the new one.
    • inheritHaploid

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

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

      public static <A extends IAllele> AllelePair<A> create(A firstAllele, A secondAllele)
      A new chromosome pair where the active allele is the first dominant allele and the inactive allele is the other allele. THIS IS DIFFERENT THAN THE CONSTRUCTOR, AllelePair(A, A).
      Returns:
      A chromosome pair of two alleles in order of allele dominance.
    • 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 A active()
      Returns the value of the active record component.
      Returns:
      the value of the active record component
    • inactive

      public A inactive()
      Returns the value of the inactive record component.
      Returns:
      the value of the inactive record component