Class TemplateUtil

java.lang.Object
cloud.opencode.base.string.template.TemplateUtil

public final class TemplateUtil extends Object
Template Utility - Provides template helper methods. 模板工具 - 提供模板辅助方法。

Features | 主要功能:

  • Simple ${var} template rendering - 简单${var}模板渲染
  • Variable extraction from templates - 从模板提取变量
  • Default value support via ${var:default} - 默认值支持

Usage Examples | 使用示例:

String result = TemplateUtil.render("Hello ${name}!", Map.of("name", "World"));
Set<String> vars = TemplateUtil.extractVariables("${a} and ${b}");

Security | 安全性:

  • Thread-safe: Yes (stateless utility) - 线程安全: 是(无状态工具类)
  • Null-safe: Yes (returns null for null template) - 空值安全: 是

Performance | 性能特性:

  • Time complexity: O(n + v) where n = template length, v = variables - O(n + v), n为模板长度, v为变量数
  • Space complexity: O(n) for rendered output - 渲染输出 O(n)
Since:
JDK 25, opencode-base-string V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also: