2020-05-17 17:17:39 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) Sapphirecode - All Rights Reserved
|
|
|
|
* This file is part of graphviz-builder which is released under MIT.
|
|
|
|
* See file 'LICENSE' for full license details.
|
|
|
|
* Created by Timo Hocker <timo@scode.ovh>, May 2020
|
|
|
|
*/
|
|
|
|
|
2020-05-06 20:24:37 +02:00
|
|
|
import { validate_name } from '../Helper';
|
|
|
|
|
2020-04-24 12:02:32 +02:00
|
|
|
export class Element {
|
2020-04-29 22:19:08 +02:00
|
|
|
private _name = '';
|
2020-04-24 14:05:58 +02:00
|
|
|
protected parent_name: string;
|
|
|
|
|
2020-04-24 12:02:32 +02:00
|
|
|
public get full_name (): string {
|
2020-04-24 14:05:58 +02:00
|
|
|
if (this.parent_name)
|
|
|
|
return `${this.parent_name}_${this.name}`;
|
2020-04-24 12:21:26 +02:00
|
|
|
return this.name;
|
2020-04-24 12:02:32 +02:00
|
|
|
}
|
|
|
|
|
2020-04-29 22:19:08 +02:00
|
|
|
public get name (): string {
|
|
|
|
return this._name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public set name (val: string) {
|
2020-05-06 20:24:37 +02:00
|
|
|
this._name = validate_name (val);
|
2020-04-29 22:19:08 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 14:05:58 +02:00
|
|
|
public get parent (): string {
|
|
|
|
return this.parent_name;
|
|
|
|
}
|
|
|
|
|
2020-04-24 12:02:32 +02:00
|
|
|
public constructor (name: string, parent = '') {
|
|
|
|
this.name = name;
|
2020-04-24 14:05:58 +02:00
|
|
|
this.parent_name = parent;
|
2020-04-24 12:02:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
|
|
public toString (): string {
|
|
|
|
return this.full_name;
|
|
|
|
}
|
|
|
|
}
|