Record Class TraitImplementationAnalyzer.TraitAnalysis
java.lang.Object
java.lang.Record
org.ek9lang.compiler.phase5.TraitImplementationAnalyzer.TraitAnalysis
- Record Components:
traitName- 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
-
Constructor Summary
ConstructorsConstructorDescriptionTraitAnalysis(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.intReturns the value of thetraitMethodCountrecord component.Returns the value of thetraitNamerecord component.
-
Constructor Details
-
TraitAnalysis
TraitAnalysis(String traitName, int traitMethodCount, int overriddenMethodCount, boolean hasCompatibleField, String compatibleFieldName) Creates an instance of aTraitAnalysisrecord class.- Parameters:
traitName- 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. -
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
-