public class SinglePlaceholderStrTemplate extends StrTemplate
例如,"?", "{}", "$$$"
Modifier and Type | Class and Description |
---|---|
static class |
SinglePlaceholderStrTemplate.Builder
构造器
|
StrTemplate.AbstractBuilder<BuilderChild extends StrTemplate.AbstractBuilder<BuilderChild,TemplateChild>,TemplateChild extends StrTemplate>, StrTemplate.Feature
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_PLACEHOLDER
默认的占位符
|
protected String |
placeholder
占位符,默认为:
StrPool.EMPTY_JSON |
DEFAULT_ESCAPE, defaultValue, defaultValueHandler, escape, fixedTextTotalLength, globalDefaultValueHandler, globalFeatures, placeholderSegments, segments
Modifier | Constructor and Description |
---|---|
protected |
SinglePlaceholderStrTemplate(String template,
int features,
String placeholder,
char escape,
String defaultValue,
UnaryOperator<String> defaultValueHandler) |
Modifier and Type | Method and Description |
---|---|
static SinglePlaceholderStrTemplate.Builder |
builder(String template)
创建 builder
|
String |
format(Iterable<?> iterable)
按顺序使用 迭代器元素 替换 占位符
|
String |
format(Object... args)
按顺序使用 数组元素 替换 占位符
|
String |
formatArray(Object array)
按顺序使用 原始数组元素 替换 占位符
|
String |
formatArray(Object[] array)
按顺序使用 数组元素 替换 占位符
|
List<String> |
matches(String str)
将 占位符位置的值 按顺序解析为 字符串列表
|
String[] |
matchesToArray(String str)
将 占位符位置的值 按顺序解析为 字符串数组
|
protected List<StrTemplateSegment> |
parseSegments(String template)
将 模板 解析为 Segment 列表
|
addLiteralSegment, afterInit, formatBySegment, formatMissingKey, formatNullValue, formatRawByKey, formatRawBySegment, formatSequence, getDefaultValue, getFeatures, getPlaceholderSegments, getPlaceholderTexts, getPlaceholderVariableNames, getSegments, getTemplate, hasDefaultValue, isMatches, matchesByKey, matchesByKey, matchesRawByKey, matchesRawBySegment, matchesSequence, of, ofNamed, setGlobalDefaultValue, setGlobalFeatures
public static final String DEFAULT_PLACEHOLDER
protected String placeholder
StrPool.EMPTY_JSON
protected SinglePlaceholderStrTemplate(String template, int features, String placeholder, char escape, String defaultValue, UnaryOperator<String> defaultValueHandler)
protected List<StrTemplateSegment> parseSegments(String template)
StrTemplate
parseSegments
in class StrTemplate
template
- 字符串模板public String format(Object... args)
args
- 可变参数public String formatArray(Object array)
array
- 原始类型数组,例如: int[]
public String formatArray(Object[] array)
array
- 数组public String format(Iterable<?> iterable)
iterable
- iterablepublic String[] matchesToArray(String str)
str
- 待解析的字符串,一般是格式化方法的返回值public List<String> matches(String str)
str
- 待解析的字符串,一般是格式化方法的返回值public static SinglePlaceholderStrTemplate.Builder builder(String template)
template
- 字符串模板,不能为 null
Copyright © 2025. All rights reserved.