"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TraitGroupReferencePersistence = void 0;
const __1 = require("..");
const internal_1 = require("../../internal");
const cdmObjectRefPersistence_1 = require("./cdmObjectRefPersistence");
class TraitGroupReferencePersistence extends cdmObjectRefPersistence_1.cdmObjectRefPersistence {
    static fromData(ctx, object) {
        // Note: Trait group reference by definition cannot be specified as a simple named reference
        if (!object || !object.traitGroupReference) {
            return;
        }
        let optional;
        let traitGroup;
        optional = object.optional;
        if (typeof (object.traitGroupReference) === 'string') {
            traitGroup = object.traitGroupReference;
        }
        else {
            traitGroup = __1.CdmFolder.TraitGroupPersistence.fromData(ctx, object.traitGroupReference);
        }
        const traitGroupReference = ctx.corpus.MakeRef(internal_1.cdmObjectType.traitGroupRef, traitGroup, false);
        if (optional !== undefined) {
            traitGroupReference.optional = optional;
        }
        return traitGroupReference;
    }
}
exports.TraitGroupReferencePersistence = TraitGroupReferencePersistence;
//# sourceMappingURL=TraitGroupReferencePersistence.js.map