Record Class SmsResult
java.lang.Object
java.lang.Record
cloud.opencode.base.sms.message.SmsResult
- Record Components:
success- whether send succeeded | 是否发送成功messageId- the message ID | 消息IDphoneNumber- the phone number | 手机号码errorCode- the error code if failed | 失败时的错误码errorMessage- the error message if failed | 失败时的错误消息timestamp- the timestamp | 时间戳
public record SmsResult(boolean success, String messageId, String phoneNumber, String errorCode, String errorMessage, Instant timestamp)
extends Record
SMS Result
短信结果
Result of sending an SMS message.
发送短信消息的结果。
Features | 主要功能:
- Success/failure status with message ID - 成功/失败状态及消息ID
- Error code and message for failures - 失败时的错误码和消息
- Factory methods for success and failure - 成功和失败的工厂方法
Usage Examples | 使用示例:
SmsResult ok = SmsResult.success("msg123", "13800138000");
SmsResult fail = SmsResult.failure("13800138000", "1001", "Send failed");
boolean sent = ok.success(); // true
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Since:
- JDK 25, opencode-base-sms V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns the value of theerrorCoderecord component.Returns the value of theerrorMessagerecord component.static SmsResultCreate failure result without phone 创建不带手机号的失败结果static SmsResultCreate failure result 创建失败结果final inthashCode()Returns a hash code value for this object.booleanisFailed()Check if failed 检查是否失败Returns the value of themessageIdrecord component.Returns the value of thephoneNumberrecord component.booleansuccess()Returns the value of thesuccessrecord component.static SmsResultCreate success result without phone 创建不带手机号的成功结果static SmsResultCreate success result 创建成功结果Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SmsResult
public SmsResult(boolean success, String messageId, String phoneNumber, String errorCode, String errorMessage, Instant timestamp) Creates an instance of aSmsResultrecord class.- Parameters:
success- the value for thesuccessrecord componentmessageId- the value for themessageIdrecord componentphoneNumber- the value for thephoneNumberrecord componenterrorCode- the value for theerrorCoderecord componenterrorMessage- the value for theerrorMessagerecord componenttimestamp- the value for thetimestamprecord component
-
-
Method Details
-
success
-
failure
-
isFailed
public boolean isFailed()Check if failed 检查是否失败- Returns:
- true if failed | 如果失败返回true
-
success
-
failure
-
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
-
messageId
-
phoneNumber
Returns the value of thephoneNumberrecord component.- Returns:
- the value of the
phoneNumberrecord component
-
errorCode
-
errorMessage
Returns the value of theerrorMessagerecord component.- Returns:
- the value of the
errorMessagerecord component
-
timestamp
-