Record Class BatchResult

java.lang.Object
java.lang.Record
cloud.opencode.base.sms.batch.BatchResult
Record Components:
results - individual results | 单条结果列表
totalCount - total message count | 总消息数
successCount - success count | 成功数
failureCount - failure count | 失败数
startTime - batch start time | 批次开始时间
endTime - batch end time | 批次结束时间

public record BatchResult(List<SmsResult> results, int totalCount, int successCount, int failureCount, Instant startTime, Instant endTime) extends Record
Batch Result 批量发送结果

Aggregated result of batch SMS sending.

批量短信发送的聚合结果。

Features | 主要功能:

  • Success/failure counts and timing - 成功/失败计数和耗时
  • Individual result access - 单条结果访问
  • Immutable result record - 不可变结果记录

Usage Examples | 使用示例:

BatchResult result = BatchResult.of(resultList, startTime);
boolean allOk = result.isAllSuccess();
int failures = result.failureCount();

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
Since:
JDK 25, opencode-base-sms V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • BatchResult

      public BatchResult(List<SmsResult> results, int totalCount, int successCount, int failureCount, Instant startTime, Instant endTime)
      Creates an instance of a BatchResult record class.
      Parameters:
      results - the value for the results record component
      totalCount - the value for the totalCount record component
      successCount - the value for the successCount record component
      failureCount - the value for the failureCount record component
      startTime - the value for the startTime record component
      endTime - the value for the endTime record component
  • Method Details

    • of

      public static BatchResult of(List<SmsResult> results, Instant startTime)
      Create batch result from results 从结果列表创建批量结果
      Parameters:
      results - the results | 结果列表
      startTime - the start time | 开始时间
      Returns:
      the batch result | 批量结果
    • empty

      public static BatchResult empty()
      Create empty batch result 创建空批量结果
      Returns:
      the empty result | 空结果
    • isAllSuccess

      public boolean isAllSuccess()
      Check if all succeeded 检查是否全部成功
      Returns:
      true if all succeeded | 如果全部成功返回true
    • isAllFailed

      public boolean isAllFailed()
      Check if all failed 检查是否全部失败
      Returns:
      true if all failed | 如果全部失败返回true
    • isPartialSuccess

      public boolean isPartialSuccess()
      Check if partial success 检查是否部分成功
      Returns:
      true if partial | 如果部分成功返回true
    • getSuccessRate

      public double getSuccessRate()
      Get success rate 获取成功率
      Returns:
      the success rate (0.0 - 1.0) | 成功率
    • getDuration

      public Duration getDuration()
      Get duration 获取耗时
      Returns:
      the duration | 耗时
    • getSuccessResults

      public List<SmsResult> getSuccessResults()
      Get success results 获取成功结果
      Returns:
      the success results | 成功结果
    • getFailureResults

      public List<SmsResult> getFailureResults()
      Get failure results 获取失败结果
      Returns:
      the failure results | 失败结果
    • getFailureCountsByCode

      public Map<String,Long> getFailureCountsByCode()
      Get failure counts by error code 按错误码获取失败统计
      Returns:
      the error code counts | 错误码统计
    • getThroughput

      public double getThroughput()
      Get throughput (messages per second) 获取吞吐量(每秒消息数)
      Returns:
      the throughput | 吞吐量
    • toString

      public 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.
    • results

      public List<SmsResult> results()
      Returns the value of the results record component.
      Returns:
      the value of the results record component
    • totalCount

      public int totalCount()
      Returns the value of the totalCount record component.
      Returns:
      the value of the totalCount record component
    • successCount

      public int successCount()
      Returns the value of the successCount record component.
      Returns:
      the value of the successCount record component
    • failureCount

      public int failureCount()
      Returns the value of the failureCount record component.
      Returns:
      the value of the failureCount record component
    • startTime

      public Instant startTime()
      Returns the value of the startTime record component.
      Returns:
      the value of the startTime record component
    • endTime

      public Instant endTime()
      Returns the value of the endTime record component.
      Returns:
      the value of the endTime record component