Record Class MetricLimit.ScalarLimit

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

public static record MetricLimit.ScalarLimit(String metricKey, String ruleCode, int limit, MetricLimit.Comparison comparison) extends Record implements MetricLimit
A single-threshold limit with a comparator.
  • Constructor Details

    • ScalarLimit

      public ScalarLimit(String metricKey, String ruleCode, int limit, MetricLimit.Comparison comparison)
      Creates an instance of a ScalarLimit record class.
      Parameters:
      metricKey - the value for the metricKey record component
      ruleCode - the value for the ruleCode record component
      limit - the value for the limit record component
      comparison - the value for the comparison record component
  • Method Details

    • isOver

      public boolean isOver(int value)
      The exact predicate the checker uses to fire.
    • usableMax

      public int usableMax()
      The largest value that does NOT fire — limit for GT, limit - 1 for GTE. This is the "one more crosses" boundary the enquiry bands are computed from.
    • 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
    • limit

      public int limit()
      Returns the value of the limit record component.
      Returns:
      the value of the limit record component
    • comparison

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