@Unmodifiable 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(@NotNull String mark)
Static methods are available only
|
| Modifier and Type | Method and Description |
|---|---|
static <T> @NotNull String |
format(@Nullable 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> @Nullable String |
format(T... templateAndArguments)
Format the message from Object array
|
<T> @NotNull String |
formatMsg(@Nullable Appendable writer,
@Nullable 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> @Nullable String |
formatMsg(@Nullable Appendable writer,
T... templateAndArguments)
Format the message from Object array
|
protected void |
writeValue(@Nullable Object value,
@NotNull Appendable out,
boolean marked)
Print argument to the Writter with an optional format.
|
protected static final String DEFAULT_MARK
protected static final char SEPARATOR
protected MsgFormatter()
protected MsgFormatter(@NotNull
@NotNull String mark)
@NotNull public <T> @NotNull String formatMsg(@Nullable @Nullable Appendable writer, @Nullable @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> @Nullable String formatMsg(@Nullable @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.IOExceptionprotected void writeValue(@Nullable
@Nullable Object value,
@NotNull
@NotNull Appendable out,
boolean marked)
throws IOException
out - Appendablevalue - Value where the Supplier interface is supported.IOException@NotNull public static <T> @NotNull String format(@Nullable @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> @Nullable 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 2015, Pavel Ponec