Record Class TraitImplementationAnalyzer.TraitAnalysis

java.lang.Object
java.lang.Record
org.ek9lang.compiler.phase5.TraitImplementationAnalyzer.TraitAnalysis
Record Components:
traitName - Name of the trait being analyzed
traitMethodCount - Total number of methods in the trait
overriddenMethodCount - Number of those methods overridden in this class
hasCompatibleField - Whether the class has a field assignable to the trait
compatibleFieldName - Name of the compatible field (if found)
Enclosing class:
TraitImplementationAnalyzer

static record TraitImplementationAnalyzer.TraitAnalysis(String traitName, int traitMethodCount, int overriddenMethodCount, boolean hasCompatibleField, String compatibleFieldName) extends Record
Result of analyzing trait implementation for potential missing 'by' delegation.
  • Constructor Details

    • TraitAnalysis

      TraitAnalysis(String traitName, int traitMethodCount, int overriddenMethodCount, boolean hasCompatibleField, String compatibleFieldName)
      Creates an instance of a TraitAnalysis record class.
      Parameters:
      traitName - the value for the traitName record component
      traitMethodCount - the value for the traitMethodCount record component
      overriddenMethodCount - the value for the overriddenMethodCount record component
      hasCompatibleField - the value for the hasCompatibleField record component
      compatibleFieldName - the value for the compatibleFieldName record 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

      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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • traitName

      public String traitName()
      Returns the value of the traitName record component.
      Returns:
      the value of the traitName record component
    • traitMethodCount

      public int traitMethodCount()
      Returns the value of the traitMethodCount record component.
      Returns:
      the value of the traitMethodCount record component
    • overriddenMethodCount

      public int overriddenMethodCount()
      Returns the value of the overriddenMethodCount record component.
      Returns:
      the value of the overriddenMethodCount record component
    • hasCompatibleField

      public boolean hasCompatibleField()
      Returns the value of the hasCompatibleField record component.
      Returns:
      the value of the hasCompatibleField record component
    • compatibleFieldName

      public String compatibleFieldName()
      Returns the value of the compatibleFieldName record component.
      Returns:
      the value of the compatibleFieldName record component