<commit_before>﻿/*import {IConstructor} from "../other/IConstructor";

import {BaseObjectExtendTools} from "./BaseObjectExtendTools";

export const BaseObjectClass: IConstructor = (BaseObjectExtendTools as any).extend(BaseEventDispatcher);
export class BaseObject extends BaseObjectClass {

}*/

import {BaseEventDispatcher} from "../event/eventdispatcher/BaseEventDispatcher";
import {EventListenerHelper} from "../event/eventlistenerhelper/EventListenerHelper";

export class BaseObject extends BaseEventDispatcher {

    protected isConstructed: boolean;

    private _data: any;

    protected eventListenerHelper:EventListenerHelper<Event | string | any>;


    constructor(...args) {
        super(...args);

        this.construction(...args);
        this.isConstructed = true;

        this.addListeners();
        this.commitData();
    }


    protected construction(...args): void {
        this.eventListenerHelper = new EventListenerHelper(this);
    }

    public destruction(): void {
        this.removeListeners();

        if (this.eventListenerHelper) {
            this.eventListenerHelper.destruction();
            this.eventListenerHelper = null;
        }
    }


    protected addListeners(): void {
        this.removeListeners();

        // Note: subclasses should implement their own logic here
    }

    protected removeListeners(): void {
        if (this.eventListenerHelper) {
            this.eventListenerHelper.removeAllListeners();
        }
    }


    protected commitData(): void {
        // Note: subclasses should implement their own logic here
    }

    protected arrange(): void {
        // Note: subclasses should implement their own logic here
    }


    public get data(): any {
        return this._data;
    }

    public set data(value: any) {
        if (this.data == value) {
            return;
        }

        this._data = value;

        this.commitData();
    }
}<commit_msg>Adding a way to use specific types for the data param through Generics.<commit_after>﻿/*import {IConstructor} from "../other/IConstructor";

import {BaseObjectExtendTools} from "./BaseObjectExtendTools";

export const BaseObjectClass: IConstructor = (BaseObjectExtendTools as any).extend(BaseEventDispatcher);
export class BaseObject extends BaseObjectClass {

}*/

import {BaseEventDispatcher} from "../event/eventdispatcher/BaseEventDispatcher";
import {EventListenerHelper} from "../event/eventlistenerhelper/EventListenerHelper";

export class BaseObject<DataType extends object = object> extends BaseEventDispatcher {

    protected isConstructed: boolean;

    private _data: DataType;

    protected eventListenerHelper:EventListenerHelper<Event | string | any>;


    constructor(...args) {
        super(...args);

        this.construction(...args);
        this.isConstructed = true;

        this.addListeners();
        this.commitData();
    }


    protected construction(...args): void {
        this.eventListenerHelper = new EventListenerHelper(this);
    }

    public destruction(): void {
        this.removeListeners();

        if (this.eventListenerHelper) {
            this.eventListenerHelper.destruction();
            this.eventListenerHelper = null;
        }
    }


    protected addListeners(): void {
        this.removeListeners();

        // Note: subclasses should implement their own logic here
    }

    protected removeListeners(): void {
        if (this.eventListenerHelper) {
            this.eventListenerHelper.removeAllListeners();
        }
    }


    protected commitData(): void {
        // Note: subclasses should implement their own logic here
    }

    protected arrange(): void {
        // Note: subclasses should implement their own logic here
    }


    public get data(): DataType {
        return this._data;
    }
    public set data(value: DataType) {
        if (this.data == value) {
            return;
        }

        this._data = value;

        this.commitData();
    }
}
{'fraction_non_alphanumeric': 0.10235825388861014, 'fraction_numerical': 0.0, 'mean_word_length': 2.6678932842686294, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '1656947', 'n_tokens_mistral': 1026, 'n_tokens_neox': 983, 'n_words': 259}