Record Class EmailFlags

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

public record EmailFlags(boolean seen, boolean answered, boolean flagged, boolean deleted, boolean draft, boolean recent) extends Record
Email Flags Record 邮件标记记录

Immutable record representing email status flags.

表示邮件状态标记的不可变记录。

Features | 主要功能:

  • Read/unread status - 已读/未读状态
  • Answered status - 已回复状态
  • Flagged/starred status - 标记/星标状态
  • Deleted status - 已删除状态
  • Draft status - 草稿状态
  • Recent status - 最近状态

Usage Examples | 使用示例:

// Check if email is unread
if (!email.flags().seen()) {
    processNewEmail(email);
}

// Check if email is flagged/starred
if (email.flags().flagged()) {
    highlightEmail(email);
}

Security | 安全性:

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

    Fields
    Modifier and Type
    Field
    Description
    static final EmailFlags
    Default flags for a read email 已读邮件的默认标记
    static final EmailFlags
    Default flags for a new unread email 新未读邮件的默认标记
  • Constructor Summary

    Constructors
    Constructor
    Description
    EmailFlags(boolean seen, boolean answered, boolean flagged, boolean deleted, boolean draft, boolean recent)
    Creates an instance of a EmailFlags record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the value of the answered record component.
    boolean
    Returns the value of the deleted record component.
    boolean
    Returns the value of the draft record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    boolean
    Returns the value of the flagged record component.
    static EmailFlags
    fromImapFlags(String imapFlags)
    Create flags from IMAP flags string 从IMAP标记字符串创建标记
    final int
    Returns a hash code value for this object.
    boolean
    Check if email is unread 检查邮件是否未读
    boolean
    Returns the value of the recent record component.
    boolean
    Returns the value of the seen record component.
    Convert to IMAP flags string 转换为IMAP标记字符串
    final String
    Returns a string representation of this record class.
    withAnswered(boolean answered)
    Create a copy with answered flag set 创建设置已回复标记的副本
    withDeleted(boolean deleted)
    Create a copy with deleted flag set 创建设置删除标记的副本
    withFlagged(boolean flagged)
    Create a copy with flagged status set 创建设置标记状态的副本
    withSeen(boolean seen)
    Create a copy with seen flag set 创建设置已读标记的副本

    Methods inherited from class Object

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

    • UNREAD

      public static final EmailFlags UNREAD
      Default flags for a new unread email 新未读邮件的默认标记
    • READ

      public static final EmailFlags READ
      Default flags for a read email 已读邮件的默认标记
  • Constructor Details

    • EmailFlags

      public EmailFlags(boolean seen, boolean answered, boolean flagged, boolean deleted, boolean draft, boolean recent)
      Creates an instance of a EmailFlags record class.
      Parameters:
      seen - the value for the seen record component
      answered - the value for the answered record component
      flagged - the value for the flagged record component
      deleted - the value for the deleted record component
      draft - the value for the draft record component
      recent - the value for the recent record component
  • Method Details

    • fromImapFlags

      public static EmailFlags fromImapFlags(String imapFlags)
      Create flags from IMAP flags string 从IMAP标记字符串创建标记

      Parses an IMAP FLAGS response string like "(\\Seen \\Flagged \\Answered)"

      解析IMAP FLAGS响应字符串,如 "(\\Seen \\Flagged \\Answered)"

      Parameters:
      imapFlags - the IMAP flags string (e.g., "(\\Seen \\Flagged)") | IMAP标记字符串
      Returns:
      the email flags | 邮件标记
    • toImapFlags

      public String toImapFlags()
      Convert to IMAP flags string 转换为IMAP标记字符串
      Returns:
      the IMAP flags string (e.g., "(\\Seen \\Flagged)") | IMAP标记字符串
    • isUnread

      public boolean isUnread()
      Check if email is unread 检查邮件是否未读
      Returns:
      true if unread | 未读返回true
    • withSeen

      public EmailFlags withSeen(boolean seen)
      Create a copy with seen flag set 创建设置已读标记的副本
      Parameters:
      seen - the seen flag | 已读标记
      Returns:
      new flags with updated seen status | 更新已读状态后的新标记
    • withFlagged

      public EmailFlags withFlagged(boolean flagged)
      Create a copy with flagged status set 创建设置标记状态的副本
      Parameters:
      flagged - the flagged status | 标记状态
      Returns:
      new flags with updated flagged status | 更新标记状态后的新标记
    • withDeleted

      public EmailFlags withDeleted(boolean deleted)
      Create a copy with deleted flag set 创建设置删除标记的副本
      Parameters:
      deleted - the deleted flag | 删除标记
      Returns:
      new flags with updated deleted status | 更新删除状态后的新标记
    • withAnswered

      public EmailFlags withAnswered(boolean answered)
      Create a copy with answered flag set 创建设置已回复标记的副本
      Parameters:
      answered - the answered flag | 已回复标记
      Returns:
      new flags with updated answered status | 更新已回复状态后的新标记
    • 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 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.
    • seen

      public boolean seen()
      Returns the value of the seen record component.
      Returns:
      the value of the seen record component
    • answered

      public boolean answered()
      Returns the value of the answered record component.
      Returns:
      the value of the answered record component
    • flagged

      public boolean flagged()
      Returns the value of the flagged record component.
      Returns:
      the value of the flagged record component
    • deleted

      public boolean deleted()
      Returns the value of the deleted record component.
      Returns:
      the value of the deleted record component
    • draft

      public boolean draft()
      Returns the value of the draft record component.
      Returns:
      the value of the draft record component
    • recent

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