Record Class EmailQuery

java.lang.Object
java.lang.Record
cloud.opencode.base.email.query.EmailQuery

public record EmailQuery(String folder, LocalDateTime fromDate, LocalDateTime toDate, Set<String> from, Set<String> to, String subjectContains, String bodyContains, boolean unreadOnly, boolean flaggedOnly, boolean hasAttachments, boolean includeDeleted, int limit, int offset, EmailQuery.SortOrder sortOrder) extends Record
Email Query Record 邮件查询记录

Immutable query configuration for filtering emails.

用于过滤邮件的不可变查询配置。

Features | 主要功能:

  • Folder selection - 文件夹选择
  • Date range filtering - 日期范围过滤
  • Sender/recipient filtering - 发件人/收件人过滤
  • Subject search - 主题搜索
  • Content search - 内容搜索
  • Flag filtering (unread, flagged) - 标记过滤(未读、星标)
  • Attachment filtering - 附件过滤
  • Pagination support - 分页支持

Usage Examples | 使用示例:

// Query unread emails from last 7 days
EmailQuery query = EmailQuery.builder()
    .folder(EmailFolder.INBOX)
    .fromDate(LocalDateTime.now().minusDays(7))
    .unreadOnly()
    .limit(100)
    .build();

// Query emails from specific sender
EmailQuery query = EmailQuery.builder()
    .from("sender@example.com")
    .subjectContains("Report")
    .build();

// Query flagged emails with attachments
EmailQuery query = EmailQuery.builder()
    .flaggedOnly()
    .hasAttachments()
    .build();

Security | 安全性:

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

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Email Query Builder 邮件查询构建器
    static enum 
    Sort order for email queries 邮件查询排序顺序
  • Constructor Summary

    Constructors
    Constructor
    Description
    EmailQuery(String folder, LocalDateTime fromDate, LocalDateTime toDate, Set<String> from, Set<String> to, String subjectContains, String bodyContains, boolean unreadOnly, boolean flaggedOnly, boolean hasAttachments, boolean includeDeleted, int limit, int offset, EmailQuery.SortOrder sortOrder)
    Creates an instance of a EmailQuery record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the bodyContains record component.
    Create a new builder 创建新的构建器
    final boolean
    Indicates whether some other object is "equal to" this one.
    boolean
    Returns the value of the flaggedOnly record component.
    Returns the value of the folder record component.
    static EmailQuery
    Create a query for all emails in folder 创建查询文件夹中所有邮件的查询
    static EmailQuery
    forFolder(String folder)
    Create a query for all emails in folder 创建查询文件夹中所有邮件的查询
    Returns the value of the from record component.
    Returns the value of the fromDate record component.
    boolean
    Returns the value of the hasAttachments record component.
    boolean
    Check if query has any filters 检查查询是否有任何过滤条件
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the includeDeleted record component.
    int
    Returns the value of the limit record component.
    int
    Returns the value of the offset record component.
    Returns the value of the sortOrder record component.
    Returns the value of the subjectContains record component.
    to()
    Returns the value of the to record component.
    Returns the value of the toDate record component.
    final String
    Returns a string representation of this record class.
    static EmailQuery
    Create a query for all unread emails 创建查询所有未读邮件的查询
    boolean
    Returns the value of the unreadOnly record component.

    Methods inherited from class Object

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

    • EmailQuery

      public EmailQuery(String folder, LocalDateTime fromDate, LocalDateTime toDate, Set<String> from, Set<String> to, String subjectContains, String bodyContains, boolean unreadOnly, boolean flaggedOnly, boolean hasAttachments, boolean includeDeleted, int limit, int offset, EmailQuery.SortOrder sortOrder)
      Creates an instance of a EmailQuery record class.
      Parameters:
      folder - the value for the folder record component
      fromDate - the value for the fromDate record component
      toDate - the value for the toDate record component
      from - the value for the from record component
      to - the value for the to record component
      subjectContains - the value for the subjectContains record component
      bodyContains - the value for the bodyContains record component
      unreadOnly - the value for the unreadOnly record component
      flaggedOnly - the value for the flaggedOnly record component
      hasAttachments - the value for the hasAttachments record component
      includeDeleted - the value for the includeDeleted record component
      limit - the value for the limit record component
      offset - the value for the offset record component
      sortOrder - the value for the sortOrder record component
  • Method Details

    • builder

      public static EmailQuery.Builder builder()
      Create a new builder 创建新的构建器
      Returns:
      the builder | 构建器
    • unread

      public static EmailQuery unread()
      Create a query for all unread emails 创建查询所有未读邮件的查询
      Returns:
      the query | 查询
    • forFolder

      public static EmailQuery forFolder(EmailFolder folder)
      Create a query for all emails in folder 创建查询文件夹中所有邮件的查询
      Parameters:
      folder - the folder | 文件夹
      Returns:
      the query | 查询
    • forFolder

      public static EmailQuery forFolder(String folder)
      Create a query for all emails in folder 创建查询文件夹中所有邮件的查询
      Parameters:
      folder - the folder name | 文件夹名称
      Returns:
      the query | 查询
    • hasFilters

      public boolean hasFilters()
      Check if query has any filters 检查查询是否有任何过滤条件
      Returns:
      true if has filters | 有过滤条件返回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.
    • folder

      public String folder()
      Returns the value of the folder record component.
      Returns:
      the value of the folder record component
    • fromDate

      public LocalDateTime fromDate()
      Returns the value of the fromDate record component.
      Returns:
      the value of the fromDate record component
    • toDate

      public LocalDateTime toDate()
      Returns the value of the toDate record component.
      Returns:
      the value of the toDate record component
    • from

      public Set<String> from()
      Returns the value of the from record component.
      Returns:
      the value of the from record component
    • to

      public Set<String> to()
      Returns the value of the to record component.
      Returns:
      the value of the to record component
    • subjectContains

      public String subjectContains()
      Returns the value of the subjectContains record component.
      Returns:
      the value of the subjectContains record component
    • bodyContains

      public String bodyContains()
      Returns the value of the bodyContains record component.
      Returns:
      the value of the bodyContains record component
    • unreadOnly

      public boolean unreadOnly()
      Returns the value of the unreadOnly record component.
      Returns:
      the value of the unreadOnly record component
    • flaggedOnly

      public boolean flaggedOnly()
      Returns the value of the flaggedOnly record component.
      Returns:
      the value of the flaggedOnly record component
    • hasAttachments

      public boolean hasAttachments()
      Returns the value of the hasAttachments record component.
      Returns:
      the value of the hasAttachments record component
    • includeDeleted

      public boolean includeDeleted()
      Returns the value of the includeDeleted record component.
      Returns:
      the value of the includeDeleted record component
    • limit

      public int limit()
      Returns the value of the limit record component.
      Returns:
      the value of the limit record component
    • offset

      public int offset()
      Returns the value of the offset record component.
      Returns:
      the value of the offset record component
    • sortOrder

      public EmailQuery.SortOrder sortOrder()
      Returns the value of the sortOrder record component.
      Returns:
      the value of the sortOrder record component