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 { Constants } from '../../../Constants';
import { ValidationRule } from '../../ValidationRule';
/**
 * Constructor.
 * @param {ValidationRuleMetaData} ruleInfo
 * @class
 * @extends ValidationRule
 * @author eric.wittmann@gmail.com
 */
var OasOperationIdUniquenessValidationRule = /** @class */ (function (_super) {
    __extends(OasOperationIdUniquenessValidationRule, _super);
    function OasOperationIdUniquenessValidationRule(ruleInfo) {
        var _this = _super.call(this, ruleInfo) || this;
        _this.indexedOperations = ({});
        return _this;
    }
    /**
     * @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitOperation(io.apicurio.datamodels.core.models.common.Operation)
     * @param {Operation} node
     */
    OasOperationIdUniquenessValidationRule.prototype.visitOperation = function (node) {
        if (this.hasValue(node.operationId)) {
            var dupes = (function (m, k) { return m[k] === undefined ? null : m[k]; })(this.indexedOperations, node.operationId);
            if (this.hasValue(dupes)) {
                this.reportIfInvalid(/* size */ dupes.length > 1, /* get */ dupes[0], Constants.PROP_OPERATION_ID, this.map("operationId", node.operationId));
                this.report(node, Constants.PROP_OPERATION_ID, this.map("operationId", node.operationId));
                /* add */ (dupes.push(node) > 0);
            }
            else {
                dupes = ([]);
                /* add */ (dupes.push(node) > 0);
                /* put */ (this.indexedOperations[node.operationId] = dupes);
            }
        }
    };
    return OasOperationIdUniquenessValidationRule;
}(ValidationRule));
export { OasOperationIdUniquenessValidationRule };
OasOperationIdUniquenessValidationRule["__class"] = "io.apicurio.datamodels.core.validation.rules.other.OasOperationIdUniquenessValidationRule";
OasOperationIdUniquenessValidationRule["__interfaces"] = ["io.apicurio.datamodels.core.visitors.IVisitor", "io.apicurio.datamodels.asyncapi.v2.visitors.IAai20Visitor", "io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor", "io.apicurio.datamodels.asyncapi.visitors.IAaiVisitor", "io.apicurio.datamodels.openapi.v2.visitors.IOas20Visitor", "io.apicurio.datamodels.openapi.visitors.IOasVisitor"];
//# sourceMappingURL=OasOperationIdUniquenessValidationRule.js.map