Record Class TraitImplementationAnalyzer.TraitAnalysis
java.lang.Object
java.lang.Record
org.ek9lang.compiler.phase5.TraitImplementationAnalyzer.TraitAnalysis
- Record Components:
trait- The trait being analyzedtraitName- Name of the trait being analyzedtraitMethodCount- Total number of methods in the traitoverriddenMethodCount- Number of those methods overridden in this classhasCompatibleField- Whether the class has a field assignable to the traitcompatibleFieldName- Name of the compatible field (if found)
- Enclosing class:
TraitImplementationAnalyzer
static record TraitImplementationAnalyzer.TraitAnalysis(IAggregateSymbol trait, String traitName, int traitMethodCount, int overriddenMethodCount, boolean hasCompatibleField, String compatibleFieldName)
extends Record
Result of analyzing trait implementation for potential missing 'by' delegation.
-
Constructor Summary
ConstructorsConstructorDescriptionTraitAnalysis(IAggregateSymbol trait, String traitName, int traitMethodCount, int overriddenMethodCount, boolean hasCompatibleField, String compatibleFieldName) Creates an instance of aTraitAnalysisrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecompatibleFieldNamerecord component.final booleanIndicates whether some other object is "equal to" this one.booleanReturns the value of thehasCompatibleFieldrecord component.final inthashCode()Returns a hash code value for this object.(package private) booleanlikelyManualForwarding(int minMethods, double minPercentage) Determine if this looks like manual forwarding that should use 'by'.intReturns the value of theoverriddenMethodCountrecord component.(package private) doubleCalculate the percentage of trait methods that are overridden.final StringtoString()Returns a string representation of this record class.trait()Returns the value of thetraitrecord component.intReturns the value of thetraitMethodCountrecord component.Returns the value of thetraitNamerecord component.
-
Constructor Details
-
TraitAnalysis
TraitAnalysis(IAggregateSymbol trait, String traitName, int traitMethodCount, int overriddenMethodCount, boolean hasCompatibleField, String compatibleFieldName) Creates an instance of aTraitAnalysisrecord class.- Parameters:
trait- the value for thetraitrecord componenttraitName- the value for thetraitNamerecord componenttraitMethodCount- the value for thetraitMethodCountrecord componentoverriddenMethodCount- the value for theoverriddenMethodCountrecord componenthasCompatibleField- the value for thehasCompatibleFieldrecord componentcompatibleFieldName- the value for thecompatibleFieldNamerecord component
-
-
Method Details
-
overriddenPercentage
double overriddenPercentage()Calculate the percentage of trait methods that are overridden. -
likelyManualForwarding
boolean likelyManualForwarding(int minMethods, double minPercentage) Determine if this looks like manual forwarding that should use 'by'. Criteria: - Has a compatible field to delegate to - Most/all trait methods are overridden (>= 70%) - At least MIN_METHODS methods are overridden (to avoid false positives on small traits) -
toString
-
hashCode
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
trait
-
traitName
-
traitMethodCount
public int traitMethodCount()Returns the value of thetraitMethodCountrecord component.- Returns:
- the value of the
traitMethodCountrecord component
-
overriddenMethodCount
public int overriddenMethodCount()Returns the value of theoverriddenMethodCountrecord component.- Returns:
- the value of the
overriddenMethodCountrecord component
-
hasCompatibleField
public boolean hasCompatibleField()Returns the value of thehasCompatibleFieldrecord component.- Returns:
- the value of the
hasCompatibleFieldrecord component
-
compatibleFieldName
Returns the value of thecompatibleFieldNamerecord component.- Returns:
- the value of the
compatibleFieldNamerecord component
-