Package forestry.api.genetics.alleles
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 chromosomeinactive- 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 -
Constructor Summary
ConstructorsConstructorDescriptionAllelePair(A active, A inactive) Creates an instance of aAllelePairrecord class. -
Method Summary
Modifier and TypeMethodDescriptionactive()Returns the value of theactiverecord 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 booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.inactive()Returns the value of theinactiverecord 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.booleanfinal StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
-
-
Constructor Details
-
Method Details
-
both
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
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
-
isSameAlleles
public boolean isSameAlleles()- Returns:
trueif the active allele is the same as the inactive allele.
-
create
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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
active
Returns the value of theactiverecord component.- Returns:
- the value of the
activerecord component
-
inactive
Returns the value of theinactiverecord component.- Returns:
- the value of the
inactiverecord component
-