public class StringTemplates extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
StringTemplates.TemplateFluenter |
| 构造器和说明 |
|---|
StringTemplates() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Supplier<Object[],String> |
beanStyleSupplier(String template) |
static Supplier<Object[],String> |
cStyleSupplier(String template) |
static StringTemplates.TemplateFluenter |
fluenter(String template) |
static String |
format(String template,
Object... args)
format based index: {0}, {1}, {2}
|
static String |
format(String template,
Pattern variablePattern,
Function2<String,Object[],String> valueGetter,
Object... args)
custom formatter
|
static String |
format(String template,
Pattern variablePattern,
PlaceholderParser variableValueProvider)
模板变量替换
|
static String |
format(String template,
String variablePattern,
Function2<String,Object[],String> valueGetter,
Object... args)
custom formatter
|
static String |
format(String template,
String variableStartFlag,
String variableEndFlag,
Function2<String,Object[],String> valueGetter,
Object... args)
模板变量替换
|
static String |
format(String template,
String variableStartFlag,
String variableEndFlag,
PlaceholderParser variableValueProvider)
模板替换
|
static String |
format(String template,
String variableStartFlag,
String variableEndFlag,
ValueGetter2<String> valueGetter)
模板替换
|
static <T> String |
formatWithBean(String template,
T bean)
format based on a bean, the variable: ${fieldName}
|
static String |
formatWithCStyle(String template,
Object... args)
%s, %d
|
static String |
formatWithIndex(String template,
Object... args)
format based index: {0}, {1}, {2}
the index based on 0
|
static String |
formatWithMap(String template,
Map<String,?> map)
format based on a map, the variable: ${key}
|
static String |
formatWithMap(String template,
MapBasedStringFormatter.PatternStyle patternStyle,
Map<String,?> map)
format based on a map, the variable: ${key}
|
static String |
formatWithPlaceholder(String template,
Object... args)
format based placeholder: {}
|
static Supplier<Object[],String> |
indexStyleSupplier(String template) |
static Supplier<Object[],String> |
mapStyleSupplier(String template) |
static Supplier<Object[],String> |
mapStyleSupplier(String template,
MapBasedStringFormatter.PatternStyle patternStyle) |
static Supplier<Object[],String> |
placeholderStyleSupplier(String template) |
static Supplier<Object[],String> |
supplier(String template) |
public static String formatWithCStyle(String template, Object... args)
template - the templateargs - the argumentsString.format(String, Object...)public static String formatWithPlaceholder(String template, Object... args)
template - the string templatepublic static Supplier<Object[],String> placeholderStyleSupplier(String template)
public static String formatWithIndex(String template, Object... args)
template - the string templateformat(String, Object...)public static <T> String formatWithBean(String template, T bean)
T - the bean typetemplate - the string templatebean - the beanpublic static String formatWithMap(String template, Map<String,?> map)
template - the string templatepublic static Supplier<Object[],String> mapStyleSupplier(@NonNull String template, @Nullable MapBasedStringFormatter.PatternStyle patternStyle)
public static String formatWithMap(String template, MapBasedStringFormatter.PatternStyle patternStyle, Map<String,?> map)
template - the string templatepublic static String format(String template, String variablePattern, Function2<String,Object[],String> valueGetter, Object... args)
template - the string templatevariablePattern - variable pattern in templatevalueGetter - variable's value getter, will get value from argsargs - argspublic static String format(String template, Pattern variablePattern, Function2<String,Object[],String> valueGetter, Object... args)
template - the string templatevariablePattern - variable pattern in templatevalueGetter - variable's value getter, will get value from argsargs - argspublic static String format(String template, String variableStartFlag, String variableEndFlag, Function2<String,Object[],String> valueGetter, Object... args)
template - 模板variableStartFlag - 变量的regexp pattern的前缀标识,例如 { 或 ${variableEndFlag - 变量的regexp pattern的后缀标识,例如 { 或 ${public static String format(String template, Pattern variablePattern, PlaceholderParser variableValueProvider)
template - 模板variablePattern - 变量的regexp patternvariableValueProvider - 用于提供变量值public static String format(String template, String variableStartFlag, String variableEndFlag, PlaceholderParser variableValueProvider)
public static String format(String template, String variableStartFlag, String variableEndFlag, ValueGetter2<String> valueGetter)
public static String format(String template, Object... args)
template - the string templateargs - argsformatWithIndex(String, Object...)public static StringTemplates.TemplateFluenter fluenter(String template)
Copyright © 2022. All rights reserved.