@@ -0,0 +1,2375 @@
+package stexfires.core.message;%0A%0Aimport org.jetbrains.annotations.Nullable;%0Aimport stexfires.core.Field;%0Aimport stexfires.core.TextRecord;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Formatter;%0Aimport java.util.List;%0Aimport java.util.Locale;%0Aimport java.util.Objects;%0Aimport java.util.stream.Stream;%0A%0A/**%0A * @author Mathias Kalb%0A * @see java.util.Formatter%0A * @since 0.1%0A */%0Apublic class FormatterMessage%3CT extends TextRecord%3E implements RecordMessage%3CT%3E %7B%0A%0A    private final String format;%0A    private final Locale locale;%0A    private final int numberOfFieldValues;%0A    private final String fillUpValue;%0A%0A    public FormatterMessage(String format, Locale locale, int numberOfFieldValues, @Nullable String fillUpValue) %7B%0A        Objects.requireNonNull(format);%0A        Objects.requireNonNull(locale);%0A        if (numberOfFieldValues %3C 0) %7B%0A            throw new IllegalArgumentException(%22Illegal size! numberOfFieldValues=%22 + numberOfFieldValues);%0A        %7D%0A        this.format = format;%0A        this.locale = locale;%0A        this.numberOfFieldValues = numberOfFieldValues;%0A        this.fillUpValue = fillUpValue;%0A    %7D%0A%0A    public static %3CT extends TextRecord%3E FormatterMessage%3CT%3E withoutValues(String format, Locale locale) %7B%0A        return new FormatterMessage%3C%3E(format, locale, 0, null);%0A    %7D%0A%0A    @Override%0A    public final String createMessage(T record) %7B%0A        List%3CObject%3E args = new ArrayList%3C%3E(4 + numberOfFieldValues);%0A%0A        // add 4 standard arguments%0A        args.add(record.getClass().getName());%0A        args.add(record.getCategory());%0A        args.add(record.getRecordId());%0A        args.add(record.size());%0A%0A        if (numberOfFieldValues %3E 0) %7B%0A            // add limited record values%0A            record.streamOfFields()%0A                  .limit(numberOfFieldValues)%0A                  .map(Field::getValue)%0A                  .forEachOrdered(args::add);%0A%0A            // fill up missing values%0A            if (numberOfFieldValues %3E record.size()) %7B%0A                Stream.generate(() -%3E fillUpValue)%0A                      .limit(numberOfFieldValues - record.size())%0A                      .forEachOrdered(args::add);%0A            %7D%0A        %7D%0A%0A        // format arguments%0A        try (Formatter formatter = new Formatter(locale)) %7B%0A            formatter.format(format, args.toArray());%0A            return formatter.out().toString();%0A        %7D%0A    %7D%0A%0A%7D%0A

Add FormatterMessage