// This file was autogenerated. Please do not change.
// All changes will be overwrited on commit.
export interface IFilterSetUrl {
    data?: any;
    url?: string;
    whitelist?: boolean;
}

export default class FilterSetUrl {
    readonly _data: any | undefined;

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

    readonly _url: string | undefined;

    get url(): string | undefined {
        return this._url;
    }

    readonly _whitelist: boolean | undefined;

    get whitelist(): boolean | undefined {
        return this._whitelist;
    }

    constructor(props: IFilterSetUrl) {
        if (props.data) {
            this._data = props.data;
        }
        if (typeof props.url === 'string') {
            this._url = props.url.trim();
        }
        if (typeof props.whitelist === 'boolean') {
            this._whitelist = props.whitelist;
        }
    }

    serialize(): IFilterSetUrl {
        const data: IFilterSetUrl = {
        };
        if (typeof this._data !== 'undefined') {
            data.data = this._data;
        }
        if (typeof this._url !== 'undefined') {
            data.url = this._url;
        }
        if (typeof this._whitelist !== 'undefined') {
            data.whitelist = this._whitelist;
        }
        return data;
    }

    validate(): string[] {
        const validate = {
            url: !this._url ? true : typeof this._url === 'string' && !this._url ? true : this._url,
            whitelist: !this._whitelist ? true : typeof this._whitelist === 'boolean',
        };
        const isError: string[] = [];
        Object.keys(validate).forEach((key) => {
            if (!(validate as any)[key]) {
                isError.push(key);
            }
        });
        return isError;
    }

    update(props: Partial<IFilterSetUrl>): FilterSetUrl {
        return new FilterSetUrl({ ...this.serialize(), ...props });
    }
}
