Record Class ConnectionTestResult
java.lang.Object
java.lang.Record
cloud.opencode.base.email.ConnectionTestResult
public record ConnectionTestResult(boolean success, String serverGreeting, Duration latency, String errorMessage, Throwable cause)
extends Record
SMTP Connection Test Result
SMTP连接测试结果
Result of testing SMTP server connectivity and authentication.
测试SMTP服务器连接和认证的结果。
Features | 主要功能:
- Connection status - 连接状态
- Latency measurement - 延迟测量
- Error details - 错误详情
Usage Examples | 使用示例:
ConnectionTestResult result = sender.testConnection();
if (result.success()) {
System.out.println("Connected in " + result.latency().toMillis() + "ms");
} else {
System.err.println("Failed: " + result.errorMessage());
}
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Since:
- JDK 25, opencode-base-email V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConnectionTestResult(boolean success, String serverGreeting, Duration latency, String errorMessage, Throwable cause) Creates an instance of aConnectionTestResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncause()Returns the value of thecauserecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theerrorMessagerecord component.static ConnectionTestResultCreate a failed test result 创建失败的测试结果final inthashCode()Returns a hash code value for this object.latency()Returns the value of thelatencyrecord component.Returns the value of theserverGreetingrecord component.booleansuccess()Returns the value of thesuccessrecord component.static ConnectionTestResultCreate a successful test result 创建成功的测试结果final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ConnectionTestResult
public ConnectionTestResult(boolean success, String serverGreeting, Duration latency, String errorMessage, Throwable cause) Creates an instance of aConnectionTestResultrecord class.- Parameters:
success- the value for thesuccessrecord componentserverGreeting- the value for theserverGreetingrecord componentlatency- the value for thelatencyrecord componenterrorMessage- the value for theerrorMessagerecord componentcause- the value for thecauserecord component
-
-
Method Details
-
success
Create a successful test result 创建成功的测试结果- Parameters:
serverGreeting- the SMTP server greeting | SMTP服务器问候语latency- the connection latency | 连接延迟- Returns:
- the result | 结果
-
failure
Create a failed test result 创建失败的测试结果- Parameters:
errorMessage- the error message | 错误消息cause- the exception cause | 异常原因latency- the time spent before failure | 失败前的耗时- Returns:
- the result | 结果
-
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. -
success
public boolean success()Returns the value of thesuccessrecord component.- Returns:
- the value of the
successrecord component
-
serverGreeting
Returns the value of theserverGreetingrecord component.- Returns:
- the value of the
serverGreetingrecord component
-
latency
Returns the value of thelatencyrecord component.- Returns:
- the value of the
latencyrecord component
-
errorMessage
Returns the value of theerrorMessagerecord component.- Returns:
- the value of the
errorMessagerecord component
-
cause
Returns the value of thecauserecord component.- Returns:
- the value of the
causerecord component
-