Record Class SendResult

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

public record SendResult(String messageId, Instant sentAt, boolean success) extends Record
Email Send Result 邮件发送结果

Result of sending an email, containing the message ID for tracking.

发送邮件的结果,包含用于跟踪的消息ID。

Features | 主要功能:

  • Message ID for tracking - 用于跟踪的消息ID
  • Send timestamp - 发送时间戳
  • Success status - 成功状态

Usage Examples | 使用示例:

SendResult result = OpenEmail.sendWithResult(email);
System.out.println("Message ID: " + result.messageId());
System.out.println("Sent at: " + result.sentAt());

Security | 安全性:

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

    Constructors
    Constructor
    Description
    SendResult(String messageId, Instant sentAt, boolean success)
    Creates an instance of a SendResult record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    static SendResult
    Create a failed send result 创建失败的发送结果
    final int
    Returns a hash code value for this object.
    boolean
    Check if the message has a message ID 检查消息是否有消息ID
    Returns the value of the messageId record component.
    Returns the value of the sentAt record component.
    boolean
    Returns the value of the success record component.
    static SendResult
    success(String messageId)
    Create a successful send result 创建成功的发送结果
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SendResult

      public SendResult(String messageId, Instant sentAt, boolean success)
      Creates an instance of a SendResult record class.
      Parameters:
      messageId - the value for the messageId record component
      sentAt - the value for the sentAt record component
      success - the value for the success record component
  • Method Details

    • success

      public static SendResult success(String messageId)
      Create a successful send result 创建成功的发送结果
      Parameters:
      messageId - the message ID | 消息ID
      Returns:
      the send result | 发送结果
    • failure

      public static SendResult failure()
      Create a failed send result 创建失败的发送结果
      Returns:
      the send result | 发送结果
    • hasMessageId

      public boolean hasMessageId()
      Check if the message has a message ID 检查消息是否有消息ID
      Returns:
      true if message ID is present | 存在消息ID返回true
    • 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.
    • messageId

      public String messageId()
      Returns the value of the messageId record component.
      Returns:
      the value of the messageId record component
    • sentAt

      public Instant sentAt()
      Returns the value of the sentAt record component.
      Returns:
      the value of the sentAt record component
    • success

      public boolean success()
      Returns the value of the success record component.
      Returns:
      the value of the success record component