<commit_before>//        This file is part of the Yildiz-Online project, licenced under the MIT License
//        (MIT)
//
//        Copyright (c) 2016 <NAME>
//
//        More infos available: http://yildiz.bitbucket.org
//
//        Permission is hereby granted, free of charge, to any person obtaining a copy
//        of this software and associated documentation files (the "Software"), to deal
//        in the Software without restriction, including without limitation the rights
//        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//        copies of the Software, and to permit persons to whom the Software is
//        furnished to do so, subject to the following conditions:
//
//        The above copyright notice and this permission notice shall be included in all
//        copies or substantial portions of the Software.
//
//        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//        SOFTWARE.

package be.yildiz.shared.player;

import be.yildiz.common.id.PlayerId;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

import java.util.Date;

/**
 * Message sent from a player to another.
 *
 * @author <NAME>
 */
public final class Message {

    /**
     * To replace comma in the message.
     */
    private static final String COMMA = "%C%";

    /**
     * Separator for the message components.
     */
    private static final String SEPARATOR = "%§%";

    /**
     * Id of the player sending the message.
     */
    @Getter
    @NonNull
    private final PlayerId sender;

    /**
     * Id of the player receiving the message.
     */
    @Getter
    @NonNull
    private final PlayerId receiver;

    /**
     * Message content.
     */
    @NonNull
    private final String content;

    /**
     * Message date.
     */
    @Getter
    @NonNull
    private final Date date;

    /**
     * <code>true</code> if the message has been read, <code>false</code> otherwise.
     */
    @Getter
    @Setter
    private boolean read;

    /**
     * Create a new message.
     *
     * @param sender   Message sender.
     * @param receiver Message receiver.
     * @param message  Message.
     * @param date     Message send date.
     * @param read     Message read status.
     */
    public Message(final PlayerId sender, final PlayerId receiver, final String message, final Date date, final boolean read) {
        super();
        this.sender = sender;
        this.receiver = receiver;
        this.content = message.replaceAll(SEPARATOR, "").replaceAll(",", COMMA);
        this.date = date;
        this.read = read;
    }

    /**
     * Create a message from a String to parse.
     *
     * @param toParse
     */
    public Message(final String toParse) {
        super();
        String[] s = toParse.split(SEPARATOR);
        this.sender = PlayerId.get(Integer.parseInt(s[0].trim()));
        this.receiver = PlayerId.get(Integer.parseInt(s[1].trim()));
        this.content = s[2].trim().replace(SEPARATOR, "").replace(",", COMMA);
        this.date = new Date(Long.parseLong(s[3].trim()));
        this.read = Boolean.parseBoolean(s[4].trim());
    }<commit_msg>Sonar fix.<commit_after>//        This file is part of the Yildiz-Online project, licenced under the MIT License
//        (MIT)
//
//        Copyright (c) 2016 <NAME>
//
//        More infos available: http://yildiz.bitbucket.org
//
//        Permission is hereby granted, free of charge, to any person obtaining a copy
//        of this software and associated documentation files (the "Software"), to deal
//        in the Software without restriction, including without limitation the rights
//        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//        copies of the Software, and to permit persons to whom the Software is
//        furnished to do so, subject to the following conditions:
//
//        The above copyright notice and this permission notice shall be included in all
//        copies or substantial portions of the Software.
//
//        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//        SOFTWARE.

package be.yildiz.shared.player;

import be.yildiz.common.id.PlayerId;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

import java.util.Date;

/**
 * Message sent from a player to another.
 *
 * @author <NAME>
 */
public final class Message {

    /**
     * To replace comma in the message.
     */
    private static final String COMMA = "%C%";

    /**
     * Separator for the message components.
     */
    private static final String SEPARATOR = "%§%";

    /**
     * Id of the player sending the message.
     */
    @Getter
    private final PlayerId sender;

    /**
     * Id of the player receiving the message.
     */
    @Getter
    private final PlayerId receiver;

    /**
     * Message content.
     */
    private final String content;

    /**
     * Message date.
     */
    @Getter
    private final Date date;

    /**
     * <code>true</code> if the message has been read, <code>false</code> otherwise.
     */
    @Getter
    @Setter
    private boolean read;

    /**
     * Create a new message.
     *
     * @param sender   Message sender.
     * @param receiver Message receiver.
     * @param message  Message.
     * @param date     Message send date.
     * @param read     Message read status.
     */
    public Message(@NonNull final PlayerId sender, @NonNull final PlayerId receiver, @NonNull final String message, @NonNull final Date date, final boolean read) {
        super();
        this.sender = sender;
        this.receiver = receiver;
        this.content = message.replaceAll(SEPARATOR, "").replaceAll(",", COMMA);
        this.date = date;
        this.read = read;
    }

    /**
     * Create a message from a String to parse.
     *
     * @param toParse
     */
    public Message(final String toParse) {
        super();
        String[] s = toParse.split(SEPARATOR);
        this.sender = PlayerId.get(Integer.parseInt(s[0].trim()));
        this.receiver = PlayerId.get(Integer.parseInt(s[1].trim()));
        this.content = s[2].trim().replace(SEPARATOR, "").replace(",", COMMA);
        this.date = new Date(Long.parseLong(s[3].trim()));
        this.read = Boolean.parseBoolean(s[4].trim());
    }
{'fraction_non_alphanumeric': 0.10432004445061814, 'fraction_numerical': 0.0025003472704542297, 'mean_word_length': 2.3042680128499313, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4621011', 'n_tokens_mistral': 1979, 'n_tokens_neox': 1958, 'n_words': 747}