<commit_before>import {CommandOutputBindingModel} from "../generic/CommandOutputBindingModel";
import {CommandOutputBinding} from "../../mappings/v1.0/CommandOutputBinding";
import {V1ExpressionModel} from "./V1ExpressionModel";
import {EventHub} from "../helpers/EventHub";
export class V1CommandOutputBindingModel extends CommandOutputBindingModel {
    public hasSecondaryFiles  = false;
    public hasMetadata        = false;
    public hasInheritMetadata = false;

    protected _glob: V1ExpressionModel;

    get glob(): V1ExpressionModel {
        return this._glob;
    }

    set glob(value: V1ExpressionModel) {
        this._glob = new V1ExpressionModel(value.serialize(), `${this.loc}.glob`, this.eventHub);
        this._glob.setValidationCallback(err => this.updateValidity(err));
        if (this._glob.serialize() === undefined) {
            this._glob.updateValidity({
                [`${this.loc}.glob`]: {
                    message: "Glob should be specified",
                    type: "warning"
                }
            }, true);
        }
    }

    protected _outputEval: V1ExpressionModel;

    get outputEval(): V1ExpressionModel {
        return this._outputEval;
    }

    set outputEval(value: V1ExpressionModel) {
        this._outputEval = new V1ExpressionModel(value.serialize(), `${this.loc}.outputEval`, this.eventHub);
        this._outputEval.setValidationCallback(err => this.updateValidity(err));
    }

    constructor(binding: CommandOutputBinding = {}, loc?: string, eventHub?: EventHub) {
        super(loc, eventHub);

        if (binding) this.deserialize(binding);
    }

    public deserialize(binding: CommandOutputBinding) {
        let glob = binding.glob;

        if (Array.isArray(binding.glob)) {
            glob = binding.glob[0];
        }

        this._glob = new V1ExpressionModel(<string> glob, `${this.loc}.glob`, this.eventHub);
        this._glob.setValidationCallback(err => this.updateValidity(err));

        this._outputEval = new V1ExpressionModel(binding.outputEval, `${this.loc}.outputEval`, this.eventHub);
        this._outputEval.setValidationCallback(err => this.updateValidity(err));
    }

    public serialize(): CommandOutputBinding {
        let base: CommandOutputBinding = <CommandOutputBinding> {};

        if (this._glob && this._glob.serialize() !== undefined) base.glob = this._glob.serialize();
        if (this._outputEval && this._outputEval.serialize() !== undefined) base.outputEval = this._outputEval.serialize();

        return base;
    }
}<commit_msg>Fix - loadContents is not serialized/deserialized in V1CommandOutputBinding<commit_after>import {CommandOutputBindingModel} from "../generic/CommandOutputBindingModel";
import {CommandOutputBinding} from "../../mappings/v1.0/CommandOutputBinding";
import {V1ExpressionModel} from "./V1ExpressionModel";
import {EventHub} from "../helpers/EventHub";
export class V1CommandOutputBindingModel extends CommandOutputBindingModel {
    public hasSecondaryFiles  = false;
    public hasMetadata        = false;
    public hasInheritMetadata = false;

    protected _glob: V1ExpressionModel;

    get glob(): V1ExpressionModel {
        return this._glob;
    }

    set glob(value: V1ExpressionModel) {
        this._glob = new V1ExpressionModel(value.serialize(), `${this.loc}.glob`, this.eventHub);
        this._glob.setValidationCallback(err => this.updateValidity(err));
        if (this._glob.serialize() === undefined) {
            this._glob.updateValidity({
                [`${this.loc}.glob`]: {
                    message: "Glob should be specified",
                    type: "warning"
                }
            }, true);
        }
    }

    protected _outputEval: V1ExpressionModel;

    get outputEval(): V1ExpressionModel {
        return this._outputEval;
    }

    set outputEval(value: V1ExpressionModel) {
        this._outputEval = new V1ExpressionModel(value.serialize(), `${this.loc}.outputEval`, this.eventHub);
        this._outputEval.setValidationCallback(err => this.updateValidity(err));
    }

    constructor(binding: CommandOutputBinding = {}, loc?: string, eventHub?: EventHub) {
        super(loc, eventHub);

        if (binding) this.deserialize(binding);
    }

    public deserialize(binding: CommandOutputBinding) {
        let glob = binding.glob;

        if (Array.isArray(binding.glob)) {
            glob = binding.glob[0];
        }

        this.loadContents = binding.loadContents === true;

        this._glob = new V1ExpressionModel(<string> glob, `${this.loc}.glob`, this.eventHub);
        this._glob.setValidationCallback(err => this.updateValidity(err));

        this._outputEval = new V1ExpressionModel(binding.outputEval, `${this.loc}.outputEval`, this.eventHub);
        this._outputEval.setValidationCallback(err => this.updateValidity(err));
    }

    public serialize(): CommandOutputBinding {
        let base: CommandOutputBinding = <CommandOutputBinding> {};

        if (this.loadContents) base.loadContents = true;

        if (this._glob && this._glob.serialize() !== undefined) base.glob = this._glob.serialize();
        if (this._outputEval && this._outputEval.serialize() !== undefined) base.outputEval = this._outputEval.serialize();

        return base;
    }
}
{'fraction_non_alphanumeric': 0.12414965986394558, 'fraction_numerical': 0.006235827664399093, 'mean_word_length': 3.052833078101072, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2132423', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1403, 'n_words': 285}