all files / dist/wrappers/ WrapperFactory.js

100% Statements 24/24
100% Branches 2/2
100% Functions 7/7
100% Lines 23/23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37      132× 72× 62× 10× 10×       10×   60×     100×          
"use strict";
var StructurePropertyWrapper_1 = require("./StructurePropertyWrapper");
var StructureTypeParameterWrapper_1 = require("./StructureTypeParameterWrapper");
var StructureTypeWrapper_1 = require("./StructureTypeWrapper");
var StructureWrapper_1 = require("./StructureWrapper");
var WrapperFactory = (function () {
    function WrapperFactory(transformOptions) {
        this.transformOptions = transformOptions;
        this.structureWrappers = [];
    }
    WrapperFactory.prototype.getStructure = function (definition) {
        // ensure only one wrapper per class is created (otherwise infinite loop will ensue when checking if a structure already exists)
        var existing = this.structureWrappers.filter(function (s) { return s.definition === definition; })[0];
        if (existing != null)
            return existing.wrapper;
        var wrapper = new StructureWrapper_1.StructureWrapper(this, this.transformOptions, definition);
        this.structureWrappers.push({
            wrapper: wrapper,
            definition: definition
        });
        return wrapper;
    };
    WrapperFactory.prototype.getStructureProperty = function (parent, definition) {
        return new StructurePropertyWrapper_1.StructurePropertyWrapper(this, this.transformOptions, parent, definition);
    };
    WrapperFactory.prototype.getStructureTypeParameter = function (structure, typeParamDefinition) {
        return new StructureTypeParameterWrapper_1.StructureTypeParameterWrapper(this, structure, typeParamDefinition);
    };
    WrapperFactory.prototype.getStructureType = function (structure, typeDef) {
        return new StructureTypeWrapper_1.StructureTypeWrapper(this, this.transformOptions, structure, typeDef);
    };
    return WrapperFactory;
}());
exports.WrapperFactory = WrapperFactory;
 
//# sourceMappingURL=WrapperFactory.js.map