Record Class BatchSendResult

java.lang.Object
java.lang.Record
cloud.opencode.base.email.BatchSendResult

public record BatchSendResult(List<BatchSendResult.ItemResult> results, Instant startedAt, Duration duration) extends Record
Batch Email Send Result 批量邮件发送结果

Contains the results of a batch email send operation, including individual results for each email.

包含批量邮件发送操作的结果,包括每封邮件的单独结果。

Features | 主要功能:

  • Individual results per email - 每封邮件的单独结果
  • Success/failure counts - 成功/失败计数
  • Total duration tracking - 总耗时跟踪

Usage Examples | 使用示例:

BatchSendResult result = sender.sendBatch(emails);
System.out.println("Sent: " + result.successCount() + "/" + result.totalCount());
result.failures().forEach(f -> log.error("Failed: {}", f.error()));

Security | 安全性:

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

    • BatchSendResult

      public BatchSendResult(List<BatchSendResult.ItemResult> results, Instant startedAt, Duration duration)
      Creates an instance of a BatchSendResult record class.
      Parameters:
      results - the value for the results record component
      startedAt - the value for the startedAt record component
      duration - the value for the duration record component
  • Method Details

    • totalCount

      public int totalCount()
      Get the total number of emails in the batch 获取批量中的邮件总数
      Returns:
      the total count | 总数
    • successCount

      public int successCount()
      Get the number of successfully sent emails 获取成功发送的邮件数量
      Returns:
      the success count | 成功数量
    • failureCount

      public int failureCount()
      Get the number of failed emails 获取发送失败的邮件数量
      Returns:
      the failure count | 失败数量
    • allSucceeded

      public boolean allSucceeded()
      Check if all emails were sent successfully 检查是否所有邮件都已成功发送
      Returns:
      true if all succeeded | 全部成功返回true
    • failures

      public List<BatchSendResult.ItemResult> failures()
      Get only the failed results 仅获取失败的结果
      Returns:
      list of failed results | 失败结果列表
    • successes

      public List<BatchSendResult.ItemResult> successes()
      Get only the successful results 仅获取成功的结果
      Returns:
      list of successful results | 成功结果列表
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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<BatchSendResult.ItemResult> results()
      Returns the value of the results record component.
      Returns:
      the value of the results record component
    • startedAt

      public Instant startedAt()
      Returns the value of the startedAt record component.
      Returns:
      the value of the startedAt record component
    • duration

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