Record Class CaptchaMetrics.MetricsSnapshot

java.lang.Object
java.lang.Record
cloud.opencode.base.captcha.support.CaptchaMetrics.MetricsSnapshot
Record Components:
totalGenerated - total CAPTCHAs generated | 生成的验证码总数
totalValidations - total validation attempts | 验证尝试总数
successfulValidations - successful validations | 验证成功次数
failedValidations - failed validations | 验证失败次数
successRate - validation success rate (0.0 to 1.0) | 验证成功率(0.0 到 1.0)
averageResponseTime - average validation response time | 平均验证响应时间
generationsByType - generation counts per type | 按类型的生成次数
uptime - time since metrics creation or last reset | 自指标创建或上次重置以来的时间
Enclosing class:
CaptchaMetrics

public static record CaptchaMetrics.MetricsSnapshot(long totalGenerated, long totalValidations, long successfulValidations, long failedValidations, double successRate, Duration averageResponseTime, Map<CaptchaType, Long> generationsByType, Duration uptime) extends Record
Immutable Metrics Snapshot - Point-in-time capture of all CAPTCHA metrics 不可变指标快照 - 所有验证码指标的时间点捕获

This record holds an immutable snapshot of all metric values at the time of creation. The generationsByType map is defensively copied.

此记录保存创建时所有指标值的不可变快照。generationsByType 映射会进行防御性复制。

Since:
JDK 25, opencode-base-captcha V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • MetricsSnapshot

      public MetricsSnapshot(long totalGenerated, long totalValidations, long successfulValidations, long failedValidations, double successRate, Duration averageResponseTime, Map<CaptchaType, Long> generationsByType, Duration uptime)
      Compact constructor that performs defensive copy of the generationsByType map. 紧凑构造器,对 generationsByType 映射执行防御性复制。
      Throws:
      NullPointerException - if averageResponseTime, generationsByType, or uptime is null | 如果 averageResponseTime、generationsByType 或 uptime 为 null
  • Method Details

    • 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.
    • totalGenerated

      public long totalGenerated()
      Returns the value of the totalGenerated record component.
      Returns:
      the value of the totalGenerated record component
    • totalValidations

      public long totalValidations()
      Returns the value of the totalValidations record component.
      Returns:
      the value of the totalValidations record component
    • successfulValidations

      public long successfulValidations()
      Returns the value of the successfulValidations record component.
      Returns:
      the value of the successfulValidations record component
    • failedValidations

      public long failedValidations()
      Returns the value of the failedValidations record component.
      Returns:
      the value of the failedValidations record component
    • successRate

      public double successRate()
      Returns the value of the successRate record component.
      Returns:
      the value of the successRate record component
    • averageResponseTime

      public Duration averageResponseTime()
      Returns the value of the averageResponseTime record component.
      Returns:
      the value of the averageResponseTime record component
    • generationsByType

      public Map<CaptchaType, Long> generationsByType()
      Returns the value of the generationsByType record component.
      Returns:
      the value of the generationsByType record component
    • uptime

      public Duration uptime()
      Returns the value of the uptime record component.
      Returns:
      the value of the uptime record component