UNPKG

1.04 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const javaUtil_1 = require("./java/javaUtil");
4class CodegenModelFactory {
5 /**
6 * Configure a different implementation class.
7 *
8 * @param type the type that shall be replaced
9 * @param implementation the implementation class must extend the default class and must provide a public no-arg constructor
10 */
11 static setTypeMapping(type, implementation) {
12 if (!(implementation.prototype instanceof type.getDefaultImplementation())) {
13 throw new Error(implementation + " doesn't extend " + type);
14 }
15 CodegenModelFactory.typeMapping.put(type, implementation);
16 }
17 static newInstance(type) {
18 const classType = CodegenModelFactory.typeMapping.get(type) ||
19 type.getDefaultImplementation();
20 return new classType();
21 }
22}
23exports.default = CodegenModelFactory;
24CodegenModelFactory.typeMapping = javaUtil_1.newHashMap();
25//# sourceMappingURL=CodegenModelFactory.js.map
\No newline at end of file