UNPKG

@yellicode/elements

Version:

The meta model API for Yellicode - an extensible code generator.

83 lines (82 loc) 3.75 kB
/* * Copyright (c) 2020 Yellicode * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as classes from './classes'; var ElementFactory = /** @class */ (function () { function ElementFactory(modelDelegate) { this.modelDelegate = modelDelegate; } ElementFactory.prototype.create = function (elementType, owner) { switch (elementType) { case 'class': return new classes.Class(this.modelDelegate, owner); case 'stereotype': return new classes.Stereotype(this.modelDelegate, owner); case 'property': return new classes.Property(this.modelDelegate, owner); case 'package': return new classes.Package(this.modelDelegate, owner); case 'profile': return new classes.Profile(this.modelDelegate, owner); case 'dataType': return new classes.DataType(this.modelDelegate, owner); case 'primitiveType': return new classes.PrimitiveType(this.modelDelegate, owner); case 'parameter': return new classes.Parameter(this.modelDelegate, owner); case 'operation': return new classes.Operation(this.modelDelegate, owner); case 'model': return new classes.Model(this.modelDelegate, owner); case 'literalUnlimitedNatural': return new classes.LiteralUnlimitedNatural(this.modelDelegate, owner); case 'literalString': return new classes.LiteralString(this.modelDelegate, owner); case 'literalReal': return new classes.LiteralReal(this.modelDelegate, owner); case 'literalNull': return new classes.LiteralNull(this.modelDelegate, owner); case 'literalInteger': return new classes.LiteralInteger(this.modelDelegate, owner); case 'literalBoolean': return new classes.LiteralBoolean(this.modelDelegate, owner); case 'interfaceRealization': return new classes.InterfaceRealization(this.modelDelegate, owner); case 'interface': return new classes.Interface(this.modelDelegate, owner); case 'generalization': return new classes.Generalization(this.modelDelegate, owner); case 'enumerationLiteral': return new classes.EnumerationLiteral(this.modelDelegate, owner); case 'enumeration': return new classes.Enumeration(this.modelDelegate, owner); case 'comment': return new classes.Comment(this.modelDelegate, owner); case 'association': return new classes.Association(this.modelDelegate, owner); default: throw "Cannot create element of type " + elementType + ". The element type is not supported."; } }; ElementFactory.requiresId = function (elementType) { switch (elementType) { case 'literalUnlimitedNatural': case 'literalString': case 'literalReal': case 'literalNull': case 'literalInteger': case 'literalBoolean': case 'enumerationLiteral': case 'comment': return false; default: return true; } }; return ElementFactory; }()); export { ElementFactory };