package com.komanov.stringformat;

import org.slf4j.helpers.MessageFormatter;

import java.text.MessageFormat;
import java.util.Locale;

public class JavaFormats {
    private static final MessageFormat messageFormatInstance = new MessageFormat("{0}a{1}b{2}{3}");

    public static String concat(int value1, String value2, Object nullObject) {
        return value1 + "a" + value2 + "b" + value2 + nullObject;
    }

    public static String stringFormat(int value1, String value2, Object nullObject) {
        return String.format(Locale.ENGLISH, "%da%sb%s%s", value1, value2, value2, nullObject);
    }

    public static String messageFormat(int value1, String value2, Object nullObject) {
        return MessageFormat.format("{0}a{1}b{2}{3}", value1, value2, value2, nullObject);
    }

    public static String messageFormatCached(int value1, String value2, Object nullObject) {
        return messageFormatInstance.format(new Object[]{value1, value2, value2, nullObject});
    }

    public static String slf4j(int value1, String value2, Object nullObject) {
        return MessageFormatter
                .arrayFormat("{}a{}b{}{}", new Object[]{value1, value2, value2, nullObject})
                .getMessage();
    }
}

@@ -233,32 +233,41 @@
 essageFormat(%22%7B0
+,number,#
 %7Da%7B1%7Db%7B2%7D%7B3%7D%22);%0A
@@ -735,16 +735,25 @@
 rmat(%22%7B0
+,number,#
 %7Da%7B1%7Db%7B2

Fix format string for MessageFormat