"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.OperationRenameAttributesPersistence = void 0;
const internal_1 = require("../../../internal");
const OperationBasePersistence_1 = require("./OperationBasePersistence");
/**
 * Operation RenameAttributes persistence
 */
class OperationRenameAttributesPersistence {
    static fromData(ctx, object) {
        if (!object) {
            return undefined;
        }
        const renameAttributesOp = OperationBasePersistence_1.OperationBasePersistence.fromData(ctx, internal_1.cdmObjectType.operationRenameAttributesDef, object);
        renameAttributesOp.renameFormat = object.renameFormat;
        if (typeof (object.applyTo) === 'string') {
            renameAttributesOp.applyTo = [object.applyTo];
        }
        else if (Array.isArray(object.applyTo)) {
            renameAttributesOp.applyTo = object.applyTo;
        }
        else if (object.applyTo !== undefined) {
            internal_1.Logger.error(ctx, this.TAG, this.fromData.name, undefined, internal_1.cdmLogCode.ErrPersistProjUnsupportedProp);
        }
        return renameAttributesOp;
    }
    static toData(instance, resOpt, options) {
        if (!instance) {
            return undefined;
        }
        const data = OperationBasePersistence_1.OperationBasePersistence.toData(instance, resOpt, options);
        data.renameFormat = instance.renameFormat;
        data.applyTo = instance.applyTo;
        return data;
    }
}
exports.OperationRenameAttributesPersistence = OperationRenameAttributesPersistence;
OperationRenameAttributesPersistence.TAG = OperationRenameAttributesPersistence.name;
//# sourceMappingURL=OperationRenameAttributesPersistence.js.map