var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* Generated from Java with JSweet 2.3.7 - http://www.jsweet.org */
import { AbstractCommand } from '../AbstractCommand';
import { LoggerCompat } from '../../compat/LoggerCompat';
/**
 * A command used to aggregate an array of other commands into a single logical command.  This is used
 * for example to make multiple changes as a single "undoable" change.
 * @author eric.wittmann@gmail.com
 * @extends AbstractCommand
 * @class
 */
var AggregateCommand = /** @class */ (function (_super) {
    __extends(AggregateCommand, _super);
    function AggregateCommand(name, info, commands) {
        var _this = this;
        if (((typeof name === 'string') || name === null) && ((info != null) || info === null) && ((commands != null && (commands instanceof Array)) || commands === null)) {
            var __args = arguments;
            _this = _super.call(this) || this;
            if (_this.name === undefined)
                _this.name = null;
            if (_this.info === undefined)
                _this.info = null;
            if (_this._commands === undefined)
                _this._commands = null;
            if (_this.name === undefined)
                _this.name = null;
            if (_this.info === undefined)
                _this.info = null;
            if (_this._commands === undefined)
                _this._commands = null;
            (function () {
                _this.name = name;
                _this.info = info;
                _this._commands = commands;
            })();
        }
        else if (name === undefined && info === undefined && commands === undefined) {
            var __args = arguments;
            _this = _super.call(this) || this;
            if (_this.name === undefined)
                _this.name = null;
            if (_this.info === undefined)
                _this.info = null;
            if (_this._commands === undefined)
                _this._commands = null;
            if (_this.name === undefined)
                _this.name = null;
            if (_this.info === undefined)
                _this.info = null;
            if (_this._commands === undefined)
                _this._commands = null;
        }
        else
            throw new Error('invalid overload');
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.cmd.ICommand#execute(io.apicurio.datamodels.core.models.Document)
     * @param {Document} document
     */
    AggregateCommand.prototype.execute = function (document) {
        LoggerCompat.info("[AggregateCommand] Executing %d child commands.", /* size */ this._commands.length);
        this._commands.forEach(function (command) {
            command.execute(document);
        });
    };
    /**
     * @see io.apicurio.datamodels.cmd.ICommand#undo(io.apicurio.datamodels.core.models.Document)
     * @param {Document} document
     */
    AggregateCommand.prototype.undo = function (document) {
        LoggerCompat.info("[AggregateCommand] Reverting %d child commands.", /* size */ this._commands.length);
        for (var idx = this._commands.length - 1; idx >= 0; idx--) {
            {
                var command = this._commands[idx];
                command.undo(document);
            }
            ;
        }
    };
    return AggregateCommand;
}(AbstractCommand));
export { AggregateCommand };
AggregateCommand["__class"] = "io.apicurio.datamodels.cmd.commands.AggregateCommand";
AggregateCommand["__interfaces"] = ["io.apicurio.datamodels.cmd.ICommand"];
//# sourceMappingURL=AggregateCommand.js.map