// This file was autogenerated. Please do not change.
// All changes will be overwrited on commit.
export interface ITopArrayEntry {
    domain_or_ip?: number;
    [key: string]: number | undefined;
}

export default class TopArrayEntry {
    readonly _domain_or_ip: number | undefined;

    get domainOrIp(): number | undefined {
        return this._domain_or_ip;
    }

    readonly numberData: Record<string, number>;

    constructor(props: ITopArrayEntry) {
        this.numberData = Object.entries(props).reduce<Record<string, number>>((prev, [key, value]) => {
            prev[key] = value!;
            return prev;
        }, {})
    }

    serialize(): ITopArrayEntry {
        return Object.entries(this.numberData).reduce<Record<string, number>>((prev, [key, value]) => {
            prev[key] = value;
            return prev;
        }, {})
    }

    validate(): string[] {
        const validate = {
            domain_or_ip: !this._domain_or_ip ? true : typeof this._domain_or_ip === 'number',
        };
        const isError: string[] = [];
        Object.keys(validate).forEach((key) => {
            if (!(validate as any)[key]) {
                isError.push(key);
            }
        });
        return isError;
    }

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