1 import { Line } from './Line';
2 import { InconsistencyError, NotFoundError } from './Errors';
4 export default abstract class Form {
5 private _lines: Line<any>[] = [];
7 abstract get name(): string;
10 this.getLines().map(this.addLine.bind(this));
13 protected abstract getLines(): Line<any>[];
15 get allowMultipleCopies(): boolean {
19 private addLine(line: Line<any>) {
21 this.getLine(line.id);
23 this._lines.push(line);
26 throw new InconsistencyError('Cannot add a line with a duplicate identifier');
29 getLine(id: string): Line<any> {
30 const lines = this._lines.filter(l => l.id === id);
31 if (lines.length == 0) {
32 throw new NotFoundError(id);