"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.OperationReplaceAsForeignKeyPersistence = void 0;
const internal_1 = require("../../../internal");
const TypeAttributePersistence_1 = require("../TypeAttributePersistence");
const utils = require("../utils");
const OperationBasePersistence_1 = require("./OperationBasePersistence");
/**
 * Operation ReplaceAsForeignKey persistence
 */
class OperationReplaceAsForeignKeyPersistence {
    static fromData(ctx, object) {
        if (!object) {
            return undefined;
        }
        const replaceAsForeignKeyOp = OperationBasePersistence_1.OperationBasePersistence.fromData(ctx, internal_1.cdmObjectType.operationReplaceAsForeignKeyDef, object);
        replaceAsForeignKeyOp.reference = object.reference;
        replaceAsForeignKeyOp.replaceWith = utils.createAttribute(ctx, object.replaceWith);
        return replaceAsForeignKeyOp;
    }
    static toData(instance, resOpt, options) {
        if (!instance) {
            return undefined;
        }
        const data = OperationBasePersistence_1.OperationBasePersistence.toData(instance, resOpt, options);
        data.reference = instance.reference;
        data.replaceWith = TypeAttributePersistence_1.TypeAttributePersistence.toData(instance.replaceWith, resOpt, options);
        return data;
    }
}
exports.OperationReplaceAsForeignKeyPersistence = OperationReplaceAsForeignKeyPersistence;
//# sourceMappingURL=OperationReplaceAsForeignKeyPersistence.js.map