UNPKG

@tripsnek/tmf

Version:

TypeScript Modeling Framework - A TypeScript port of the Eclipse Modeling Framework (EMF)

31 lines 1.01 kB
import { BasicEList } from './basicelist'; import { EDataTypeImpl } from './edata-type-impl'; export class EEnumImpl extends EDataTypeImpl { eLiterals = new BasicEList(); constructor() { super(); } getELiterals() { return this.eLiterals; } addLiteral(value) { this.eLiterals.add(value); } getEEnumLiteralByLiteral(literal) { return this.eLiterals.find((e) => e.getLiteral() === literal); } getEEnumLiteral(value) { if (typeof value === 'number') { return this.eLiterals.find((e) => e.getValue() === value); } else { let toRet = this.eLiterals.find((e) => e.getLiteral() === value); //attempt to interpret string as literal value (in case number was passed in as a string) if (!toRet) { toRet = this.eLiterals.find((e) => e.getValue().toString() === value); } return toRet; } } } //# sourceMappingURL=eenum-impl.js.map