import { immutable, circular } from '../decorators';
import { LEVEL_ENUM, Vertex, Service, Entity, Structure, Enum } from '..';

/**
 * 数据分类
 */
export class DataNode extends Vertex {
    /**
     * 概念类型
     */
    @immutable()
    public readonly level: LEVEL_ENUM = LEVEL_ENUM.dataNode;

    @immutable()
    public readonly type: 'entities' | 'structures' = undefined;
    @immutable()
    public readonly entities: Array<Entity> = [];
    public readonly structures: Array<Structure> = [];
    public readonly enums: Array<Enum> = [];
    public readonly erdiagrams: Array<any> = [];
    public entityExpanded: boolean = true;
    public structureExpanded: boolean = true;
    public enumExpanded: boolean = true;

    @circular()
    @immutable()
    public readonly service: Service = undefined;
    /**
     * @param source 需要合并的部分参数
     */
    constructor(source?: Partial<DataNode>) {
        super();
        source && this.assign(source);
    }
}

export default DataNode;
