@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 char |
SEPARATOR
Separator of unmarked arguments '{}' was changed to a single space from release 1.91
|
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 <T> String |
format(CharSequence messageTemplate,
T... 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")); |
static <T> String |
format(T... templateAndArguments)
Format the message from Object array
|
<T> String |
formatMsg(Appendable writer,
CharSequence messageTemplate,
T... 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")); |
protected <T> String |
formatMsg(Appendable writer,
T... templateAndArguments)
Format the message from Object array
|
protected void |
writeValue(Object value,
Appendable out,
boolean marked)
Print argument to the Writter with an optional format.
|
protected static final String DEFAULT_MARK
protected static final char SEPARATOR
@Nonnull public <T> String formatMsg(@Nullable Appendable writer, @Nullable CharSequence messageTemplate, @Nullable T... argumentValues) throws IOException
assertEquals("TEST" , MsgFormatter.format("TE{}T", "S")); assertEquals("TE, S, T", MsgFormatter.format("TE", "S", "T")); assertEquals("TES{}" , MsgFormatter.format("TE{}{}", "S"));
writer
- An optional writermessageTemplate
- Template where argument position is marked by the {}
characters.argumentValues
- Optional arguments, where the Supplier
interface is supported.IOException
@Nullable protected <T> String formatMsg(@Nullable Appendable writer, @Nullable T... templateAndArguments) throws IOException
templateAndArguments
- The first item is a template where parameters are located by "{}"
text and the next arguments are optional parameters of the template.null
.IOException
protected void writeValue(@Nullable Object value, @Nonnull Appendable out, boolean marked) throws IOException
out
- Appendablevalue
- Value where the Supplier
interface is supported.IOException
@Nonnull public static <T> String format(@Nullable CharSequence messageTemplate, @Nullable T... 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 <T> String format(@Nullable T... 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