Record Class SmsTemplate
java.lang.Object
java.lang.Record
cloud.opencode.base.sms.template.SmsTemplate
- Record Components:
id- the template ID | 模板IDname- the template name | 模板名称content- the template content | 模板内容variableNames- the variable names | 变量名称列表
public record SmsTemplate(String id, String name, String content, List<String> variableNames)
extends Record
SMS Template
短信模板
Template for SMS messages with variable substitution.
支持变量替换的短信消息模板。
Features | 主要功能:
- Automatic variable name extraction from content - 从内容自动提取变量名
- Variable substitution rendering - 变量替换渲染
- Immutable record design - 不可变记录设计
Usage Examples | 使用示例:
SmsTemplate tpl = SmsTemplate.of("verify", "Your code is ${code}");
List<String> vars = tpl.variableNames(); // ["code"]
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 TypeMethodDescriptioncontent()Returns the value of thecontentrecord component.final booleanIndicates whether some other object is "equal to" this one.getMissingVariables(Map<String, String> variables) Get missing variables 获取缺失的变量booleanhasAllVariables(Map<String, String> variables) Check if all variables are provided 检查是否提供了所有变量final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.name()Returns the value of thenamerecord component.static SmsTemplateCreate template from content 从内容创建模板static SmsTemplateCreate template with name 使用名称创建模板Render template with variables 使用变量渲染模板final StringtoString()Returns a string representation of this record class.Returns the value of thevariableNamesrecord component.
-
Constructor Details
-
SmsTemplate
Creates an instance of aSmsTemplaterecord class.- Parameters:
id- the value for theidrecord componentname- the value for thenamerecord componentcontent- the value for thecontentrecord componentvariableNames- the value for thevariableNamesrecord component
-
-
Method Details
-
of
Create template from content 从内容创建模板- Parameters:
id- the template ID | 模板IDcontent- the content | 内容- Returns:
- the template | 模板
-
of
Create template with name 使用名称创建模板- Parameters:
id- the template ID | 模板IDname- the name | 名称content- the content | 内容- Returns:
- the template | 模板
-
render
-
hasAllVariables
-
getMissingVariables
-
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). -
id
-
name
-
content
-
variableNames
Returns the value of thevariableNamesrecord component.- Returns:
- the value of the
variableNamesrecord component
-