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 { CombinedCompositeVisitor } from '../../combined/visitors/CombinedCompositeVisitor';
import { ValidationProblemSeverity } from '../models/ValidationProblemSeverity';
import { NodePathUtil } from '../util/NodePathUtil';
/**
 * Constructor.
 * @param {Document} document
 * @class
 * @extends CombinedCompositeVisitor
 * @author eric.wittmann@gmail.com
 */
var ValidationVisitor = /** @class */ (function (_super) {
    __extends(ValidationVisitor, _super);
    function ValidationVisitor(document) {
        var _this = _super.call(this, ([])) || this;
        _this.problems = ([]);
        if (_this.severityRegistry === undefined)
            _this.severityRegistry = null;
        var ruleSet = ValidationRuleSet.instance_$LI$();
        var rulesFor = ruleSet.getRulesFor(document);
        rulesFor.forEach(function (rule) {
            rule.setReporter(_this);
        });
        _this.addVisitors(rulesFor);
        return _this;
    }
    /**
     * Sets the severity registry.
     * @param {*} severityRegistry
     */
    ValidationVisitor.prototype.setSeverityRegistry = function (severityRegistry) {
        this.severityRegistry = severityRegistry;
    };
    /**
     * Accessor for the problems.
     * @return {ValidationProblem[]}
     */
    ValidationVisitor.prototype.getValidationProblems = function () {
        return this.problems;
    };
    /**
     * @see io.apicurio.datamodels.core.validation.IValidationProblemReporter#report(io.apicurio.datamodels.core.validation.ValidationRuleMetaData, io.apicurio.datamodels.core.models.Node, java.lang.String, java.lang.String)
     * @param {ValidationRuleMetaData} ruleInfo
     * @param {Node} node
     * @param {string} property
     * @param {string} message
     */
    ValidationVisitor.prototype.report = function (ruleInfo, node, property, message) {
        var severity = this.severityRegistry.lookupSeverity(ruleInfo);
        if (severity === ValidationProblemSeverity.ignore) {
            return;
        }
        var path = NodePathUtil.createNodePath(node);
        var problem = node.addValidationProblem(ruleInfo.code, path, property, message, severity);
        /* add */ (this.problems.push(problem) > 0);
    };
    return ValidationVisitor;
}(CombinedCompositeVisitor));
export { ValidationVisitor };
ValidationVisitor["__class"] = "io.apicurio.datamodels.core.validation.ValidationVisitor";
ValidationVisitor["__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.core.validation.IValidationProblemReporter", "io.apicurio.datamodels.openapi.visitors.IOasVisitor"];
import { ValidationRuleSet } from './ValidationRuleSet';
//# sourceMappingURL=ValidationVisitor.js.map