UNPKG

ern-api-gen

Version:

Electrode Native API generator

25 lines 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const javaUtil_1 = require("./java/javaUtil"); class CodegenModelFactory { /** * Configure a different implementation class. * * @param type the type that shall be replaced * @param implementation the implementation class must extend the default class and must provide a public no-arg constructor */ static setTypeMapping(type, implementation) { if (!(implementation.prototype instanceof type.getDefaultImplementation())) { throw new Error(implementation + " doesn't extend " + type); } CodegenModelFactory.typeMapping.put(type, implementation); } static newInstance(type) { const classType = CodegenModelFactory.typeMapping.get(type) || type.getDefaultImplementation(); return new classType(); } } CodegenModelFactory.typeMapping = javaUtil_1.newHashMap(); exports.default = CodegenModelFactory; //# sourceMappingURL=CodegenModelFactory.js.map