/**
 * C'tor.
 * @param {*} visitor
 * @class
 * @author eric.wittmann@gmail.com
 */
var Traverser = /** @class */ (function () {
    function Traverser(visitor) {
        if (this.visitor === undefined)
            this.visitor = null;
        this.visitor = visitor;
    }
    /**
     * Traverse the items of the given array.
     * @param {Bound[]} items
     */
    Traverser.prototype.traverseCollection = function (items) {
        var _this = this;
        if (items != null) {
            items.forEach(function (node) {
                _this.traverseIfNotNull(node);
            });
        }
    };
    /**
     * Traverse the extension nodes, if any are found.
     * @param {ExtensibleNode} node
     */
    Traverser.prototype.traverseExtensions = function (node) {
        this.traverseCollection(node.getExtensions());
    };
    /**
     * Traverse all children of the indexed node.
     * @param {*} node
     */
    Traverser.prototype.traverseIndexedNode = function (node) {
        this.traverseCollection(node.getItems());
    };
    /**
     * Traverse the validation problems, if any are found.
     * @param {Node} node
     */
    Traverser.prototype.traverseValidationProblems = function (node) {
        this.traverseCollection(node.getValidationProblems());
    };
    /**
     * Called to traverse the data model starting at the given node and traversing
     * down until this node and all child nodes have been visited.
     * @param {Node} node
     */
    Traverser.prototype.traverse = function (node) {
        node.accept(this);
    };
    /**
     * Traverse into the given node, unless it's null.
     * @param {*} node
     */
    Traverser.prototype.traverseIfNotNull = function (node) {
        if (node != null) {
            node.accept(this);
        }
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitDocument(io.apicurio.datamodels.core.models.Document)
     * @param {Document} node
     */
    Traverser.prototype.visitDocument = function (node) {
        node.accept(this.visitor);
        this.traverseDocument(node);
    };
    /**
     * Subclasses can override this to provide version-specific traversal of the root document.
     * @param {Document} node
     */
    Traverser.prototype.traverseDocument = function (node) {
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
        this.traverseIfNotNull(node.info);
        this.traverseCollection(node.tags);
        this.traverseIfNotNull(node.externalDocs);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitExtension(io.apicurio.datamodels.core.models.Extension)
     * @param {Extension} node
     */
    Traverser.prototype.visitExtension = function (node) {
        node.accept(this.visitor);
        this.traverseValidationProblems(node);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitValidationProblem(io.apicurio.datamodels.core.models.ValidationProblem)
     * @param {ValidationProblem} problem
     */
    Traverser.prototype.visitValidationProblem = function (problem) {
        problem.accept(this.visitor);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitInfo(io.apicurio.datamodels.core.models.common.Info)
     * @param {Info} node
     */
    Traverser.prototype.visitInfo = function (node) {
        node.accept(this.visitor);
        this.traverseIfNotNull(node.contact);
        this.traverseIfNotNull(node.license);
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitContact(io.apicurio.datamodels.core.models.common.Contact)
     * @param {Contact} node
     */
    Traverser.prototype.visitContact = function (node) {
        node.accept(this.visitor);
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitLicense(io.apicurio.datamodels.core.models.common.License)
     * @param {License} node
     */
    Traverser.prototype.visitLicense = function (node) {
        node.accept(this.visitor);
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitTag(io.apicurio.datamodels.core.models.common.Tag)
     * @param {Tag} node
     */
    Traverser.prototype.visitTag = function (node) {
        node.accept(this.visitor);
        this.traverseIfNotNull(node.externalDocs);
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitSecurityRequirement(io.apicurio.datamodels.core.models.common.SecurityRequirement)
     * @param {SecurityRequirement} node
     */
    Traverser.prototype.visitSecurityRequirement = function (node) {
        node.accept(this.visitor);
        this.traverseValidationProblems(node);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitExternalDocumentation(io.apicurio.datamodels.core.models.common.ExternalDocumentation)
     * @param {ExternalDocumentation} node
     */
    Traverser.prototype.visitExternalDocumentation = function (node) {
        node.accept(this.visitor);
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitSchema(io.apicurio.datamodels.core.models.common.Schema)
     * @param {Schema} node
     */
    Traverser.prototype.visitSchema = function (node) {
        node.accept(this.visitor);
        this.traverseSchema(node);
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
    };
    Traverser.prototype.traverseSchema = function (node) {
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitParameter(io.apicurio.datamodels.core.models.common.Parameter)
     * @param {Parameter} node
     */
    Traverser.prototype.visitParameter = function (node) {
        node.accept(this.visitor);
        this.traverseParameter(node);
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
    };
    Traverser.prototype.traverseParameter = function (node) {
        this.traverseIfNotNull(node.schema);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitParameterDefinition(io.apicurio.datamodels.core.models.common.IDefinition)
     * @param {*} node
     */
    Traverser.prototype.visitParameterDefinition = function (node) {
        this.visitParameter(node);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitOperation(io.apicurio.datamodels.core.models.common.Operation)
     * @param {Operation} node
     */
    Traverser.prototype.visitOperation = function (node) {
        node.accept(this.visitor);
        this.traverseOperation(node);
    };
    Traverser.prototype.traverseOperation = function (node) {
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
        this.traverseIfNotNull(node.externalDocs);
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitSecurityScheme(io.apicurio.datamodels.core.models.common.SecurityScheme)
     * @param {SecurityScheme} node
     */
    Traverser.prototype.visitSecurityScheme = function (node) {
        node.accept(this.visitor);
        this.traverseSecurityScheme(node);
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
    };
    Traverser.prototype.traverseSecurityScheme = function (node) {
    };
    /**
     * @see io.apicurio.datamodels.core.visitors.IVisitor#visitSchemaDefinition(io.apicurio.datamodels.core.models.common.IDefinition)
     * @param {*} node
     */
    Traverser.prototype.visitSchemaDefinition = function (node) {
        var schema = node;
        this.visitSchema(schema);
    };
    /**
     * Traverse an OAuth flow.
     * @param {OAuthFlow} node
     */
    Traverser.prototype.traverseOAuthFlow = function (node) {
        node.accept(this.visitor);
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
    };
    /**
     * Traverses an oauth flows node.
     * @param {OAuthFlows} node
     */
    Traverser.prototype.traverseOAuthFlows = function (node) {
        node.accept(this.visitor);
        this.traverseIfNotNull(node.implicit);
        this.traverseIfNotNull(node.password);
        this.traverseIfNotNull(node.clientCredentials);
        this.traverseIfNotNull(node.authorizationCode);
        this.traverseExtensions(node);
        this.traverseValidationProblems(node);
    };
    return Traverser;
}());
export { Traverser };
Traverser["__class"] = "io.apicurio.datamodels.core.visitors.Traverser";
Traverser["__interfaces"] = ["io.apicurio.datamodels.core.visitors.IVisitor", "io.apicurio.datamodels.core.visitors.ITraverser"];
//# sourceMappingURL=Traverser.js.map