@Immutable public class MsgFormatter extends Object
{}
characters.
See the next correct asserts:
assertEquals("TEST" , MsgFormatter.format("TE{}T", "S")); assertEquals("TE, S, T", MsgFormatter.format("TE", "S", "T")); assertEquals("TES{}" , MsgFormatter.format("TE{}{}", "S"));
Modifier and Type | Field and Description |
---|---|
protected static String |
DEFAULT_MARK
Parameter mark
|
protected static String |
SEPARATOR
Separator
|
Modifier | Constructor and Description |
---|---|
protected |
MsgFormatter()
Static methods are available only
|
protected |
MsgFormatter(String mark)
Static methods are available only
|
Modifier and Type | Method and Description |
---|---|
static String |
format(Object... templateAndArguments)
Format the message from Object array
|
static String |
format(String messageTemplate,
Object... arguments)
Format the message, see the next correct asserts:
assertEquals("TEST" , MsgFormatter.format("TE{}T", "S")); assertEquals("TE, S, T", MsgFormatter.format("TE", "S", "T")); assertEquals("TES{}" , MsgFormatter.format("TE{}{}", "S")); |
String |
formatMsg(CharSequence messageTemplate,
Object... argumentValues)
Format the message, see the next correct asserts:
assertEquals("TEST" , MsgFormatter.format("TE{}T", "S")); assertEquals("TE, S, T", MsgFormatter.format("TE", "S", "T")); assertEquals("TES{}" , MsgFormatter.format("TE{}{}", "S")); |
String |
formatMsg(Object... templateAndArguments)
Format the message from Object array
|
protected void |
writeValue(Object value,
CharArrayWriter out,
boolean marked)
Print argument to the Writter with an optional format.
|
protected static final String DEFAULT_MARK
protected static final String SEPARATOR
@Nonnull public String formatMsg(@Nullable CharSequence messageTemplate, @Nullable Object... argumentValues)
assertEquals("TEST" , MsgFormatter.format("TE{}T", "S")); assertEquals("TE, S, T", MsgFormatter.format("TE", "S", "T")); assertEquals("TES{}" , MsgFormatter.format("TE{}{}", "S"));
messageTemplate
- Template where argument position is marked by the {}
characters.argumentValues
- Optional arguments, where the Supplier
interface is supported.@Nullable public String formatMsg(@Nullable Object... templateAndArguments)
templateAndArguments
- The first item is a template where parameters are located by "{}"
text and the next arguments are optional parameters of the template.null
.protected void writeValue(@Nullable Object value, @Nonnull CharArrayWriter out, boolean marked)
out
- Writervalue
- Value where the Supplier
interface is supported.@Nonnull public static String format(@Nullable String messageTemplate, @Nullable Object... arguments)
assertEquals("TEST" , MsgFormatter.format("TE{}T", "S")); assertEquals("TE, S, T", MsgFormatter.format("TE", "S", "T")); assertEquals("TES{}" , MsgFormatter.format("TE{}{}", "S"));
messageTemplate
- Template where argument position is marked by the {}
characters.arguments
- Optional arguments, where the Supplier
interface is supported.@Nullable public static String format(@Nullable Object... templateAndArguments)
templateAndArguments
- The first item is a template where parameters are located by "{}"
.
The Supplier
interface is supported.
text and the next arguments are optional parameters of the template.null
.Copyright 2019-2022, Pavel Ponec