Record Class EmailReceiveConfig
java.lang.Object
java.lang.Record
cloud.opencode.base.email.EmailReceiveConfig
public record EmailReceiveConfig(String host, int port, String username, String password, String oauth2Token, EmailReceiveConfig.Protocol protocol, boolean ssl, boolean starttls, Duration timeout, Duration connectionTimeout, String defaultFolder, int maxMessages, boolean deleteAfterReceive, boolean markAsReadAfterReceive, boolean debug)
extends Record
Email Receive Configuration Record
邮件接收配置记录
Immutable configuration for IMAP/POP3 email receiving.
用于IMAP/POP3邮件接收的不可变配置。
Features | 主要功能:
- IMAP/POP3 protocol support - IMAP/POP3协议支持
- SSL/TLS configuration - SSL/TLS配置
- Connection pool settings - 连接池设置
- Timeout configuration - 超时配置
- Folder preferences - 文件夹偏好设置
Usage Examples | 使用示例:
// IMAP configuration
EmailReceiveConfig config = EmailReceiveConfig.builder()
.host("imap.example.com")
.username("user@example.com")
.password("password")
.imap()
.ssl(true)
.build();
// POP3 configuration
EmailReceiveConfig config = EmailReceiveConfig.builder()
.host("pop3.example.com")
.port(995)
.username("user")
.password("pass")
.pop3()
.ssl(true)
.build();
// OAuth2 configuration (Gmail/Outlook)
EmailReceiveConfig config = EmailReceiveConfig.builder()
.host("imap.gmail.com")
.username("user@gmail.com")
.oauth2Token(accessToken)
.imap()
.ssl(true)
.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 Receive Configuration Builder 邮件接收配置构建器static enumEmail receiving protocol 邮件接收协议 -
Constructor Summary
ConstructorsConstructorDescriptionEmailReceiveConfig(String host, int port, String username, String password, String oauth2Token, EmailReceiveConfig.Protocol protocol, boolean ssl, boolean starttls, Duration timeout, Duration connectionTimeout, String defaultFolder, int maxMessages, boolean deleteAfterReceive, boolean markAsReadAfterReceive, boolean debug) Creates an instance of aEmailReceiveConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic EmailReceiveConfig.Builderbuilder()Create a new builder 创建新的构建器Returns the value of theconnectionTimeoutrecord component.booleandebug()Returns the value of thedebugrecord component.Returns the value of thedefaultFolderrecord component.booleanReturns the value of thedeleteAfterReceiverecord component.final booleanIndicates whether some other object is "equal to" this one.Get the store protocol name for Jakarta Mail 获取Jakarta Mail的存储协议名称final inthashCode()Returns a hash code value for this object.booleanCheck if OAuth2 authentication is configured 检查是否配置了OAuth2认证host()Returns the value of thehostrecord component.booleanisImap()Check if IMAP protocol is used 检查是否使用IMAP协议booleanisPop3()Check if POP3 protocol is used 检查是否使用POP3协议booleanReturns the value of themarkAsReadAfterReceiverecord component.intReturns the value of themaxMessagesrecord component.Returns the value of theoauth2Tokenrecord component.password()Returns the value of thepasswordrecord component.intport()Returns the value of theportrecord component.protocol()Returns the value of theprotocolrecord component.booleanCheck if authentication is required 检查是否需要认证booleanssl()Returns the value of thesslrecord component.booleanstarttls()Returns the value of thestarttlsrecord component.timeout()Returns the value of thetimeoutrecord component.toString()Return string representation with masked sensitive fields 返回屏蔽敏感字段的字符串表示username()Returns the value of theusernamerecord component.
-
Constructor Details
-
EmailReceiveConfig
public EmailReceiveConfig(String host, int port, String username, String password, String oauth2Token, EmailReceiveConfig.Protocol protocol, boolean ssl, boolean starttls, Duration timeout, Duration connectionTimeout, String defaultFolder, int maxMessages, boolean deleteAfterReceive, boolean markAsReadAfterReceive, boolean debug) Creates an instance of aEmailReceiveConfigrecord class.- Parameters:
host- the value for thehostrecord componentport- the value for theportrecord componentusername- the value for theusernamerecord componentpassword- the value for thepasswordrecord componentoauth2Token- the value for theoauth2Tokenrecord componentprotocol- the value for theprotocolrecord componentssl- the value for thesslrecord componentstarttls- the value for thestarttlsrecord componenttimeout- the value for thetimeoutrecord componentconnectionTimeout- the value for theconnectionTimeoutrecord componentdefaultFolder- the value for thedefaultFolderrecord componentmaxMessages- the value for themaxMessagesrecord componentdeleteAfterReceive- the value for thedeleteAfterReceiverecord componentmarkAsReadAfterReceive- the value for themarkAsReadAfterReceiverecord componentdebug- the value for thedebugrecord component
-
-
Method Details
-
builder
Create a new builder 创建新的构建器- Returns:
- the builder | 构建器
-
requiresAuth
public boolean requiresAuth()Check if authentication is required 检查是否需要认证- Returns:
- true if authentication is required | 需要认证返回true
-
hasOAuth2
public boolean hasOAuth2()Check if OAuth2 authentication is configured 检查是否配置了OAuth2认证- Returns:
- true if OAuth2 is configured | 配置了OAuth2返回true
-
getStoreProtocol
Get the store protocol name for Jakarta Mail 获取Jakarta Mail的存储协议名称- Returns:
- the store protocol name | 存储协议名称
-
isImap
public boolean isImap()Check if IMAP protocol is used 检查是否使用IMAP协议- Returns:
- true if using IMAP | 使用IMAP返回true
-
isPop3
public boolean isPop3()Check if POP3 protocol is used 检查是否使用POP3协议- Returns:
- true if using POP3 | 使用POP3返回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. -
host
Returns the value of thehostrecord component.- Returns:
- the value of the
hostrecord component
-
port
public int port()Returns the value of theportrecord component.- Returns:
- the value of the
portrecord component
-
username
Returns the value of theusernamerecord component.- Returns:
- the value of the
usernamerecord component
-
password
Returns the value of thepasswordrecord component.- Returns:
- the value of the
passwordrecord component
-
oauth2Token
Returns the value of theoauth2Tokenrecord component.- Returns:
- the value of the
oauth2Tokenrecord component
-
protocol
Returns the value of theprotocolrecord component.- Returns:
- the value of the
protocolrecord component
-
ssl
public boolean ssl()Returns the value of thesslrecord component.- Returns:
- the value of the
sslrecord component
-
starttls
public boolean starttls()Returns the value of thestarttlsrecord component.- Returns:
- the value of the
starttlsrecord component
-
timeout
Returns the value of thetimeoutrecord component.- Returns:
- the value of the
timeoutrecord component
-
connectionTimeout
Returns the value of theconnectionTimeoutrecord component.- Returns:
- the value of the
connectionTimeoutrecord component
-
defaultFolder
Returns the value of thedefaultFolderrecord component.- Returns:
- the value of the
defaultFolderrecord component
-
maxMessages
public int maxMessages()Returns the value of themaxMessagesrecord component.- Returns:
- the value of the
maxMessagesrecord component
-
deleteAfterReceive
public boolean deleteAfterReceive()Returns the value of thedeleteAfterReceiverecord component.- Returns:
- the value of the
deleteAfterReceiverecord component
-
markAsReadAfterReceive
public boolean markAsReadAfterReceive()Returns the value of themarkAsReadAfterReceiverecord component.- Returns:
- the value of the
markAsReadAfterReceiverecord component
-
debug
public boolean debug()Returns the value of thedebugrecord component.- Returns:
- the value of the
debugrecord component
-