Record Class MetricLimit.GenusLimit

java.lang.Object
java.lang.Record
org.ek9lang.compiler.support.MetricLimit.GenusLimit
All Implemented Interfaces:
MetricLimit
Enclosing interface:
MetricLimit

public static record MetricLimit.GenusLimit(String metricKey, String ruleCode, MetricLimit.Comparison comparison, Map<SymbolGenus, Integer> byGenus, int fallback, Set<SymbolGenus> exempt) extends Record implements MetricLimit
A per-genus threshold table: byGenus holds explicit limits, fallback covers genera not listed, and exempt genera are not checked at all (so limitFor(SymbolGenus) is empty and isOver(int, SymbolGenus) is always false for them).
  • Constructor Details

    • GenusLimit

      public GenusLimit(String metricKey, String ruleCode, MetricLimit.Comparison comparison, Map<SymbolGenus, Integer> byGenus, int fallback, Set<SymbolGenus> exempt)
      Creates an instance of a GenusLimit record class.
      Parameters:
      metricKey - the value for the metricKey record component
      ruleCode - the value for the ruleCode record component
      comparison - the value for the comparison record component
      byGenus - the value for the byGenus record component
      fallback - the value for the fallback record component
      exempt - the value for the exempt record component
  • Method Details

    • limitFor

      public Optional<Integer> limitFor(SymbolGenus genus)
      The effective limit for a genus, or empty when the genus is exempt from this metric entirely.
    • isOver

      public boolean isOver(int value, SymbolGenus genus)
      The exact predicate the checker uses to fire — false for exempt genera.
    • isOver

      public boolean isOver(double value, SymbolGenus genus)
      Fractional overload — construct coupling (E11015) is a fractional score once by delegation is weighted at 0.5, so the fire predicate compares a double against the integer limit.
    • usableMaxFor

      public Optional<Integer> usableMaxFor(SymbolGenus genus)
      The "one more crosses" boundary for a genus, or empty when exempt.
    • 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.
    • metricKey

      public String metricKey()
      Returns the value of the metricKey record component.
      Specified by:
      metricKey in interface MetricLimit
      Returns:
      the value of the metricKey record component
    • ruleCode

      public String ruleCode()
      Returns the value of the ruleCode record component.
      Specified by:
      ruleCode in interface MetricLimit
      Returns:
      the value of the ruleCode record component
    • comparison

      public MetricLimit.Comparison comparison()
      Returns the value of the comparison record component.
      Returns:
      the value of the comparison record component
    • byGenus

      public Map<SymbolGenus, Integer> byGenus()
      Returns the value of the byGenus record component.
      Returns:
      the value of the byGenus record component
    • fallback

      public int fallback()
      Returns the value of the fallback record component.
      Returns:
      the value of the fallback record component
    • exempt

      public Set<SymbolGenus> exempt()
      Returns the value of the exempt record component.
      Returns:
      the value of the exempt record component