/* Generated from Java with JSweet 2.3.7 - http://www.jsweet.org */
import { Aai20Traverser } from '../../asyncapi/v2/visitors/Aai20Traverser';
import { CombinedReverseTraverser } from '../../combined/visitors/CombinedReverseTraverser';
import { TraverserDirection } from '../visitors/TraverserDirection';
import { Oas20Traverser } from '../../openapi/v2/visitors/Oas20Traverser';
import { Oas30Traverser } from '../../openapi/v3/visitors/Oas30Traverser';
import { DocumentType } from '../models/DocumentType';
/**
 * Creates a traverser for a particular data model.
 *
 * @author eric.wittmann@gmail.com
 * @class
 */
var TraverserFactory = /** @class */ (function () {
    function TraverserFactory() {
    }
    /**
     * Create the appropriate traverser for the given document/data model.
     *
     * @param {Document} doc
     * @param {*} visitor
     * @param {TraverserDirection} direction
     * @return {*}
     */
    TraverserFactory.create = function (doc, visitor, direction) {
        if (direction == null) {
            direction = TraverserDirection.down;
        }
        switch ((doc.getDocumentType())) {
            case DocumentType.asyncapi2:
                return direction === TraverserDirection.down ? new Aai20Traverser(visitor) : new CombinedReverseTraverser(visitor);
            case DocumentType.openapi2:
                return direction === TraverserDirection.down ? new Oas20Traverser(visitor) : new CombinedReverseTraverser(visitor);
            case DocumentType.openapi3:
                return direction === TraverserDirection.down ? new Oas30Traverser(visitor) : new CombinedReverseTraverser(visitor);
            default:
                throw Object.defineProperty(new Error("Failed to create a traverser for document type: " + doc.getDocumentType()), '__classes', { configurable: true, value: ['java.lang.Throwable', 'java.lang.Object', 'java.lang.RuntimeException', 'java.lang.Exception'] });
        }
    };
    return TraverserFactory;
}());
export { TraverserFactory };
TraverserFactory["__class"] = "io.apicurio.datamodels.core.factories.TraverserFactory";
//# sourceMappingURL=TraverserFactory.js.map