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 ClassesModifier and TypeClassDescriptionstatic classEmail Query Builder 邮件查询构建器static enumSort order for email queries 邮件查询排序顺序 -
Constructor Summary
ConstructorsConstructorDescriptionEmailQuery(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 aEmailQueryrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thebodyContainsrecord component.static EmailQuery.Builderbuilder()Create a new builder 创建新的构建器final booleanIndicates whether some other object is "equal to" this one.booleanReturns the value of theflaggedOnlyrecord component.folder()Returns the value of thefolderrecord component.static EmailQueryforFolder(EmailFolder folder) Create a query for all emails in folder 创建查询文件夹中所有邮件的查询static EmailQueryCreate a query for all emails in folder 创建查询文件夹中所有邮件的查询from()Returns the value of thefromrecord component.fromDate()Returns the value of thefromDaterecord component.booleanReturns the value of thehasAttachmentsrecord component.booleanCheck if query has any filters 检查查询是否有任何过滤条件final inthashCode()Returns a hash code value for this object.booleanReturns the value of theincludeDeletedrecord component.intlimit()Returns the value of thelimitrecord component.intoffset()Returns the value of theoffsetrecord component.Returns the value of thesortOrderrecord component.Returns the value of thesubjectContainsrecord component.to()Returns the value of thetorecord component.toDate()Returns the value of thetoDaterecord component.final StringtoString()Returns a string representation of this record class.static EmailQueryunread()Create a query for all unread emails 创建查询所有未读邮件的查询booleanReturns the value of theunreadOnlyrecord component.
-
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 aEmailQueryrecord class.- Parameters:
folder- the value for thefolderrecord componentfromDate- the value for thefromDaterecord componenttoDate- the value for thetoDaterecord componentfrom- the value for thefromrecord componentto- the value for thetorecord componentsubjectContains- the value for thesubjectContainsrecord componentbodyContains- the value for thebodyContainsrecord componentunreadOnly- the value for theunreadOnlyrecord componentflaggedOnly- the value for theflaggedOnlyrecord componenthasAttachments- the value for thehasAttachmentsrecord componentincludeDeleted- the value for theincludeDeletedrecord componentlimit- the value for thelimitrecord componentoffset- the value for theoffsetrecord componentsortOrder- the value for thesortOrderrecord component
-
-
Method Details
-
builder
-
unread
Create a query for all unread emails 创建查询所有未读邮件的查询- Returns:
- the query | 查询
-
forFolder
Create a query for all emails in folder 创建查询文件夹中所有邮件的查询- Parameters:
folder- the folder | 文件夹- Returns:
- the query | 查询
-
forFolder
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
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
folder
Returns the value of thefolderrecord component.- Returns:
- the value of the
folderrecord component
-
fromDate
Returns the value of thefromDaterecord component.- Returns:
- the value of the
fromDaterecord component
-
toDate
Returns the value of thetoDaterecord component.- Returns:
- the value of the
toDaterecord component
-
from
-
to
-
subjectContains
Returns the value of thesubjectContainsrecord component.- Returns:
- the value of the
subjectContainsrecord component
-
bodyContains
Returns the value of thebodyContainsrecord component.- Returns:
- the value of the
bodyContainsrecord component
-
unreadOnly
public boolean unreadOnly()Returns the value of theunreadOnlyrecord component.- Returns:
- the value of the
unreadOnlyrecord component
-
flaggedOnly
public boolean flaggedOnly()Returns the value of theflaggedOnlyrecord component.- Returns:
- the value of the
flaggedOnlyrecord component
-
hasAttachments
public boolean hasAttachments()Returns the value of thehasAttachmentsrecord component.- Returns:
- the value of the
hasAttachmentsrecord component
-
includeDeleted
public boolean includeDeleted()Returns the value of theincludeDeletedrecord component.- Returns:
- the value of the
includeDeletedrecord component
-
limit
public int limit()Returns the value of thelimitrecord component.- Returns:
- the value of the
limitrecord component
-
offset
public int offset()Returns the value of theoffsetrecord component.- Returns:
- the value of the
offsetrecord component
-
sortOrder
Returns the value of thesortOrderrecord component.- Returns:
- the value of the
sortOrderrecord component
-