import { MetaElement } from '../../metaElement'; import { StateType } from './stateType'; import { IStateJSON }from './iStateJSON'; import { IStateModelFormat } from './iStateModelFormat'; /** * A `State` represents a possible state in a [[FSM]] * * States are **mutable** * * @specfield type ([[StateType]]): type of state */ export class State extends MetaElement { //================================ Representation ================================ private type: StateType; //================================= Constructor ================================== /** * Creates a new State s so that: * * s.name = name && * * s.type = type * @param name Name of the state * @param type Type of the state ([[StateType]]) */ public constructor(name: string, type: StateType) { super(name); this.type = type; } //=================================== Getters ==================================== /** * @willreturn this.type */ public getType(): StateType { return this.type; } //================================== Overriding ================================== public toJSON(): IStateJSON { return { id : this.getId(), name: this.getName(), type: this.type }; } public toModelFormat(): IStateModelFormat { return { id : this.getId(), name: this.getName(), type: this.type }; } }