Record Class SmsMessage
java.lang.Object
java.lang.Record
cloud.opencode.base.sms.message.SmsMessage
- Record Components:
phoneNumber- the phone number | 手机号码content- the message content | 消息内容templateId- the template ID (optional) | 模板ID(可选)variables- the template variables (optional) | 模板变量(可选)
public record SmsMessage(String phoneNumber, String content, String templateId, Map<String,String> variables)
extends Record
SMS Message
短信消息
Represents an SMS message to be sent.
表示要发送的短信消息。
Features | 主要功能:
- Content-based and template-based message creation - 基于内容和模板的消息创建
- Defensive copy of template variables - 模板变量防御性复制
- Builder pattern support - 构建器模式支持
Usage Examples | 使用示例:
SmsMessage msg = SmsMessage.of("13800138000", "Your code is 1234");
SmsMessage tpl = SmsMessage.ofTemplate("13800138000", "TPL_001",
Map.of("code", "1234"));
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Since:
- JDK 25, opencode-base-sms V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for SmsMessage SmsMessage构建器 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SmsMessage.Builderbuilder()Create builder 创建构建器content()Returns the value of thecontentrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static SmsMessageCreate message with content 使用内容创建消息static SmsMessageCreate message with template 使用模板创建消息Returns the value of thephoneNumberrecord component.Returns the value of thetemplateIdrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thevariablesrecord component.
-
Constructor Details
-
SmsMessage
public SmsMessage(String phoneNumber, String content, String templateId, Map<String, String> variables) Creates an instance of aSmsMessagerecord class.- Parameters:
phoneNumber- the value for thephoneNumberrecord componentcontent- the value for thecontentrecord componenttemplateId- the value for thetemplateIdrecord componentvariables- the value for thevariablesrecord component
-
-
Method Details
-
of
Create message with content 使用内容创建消息- Parameters:
phoneNumber- the phone number | 手机号码content- the content | 内容- Returns:
- the message | 消息
-
ofTemplate
-
builder
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
phoneNumber
Returns the value of thephoneNumberrecord component.- Returns:
- the value of the
phoneNumberrecord component
-
content
-
templateId
Returns the value of thetemplateIdrecord component.- Returns:
- the value of the
templateIdrecord component
-
variables
-