<commit_before>package com.valkryst.VTerminal.builder.component;

import com.valkryst.VTerminal.component.CheckBox;
import com.valkryst.VTerminal.misc.ColorFunctions;
import lombok.*;

import java.awt.Color;

@EqualsAndHashCode(callSuper=true)
@ToString
public class CheckBoxBuilder extends ComponentBuilder<CheckBox> {
    /** The text of the label to display to the right of the check box. */
    @Getter @Setter @NonNull private String text;

    /** The character to display when the check box is not checked. */
    @Getter @Setter private char emptyBoxChar;
    /** The character to display when the check box is checked. */
    @Getter @Setter private char checkedBoxChar;

    /** Whether or not the check box is checked. */
    @Getter @Setter private boolean isChecked;

    /** The background color for when the check box is in the normal state. */
    @Getter @Setter @NonNull private Color backgroundColor_normal;
    /** The foreground color for when the check box is in the normal state. */
    @Getter @Setter @NonNull private Color foregroundColor_normal;

    /** The background color for when the check box is in the hover state. */
    @Getter @Setter @NonNull private Color backgroundColor_hover;
    /** The foreground color for when the check box is in the hover state. */
    @Getter @Setter @NonNull private Color foregroundColor_hover;

    /** The background color for when the check box is in the checked state. */
    @Getter @Setter @NonNull private Color backgroundColor_checked;
    /** The foreground color for when the check box is in the checked state. */
    @Getter @Setter @NonNull private Color foregroundColor_checked;

    @Override
    public CheckBox build() {
        checkState();
        return new CheckBox(this);
    }

    /** Resets the builder to it's default state. */
    public void reset() {
        super.reset();

        text = "";

        emptyBoxChar = '☐';
        checkedBoxChar = '☑';

        isChecked = false;

        backgroundColor_normal = new Color(45, 45, 45, 255);
        foregroundColor_normal = new Color(0xFF2DBEFF, true);

        backgroundColor_hover = new Color(0xFF2DFF63, true);
        foregroundColor_hover = ColorFunctions.shade(backgroundColor_hover, 0.5);

        backgroundColor_checked = backgroundColor_normal;
        foregroundColor_checked = new Color(0xFFFFD72D, true);
    }<commit_msg>Adds support for loading a check box from JSON.<commit_after>package com.valkryst.VTerminal.builder.component;

import com.valkryst.VTerminal.component.CheckBox;
import com.valkryst.VTerminal.misc.ColorFunctions;
import lombok.*;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

import java.awt.Color;

@EqualsAndHashCode(callSuper=true)
@ToString
public class CheckBoxBuilder extends ComponentBuilder<CheckBox> {
    /** The text of the label to display to the right of the check box. */
    @Getter @Setter @NonNull private String text;

    /** The character to display when the check box is not checked. */
    @Getter @Setter private char emptyBoxChar;
    /** The character to display when the check box is checked. */
    @Getter @Setter private char checkedBoxChar;

    /** Whether or not the check box is checked. */
    @Getter @Setter private boolean isChecked;

    /** The background color for when the check box is in the normal state. */
    @Getter @Setter @NonNull private Color backgroundColor_normal;
    /** The foreground color for when the check box is in the normal state. */
    @Getter @Setter @NonNull private Color foregroundColor_normal;

    /** The background color for when the check box is in the hover state. */
    @Getter @Setter @NonNull private Color backgroundColor_hover;
    /** The foreground color for when the check box is in the hover state. */
    @Getter @Setter @NonNull private Color foregroundColor_hover;

    /** The background color for when the check box is in the checked state. */
    @Getter @Setter @NonNull private Color backgroundColor_checked;
    /** The foreground color for when the check box is in the checked state. */
    @Getter @Setter @NonNull private Color foregroundColor_checked;

    @Override
    public CheckBox build() {
        checkState();
        return new CheckBox(this);
    }

    /** Resets the builder to it's default state. */
    public void reset() {
        super.reset();

        text = "";

        emptyBoxChar = '☐';
        checkedBoxChar = '☑';

        isChecked = false;

        backgroundColor_normal = new Color(45, 45, 45, 255);
        foregroundColor_normal = new Color(0xFF2DBEFF, true);

        backgroundColor_hover = new Color(0xFF2DFF63, true);
        foregroundColor_hover = ColorFunctions.shade(backgroundColor_hover, 0.5);

        backgroundColor_checked = backgroundColor_normal;
        foregroundColor_checked = new Color(0xFFFFD72D, true);
    }

    @Override
    public void parseJSON(final JSONObject jsonObject) {
        super.parseJSON(jsonObject);


        final String text = (String) jsonObject.get("text");

        final Character emptyBoxChar = (Character) jsonObject.get("emptyBoxChar");
        final Character checkedBoxChar = (Character) jsonObject.get("checkedBoxChar");

        final Boolean isChecked = (Boolean) jsonObject.get("isChecked");

        final Color backgroundColor_normal = super.loadColorFromJSON((JSONArray) jsonObject.get("backgroundColor_normal"));
        final Color foregroundColor_normal = super.loadColorFromJSON((JSONArray) jsonObject.get("foregroundColor_normal"));

        final Color backgroundColor_hover = super.loadColorFromJSON((JSONArray) jsonObject.get("backgroundColor_hover"));
        final Color foregroundColor_hover = super.loadColorFromJSON((JSONArray) jsonObject.get("foregroundColor_hover"));

        final Color backgroundColor_checked = super.loadColorFromJSON((JSONArray) jsonObject.get("backgroundColor_checked"));
        final Color foregroundColor_checked = super.loadColorFromJSON((JSONArray) jsonObject.get("foregroundColor_checked"));


        if (text != null) {
            this.text = text;
        }



        if (emptyBoxChar != null) {
            this.emptyBoxChar = emptyBoxChar;
        }

        if (checkedBoxChar != null) {
            this.checkedBoxChar = checkedBoxChar;
        }



        if (isChecked != null) {
            this.isChecked = isChecked;
        }



        if (backgroundColor_normal != null) {
            this.backgroundColor_normal = backgroundColor_normal;
        }

        if (foregroundColor_normal != null) {
            this.foregroundColor_normal = foregroundColor_normal;
        }



        if (backgroundColor_hover != null) {
            this.backgroundColor_hover = backgroundColor_hover;
        }

        if (foregroundColor_hover != null) {
            this.foregroundColor_hover = foregroundColor_hover;
        }



        if (backgroundColor_checked != null) {
            this.backgroundColor_checked = backgroundColor_checked;
        }

        if (foregroundColor_checked != null) {
            this.foregroundColor_checked = foregroundColor_checked;
        }
    }
{'fraction_non_alphanumeric': 0.08689558514365803, 'fraction_numerical': 0.005606166783461808, 'mean_word_length': 3.1320208453966414, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1088156', 'n_tokens_mistral': 1944, 'n_tokens_neox': 1849, 'n_words': 607}