<commit_before>/**
 * Created by <NAME> on 17.12.2015.
 */
package net.dv8tion.jda;

import net.dv8tion.jda.entities.Message;
import net.dv8tion.jda.entities.User;
import net.dv8tion.jda.entities.impl.MessageImpl;

import java.util.LinkedList;
import java.util.List;

public class MessageBuilder
{
    private final StringBuilder builder = new StringBuilder();
    private final List<User> mentioned = new LinkedList<>();

    /**
     * Appends a string to the Message
     *
     * @param text the text to append
     * @return this instance
     */
    public MessageBuilder appendString(String text)
    {
        builder.append(text);
        return this;
    }

    /**
     * Appends a formatted string to the Message
     *
     * @param text       the text to append
     * @param formatting the format to apply to the text
     * @return this instance
     */
    public MessageBuilder appendString(String text, Formatting formatting)
    {
        builder.append(formatting.getOpenTag()).append(text).append(formatting.getCloseTag());
        return this;
    }

    /**
     * Appends a code-block to the Message
     *
     * @param text     the code to append
     * @param language the language of the code. If unknown use an empty string or use the {@link Formatting#BLOCK BLOCK Formatting}
     * @return this instance
     */
    public MessageBuilder appendCodeBlock(String text, String language)
    {
        builder.append("```").append(language).append('\n').append(text).append("\n```");
        return this;
    }

    /**
     * Appends a mention to the Message
     *
     * @param user the user to mention
     * @return this instance
     */
    public MessageBuilder appendMention(User user)
    {
        builder.append('@').append(user.getUsername());
        mentioned.add(user);
        return this;
    }

    /**
     * Creates a {@link net.dv8tion.jda.entities.Message Message} object from this Builder
     *
     * @return the created {@link net.dv8tion.jda.entities.Message Message}
     */
    public Message build()
    {
        return new MessageImpl("", null).setContent(builder.toString()).setMentionedUsers(mentioned);
    }

    /**
     * Holds the Available formatting used in {@link #appendString(String, Formatting)}
     */
    public enum Formatting
    {
        ITALICS("*"),
        BOLD("**"),
        BOLD_ITALICS("***"),
        STRIKETHROUGH("~~"),
        UNDERLINE("__"),
        UNDERLINE_ITALICS("__*", "*__"),
        UNDERLINE_BOLD("__**", "**__"),
        UNDERLINE_BOLD_ITALICS("__***", "***__"),
        BLOCK("```\n", "```");

        private final String open, close;

        Formatting(String open)
        {
            this(open, open);
        }

        Formatting(String open, String close)
        {
            this.open = open;
            this.close = close;
        }

        private String getOpenTag()
        {
            return open;
        }

        private String getCloseTag()
        {
            return close;
        }

    }
}
<commit_msg>MessageBuilder changed to allow any combination of formats<commit_after>/**
 * Created by <NAME> on 17.12.2015.
 */
package net.dv8tion.jda;

import net.dv8tion.jda.entities.Message;
import net.dv8tion.jda.entities.User;
import net.dv8tion.jda.entities.impl.MessageImpl;

import java.util.LinkedList;
import java.util.List;

public class MessageBuilder
{
    private final StringBuilder builder = new StringBuilder();
    private final List<User> mentioned = new LinkedList<>();

    /**
     * Appends a string to the Message
     *
     * @param text the text to append
     * @return this instance
     */
    public MessageBuilder appendString(String text)
    {
        builder.append(text);
        return this;
    }

    /**
     * Appends a formatted string to the Message
     *
     * @param text   the text to append
     * @param format the format(s) to apply to the text
     * @return this instance
     */
    public MessageBuilder appendString(String text, Formatting... format)
    {
        boolean blockPresent = false;
        for (Formatting formatting : format)
        {
            if (formatting == Formatting.BLOCK)
            {
                blockPresent = true;
                continue;
            }
            builder.append(formatting.getTag());
        }
        if (blockPresent)
            builder.append(Formatting.BLOCK.getTag());

        builder.append(text);

        if (blockPresent)
            builder.append(Formatting.BLOCK.getTag());
        for (int i = format.length - 1; i >= 0; i--)
        {
            if (format[i] == Formatting.BLOCK) continue;
            builder.append(format[i].getTag());
        }
        return this;
    }

    /**
     * Appends a code-block to the Message
     *
     * @param text     the code to append
     * @param language the language of the code. If unknown use an empty string
     * @return this instance
     */
    public MessageBuilder appendCodeBlock(String text, String language)
    {
        builder.append("```").append(language).append('\n').append(text).append("\n```");
        return this;
    }

    /**
     * Appends a mention to the Message
     *
     * @param user the user to mention
     * @return this instance
     */
    public MessageBuilder appendMention(User user)
    {
        builder.append('@').append(user.getUsername());
        mentioned.add(user);
        return this;
    }

    /**
     * Creates a {@link net.dv8tion.jda.entities.Message Message} object from this Builder
     *
     * @return the created {@link net.dv8tion.jda.entities.Message Message}
     */
    public Message build()
    {
        return new MessageImpl("", null).setContent(builder.toString()).setMentionedUsers(mentioned);
    }

    /**
     * Holds the Available formatting used in {@link #appendString(String, Formatting...)}
     */
    public enum Formatting
    {
        ITALICS("*"),
        BOLD("**"),
        STRIKETHROUGH("~~"),
        UNDERLINE("__"),
        BLOCK("`");

        private final String tag;

        Formatting(String tag)
        {
            this.tag = tag;
        }

        private String getTag()
        {
            return tag;
        }

    }
}

{'fraction_non_alphanumeric': 0.11724137931034483, 'fraction_numerical': 0.0048115477145148355, 'mean_word_length': 2.0978638847491307, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7544226', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1734, 'n_words': 467}