UNPKG

@tripsnek/tmf

Version:

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

35 lines 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EEnumImpl = void 0; const basicelist_1 = require("./basicelist"); const edata_type_impl_1 = require("./edata-type-impl"); class EEnumImpl extends edata_type_impl_1.EDataTypeImpl { eLiterals = new basicelist_1.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; } } } exports.EEnumImpl = EEnumImpl; //# sourceMappingURL=eenum-impl.js.map