"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.DataTypePersistence = void 0;
const __1 = require("..");
const internal_1 = require("../../internal");
const copyDataUtils = require("../../Utilities/CopyDataUtils");
const utils = require("./utils");
class DataTypePersistence {
    static fromData(ctx, object) {
        const dataType = ctx.corpus.MakeObject(internal_1.cdmObjectType.dataTypeDef, object.dataTypeName);
        dataType.extendsDataType = __1.CdmFolder.DataTypeReferencePersistence.fromData(ctx, object.extendsDataType);
        if (object.explanation) {
            dataType.explanation = object.explanation;
        }
        utils.addArrayToCdmCollection(dataType.exhibitsTraits, utils.createTraitReferenceArray(ctx, object.exhibitsTraits));
        return dataType;
    }
    static toData(instance, resOpt, options) {
        return {
            explanation: instance.explanation,
            dataTypeName: instance.dataTypeName,
            extendsDataType: instance.extendsDataType
                ? instance.extendsDataType.copyData(resOpt, options)
                : undefined,
            exhibitsTraits: copyDataUtils.arrayCopyData(resOpt, instance.exhibitsTraits, options)
        };
    }
}
exports.DataTypePersistence = DataTypePersistence;
//# sourceMappingURL=DataTypePersistence.js.map