import { IListable } from '@iqser/common-ui';

export interface IComponentMapping extends IListable {
    id: string;
    name: string;
    fileName: string;
    version: number;
    columnLabels: string[];
    columnLabelsString: string;
    numberOfLines: number;
    encoding: string;
    delimiter: string;
    quoteChar: string;
}

export class ComponentMapping implements IComponentMapping, IListable {
    readonly id: string;
    readonly name: string;
    readonly fileName: string;
    readonly version: number;
    readonly columnLabels: string[];
    readonly columnLabelsString: string;
    readonly numberOfLines: number;
    readonly encoding: string;
    readonly delimiter: string;
    readonly quoteChar: string;

    constructor(componentMapping: IComponentMapping) {
        this.id = componentMapping.id;
        this.name = componentMapping.name;
        this.fileName = componentMapping.fileName;
        this.version = componentMapping.version;
        this.columnLabels = componentMapping.columnLabels;
        this.columnLabelsString = componentMapping.columnLabels?.join(', ');
        this.numberOfLines = componentMapping.numberOfLines;
        this.encoding = componentMapping.encoding;
        this.delimiter = componentMapping.delimiter;
        this.quoteChar = componentMapping.quoteChar;
    }

    get searchKey(): string {
        return this.name;
    }
}
