io.apicurio.datamodels.combined.visitors.CombinedCompositeVisitor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of data-models-test Show documentation
Show all versions of data-models-test Show documentation
Open Source API Design Studio
/*
* Copyright 2019 Red Hat
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.apicurio.datamodels.combined.visitors;
import java.util.ArrayList;
import java.util.List;
import io.apicurio.datamodels.asyncapi.v2.visitors.IAai20Visitor;
import io.apicurio.datamodels.core.models.Document;
import io.apicurio.datamodels.core.models.Extension;
import io.apicurio.datamodels.core.models.IVisitable;
import io.apicurio.datamodels.core.models.Node;
import io.apicurio.datamodels.core.models.ValidationProblem;
import io.apicurio.datamodels.core.models.common.AuthorizationCodeOAuthFlow;
import io.apicurio.datamodels.core.models.common.ClientCredentialsOAuthFlow;
import io.apicurio.datamodels.core.models.common.Contact;
import io.apicurio.datamodels.core.models.common.ExternalDocumentation;
import io.apicurio.datamodels.core.models.common.IDefinition;
import io.apicurio.datamodels.core.models.common.IExample;
import io.apicurio.datamodels.core.models.common.ImplicitOAuthFlow;
import io.apicurio.datamodels.core.models.common.Info;
import io.apicurio.datamodels.core.models.common.License;
import io.apicurio.datamodels.core.models.common.OAuthFlows;
import io.apicurio.datamodels.core.models.common.Operation;
import io.apicurio.datamodels.core.models.common.Parameter;
import io.apicurio.datamodels.core.models.common.PasswordOAuthFlow;
import io.apicurio.datamodels.core.models.common.Schema;
import io.apicurio.datamodels.core.models.common.SecurityRequirement;
import io.apicurio.datamodels.core.models.common.SecurityScheme;
import io.apicurio.datamodels.core.models.common.Server;
import io.apicurio.datamodels.core.models.common.ServerVariable;
import io.apicurio.datamodels.core.models.common.Tag;
import io.apicurio.datamodels.core.visitors.IVisitor;
import io.apicurio.datamodels.openapi.models.IOasPropertySchema;
import io.apicurio.datamodels.openapi.models.OasHeader;
import io.apicurio.datamodels.openapi.models.OasPathItem;
import io.apicurio.datamodels.openapi.models.OasPaths;
import io.apicurio.datamodels.openapi.models.OasResponse;
import io.apicurio.datamodels.openapi.models.OasResponses;
import io.apicurio.datamodels.openapi.models.OasSchema;
import io.apicurio.datamodels.openapi.models.OasXML;
import io.apicurio.datamodels.openapi.v2.models.Oas20Definitions;
import io.apicurio.datamodels.openapi.v2.models.Oas20Headers;
import io.apicurio.datamodels.openapi.v2.models.Oas20Items;
import io.apicurio.datamodels.openapi.v2.models.Oas20ParameterDefinitions;
import io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinitions;
import io.apicurio.datamodels.openapi.v2.models.Oas20Scopes;
import io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions;
import io.apicurio.datamodels.openapi.v2.visitors.IOas20Visitor;
import io.apicurio.datamodels.openapi.v3.models.Oas30Callback;
import io.apicurio.datamodels.openapi.v3.models.Oas30CallbackDefinition;
import io.apicurio.datamodels.openapi.v3.models.Oas30CallbackPathItem;
import io.apicurio.datamodels.openapi.v3.models.Oas30Discriminator;
import io.apicurio.datamodels.openapi.v3.models.Oas30Encoding;
import io.apicurio.datamodels.openapi.v3.models.Oas30ExampleDefinition;
import io.apicurio.datamodels.openapi.v3.models.Oas30HeaderDefinition;
import io.apicurio.datamodels.openapi.v3.models.Oas30Link;
import io.apicurio.datamodels.openapi.v3.models.Oas30LinkDefinition;
import io.apicurio.datamodels.openapi.v3.models.Oas30LinkParameterExpression;
import io.apicurio.datamodels.openapi.v3.models.Oas30LinkRequestBodyExpression;
import io.apicurio.datamodels.openapi.v3.models.Oas30LinkServer;
import io.apicurio.datamodels.openapi.v3.models.Oas30MediaType;
import io.apicurio.datamodels.openapi.v3.models.Oas30RequestBody;
import io.apicurio.datamodels.openapi.v3.models.Oas30RequestBodyDefinition;
import io.apicurio.datamodels.openapi.v3.models.Oas30Schema.Oas30AnyOfSchema;
import io.apicurio.datamodels.openapi.v3.models.Oas30Schema.Oas30NotSchema;
import io.apicurio.datamodels.openapi.v3.models.Oas30Schema.Oas30OneOfSchema;
import io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor;
/**
* A composite visitor base class useful for any data model type.
*
* @author [email protected]
* @author Jakub Senko
*/
public class CombinedCompositeVisitor extends CombinedAllNodeVisitor implements IOas20Visitor, IOas30Visitor, IAai20Visitor {
private List visitors = new ArrayList<>();
/**
* Constructor.
*
* @param visitors
*/
public CombinedCompositeVisitor(List visitors) {
this.visitors = visitors;
}
/**
* Adds a visitor.
*
* @param visitor
*/
public void addVisitor(IVisitor visitor) {
this.visitors.add(visitor);
}
/**
* Adds multiple visitors.
*
* @param visitors
*/
public void addVisitors(List extends IVisitor> visitors) {
this.visitors.addAll(visitors);
}
/**
* Make the node accept all of the visitors.
*
* @param node
*/
protected void acceptAll(IVisitable node) {
this.visitors.forEach(visitor -> {
node.accept(visitor);
});
}
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitPaths(io.apicurio.datamodels.openapi.models.OasPaths)
*/
@Override
public void visitPaths(OasPaths node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitPathItem(io.apicurio.datamodels.openapi.models.OasPathItem)
*/
@Override
public void visitPathItem(OasPathItem node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitResponse(io.apicurio.datamodels.openapi.models.OasResponse)
*/
@Override
public void visitResponse(OasResponse node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitResponses(io.apicurio.datamodels.openapi.models.OasResponses)
*/
@Override
public void visitResponses(OasResponses node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitXML(io.apicurio.datamodels.openapi.models.OasXML)
*/
@Override
public void visitXML(OasXML node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitAllOfSchema(io.apicurio.datamodels.openapi.models.OasSchema)
*/
@Override
public void visitAllOfSchema(OasSchema node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitItemsSchema(io.apicurio.datamodels.openapi.models.OasSchema)
*/
@Override
public void visitItemsSchema(OasSchema node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitAdditionalPropertiesSchema(io.apicurio.datamodels.openapi.models.OasSchema)
*/
@Override
public void visitAdditionalPropertiesSchema(OasSchema node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitPropertySchema(io.apicurio.datamodels.openapi.models.IOasPropertySchema)
*/
@Override
public void visitPropertySchema(IOasPropertySchema node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitHeader(io.apicurio.datamodels.openapi.models.OasHeader)
*/
@Override
public void visitHeader(OasHeader node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitResponseDefinition(io.apicurio.datamodels.core.models.common.IDefinition)
*/
@Override
public void visitResponseDefinition(IDefinition node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitDocument(io.apicurio.datamodels.core.models.Document)
*/
@Override
public void visitDocument(Document node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitInfo(io.apicurio.datamodels.core.models.common.Info)
*/
@Override
public void visitInfo(Info node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitContact(io.apicurio.datamodels.core.models.common.Contact)
*/
@Override
public void visitContact(Contact node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitLicense(io.apicurio.datamodels.core.models.common.License)
*/
@Override
public void visitLicense(License node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitTag(io.apicurio.datamodels.core.models.common.Tag)
*/
@Override
public void visitTag(Tag node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitExternalDocumentation(io.apicurio.datamodels.core.models.common.ExternalDocumentation)
*/
@Override
public void visitExternalDocumentation(ExternalDocumentation node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitExtension(io.apicurio.datamodels.core.models.Extension)
*/
@Override
public void visitExtension(Extension node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitServer(io.apicurio.datamodels.core.models.common.Server)
*/
@Override
public void visitServer(Server node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitSecurityRequirement(io.apicurio.datamodels.core.models.common.SecurityRequirement)
*/
@Override
public void visitSecurityRequirement(SecurityRequirement node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitServerVariable(io.apicurio.datamodels.core.models.common.ServerVariable)
*/
@Override
public void visitServerVariable(ServerVariable node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitValidationProblem(io.apicurio.datamodels.core.models.ValidationProblem)
*/
@Override
public void visitValidationProblem(ValidationProblem problem) {
this.acceptAll(problem);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitSchema(io.apicurio.datamodels.core.models.common.Schema)
*/
@Override
public void visitSchema(Schema node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitSchemaDefinition(io.apicurio.datamodels.core.models.common.IDefinition)
*/
@Override
public void visitSchemaDefinition(IDefinition node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitParameter(io.apicurio.datamodels.core.models.common.Parameter)
*/
@Override
public void visitParameter(Parameter node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitOperation(io.apicurio.datamodels.core.models.common.Operation)
*/
@Override
public void visitOperation(Operation node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitSecurityScheme(io.apicurio.datamodels.core.models.common.SecurityScheme)
*/
@Override
public void visitSecurityScheme(SecurityScheme node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitCallbackPathItem(io.apicurio.datamodels.openapi.v3.models.Oas30CallbackPathItem)
*/
@Override
public void visitCallbackPathItem(Oas30CallbackPathItem node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitCallback(io.apicurio.datamodels.openapi.v3.models.Oas30Callback)
*/
@Override
public void visitCallback(Oas30Callback node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitLinkServer(io.apicurio.datamodels.openapi.v3.models.Oas30LinkServer)
*/
@Override
public void visitLinkServer(Oas30LinkServer node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitCallbackDefinition(io.apicurio.datamodels.openapi.v3.models.Oas30CallbackDefinition)
*/
@Override
public void visitCallbackDefinition(Oas30CallbackDefinition node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitLink(io.apicurio.datamodels.openapi.v3.models.Oas30Link)
*/
@Override
public void visitLink(Oas30Link node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitLinkRequestBodyExpression(io.apicurio.datamodels.openapi.v3.models.Oas30LinkRequestBodyExpression)
*/
@Override
public void visitLinkRequestBodyExpression(Oas30LinkRequestBodyExpression node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitLinkParameterExpression(io.apicurio.datamodels.openapi.v3.models.Oas30LinkParameterExpression)
*/
@Override
public void visitLinkParameterExpression(Oas30LinkParameterExpression node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitLinkDefinition(io.apicurio.datamodels.openapi.v3.models.Oas30LinkDefinition)
*/
@Override
public void visitLinkDefinition(Oas30LinkDefinition node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitAuthorizationCodeOAuthFlow(io.apicurio.datamodels.core.models.common.AuthorizationCodeOAuthFlow)
*/
@Override
public void visitAuthorizationCodeOAuthFlow(AuthorizationCodeOAuthFlow node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitClientCredentialsOAuthFlow(io.apicurio.datamodels.core.models.common.ClientCredentialsOAuthFlow)
*/
@Override
public void visitClientCredentialsOAuthFlow(ClientCredentialsOAuthFlow node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitPasswordOAuthFlow(io.apicurio.datamodels.core.models.common.PasswordOAuthFlow)
*/
@Override
public void visitPasswordOAuthFlow(PasswordOAuthFlow node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitImplicitOAuthFlow(io.apicurio.datamodels.core.models.common.ImplicitOAuthFlow)
*/
@Override
public void visitImplicitOAuthFlow(ImplicitOAuthFlow node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitOAuthFlows(io.apicurio.datamodels.core.models.common.OAuthFlows)
*/
@Override
public void visitOAuthFlows(OAuthFlows node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitEncoding(io.apicurio.datamodels.openapi.v3.models.Oas30Encoding)
*/
@Override
public void visitEncoding(Oas30Encoding node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitMediaType(io.apicurio.datamodels.openapi.v3.models.Oas30MediaType)
*/
@Override
public void visitMediaType(Oas30MediaType node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitHeaderDefinition(io.apicurio.datamodels.openapi.v3.models.Oas30HeaderDefinition)
*/
@Override
public void visitHeaderDefinition(Oas30HeaderDefinition node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitRequestBody(io.apicurio.datamodels.openapi.v3.models.Oas30RequestBody)
*/
@Override
public void visitRequestBody(Oas30RequestBody node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitRequestBodyDefinition(io.apicurio.datamodels.openapi.v3.models.Oas30RequestBodyDefinition)
*/
@Override
public void visitRequestBodyDefinition(Oas30RequestBodyDefinition node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitExampleDefinition(io.apicurio.datamodels.openapi.v3.models.Oas30ExampleDefinition)
*/
@Override
public void visitExampleDefinition(Oas30ExampleDefinition node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v3.visitors.IOas30Visitor#visitDiscriminator(io.apicurio.datamodels.openapi.v3.models.Oas30Discriminator)
*/
@Override
public void visitDiscriminator(Oas30Discriminator node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitNotSchema(io.apicurio.datamodels.openapi.v3.models.Oas30Schema.Oas30NotSchema)
*/
@Override
public void visitNotSchema(Oas30NotSchema node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitOneOfSchema(io.apicurio.datamodels.openapi.v3.models.Oas30Schema.Oas30OneOfSchema)
*/
@Override
public void visitOneOfSchema(Oas30OneOfSchema node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitAnyOfSchema(io.apicurio.datamodels.openapi.v3.models.Oas30Schema.Oas30AnyOfSchema)
*/
@Override
public void visitAnyOfSchema(Oas30AnyOfSchema node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.core.visitors.IVisitor#visitParameterDefinition(io.apicurio.datamodels.core.models.common.IDefinition)
*/
@Override
public void visitParameterDefinition(IDefinition node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v2.visitors.IOas20Visitor#visitItems(io.apicurio.datamodels.openapi.v2.models.Oas20Items)
*/
@Override
public void visitItems(Oas20Items node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v2.visitors.IOas20Visitor#visitScopes(io.apicurio.datamodels.openapi.v2.models.Oas20Scopes)
*/
@Override
public void visitScopes(Oas20Scopes node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v2.visitors.IOas20Visitor#visitSecurityDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20SecurityDefinitions)
*/
@Override
public void visitSecurityDefinitions(Oas20SecurityDefinitions node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v2.visitors.IOas20Visitor#visitDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20Definitions)
*/
@Override
public void visitDefinitions(Oas20Definitions node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v2.visitors.IOas20Visitor#visitParameterDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20ParameterDefinitions)
*/
@Override
public void visitParameterDefinitions(Oas20ParameterDefinitions node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.combined.visitors.CombinedAllNodeVisitor#visitExample(io.apicurio.datamodels.core.models.common.IExample)
*/
@Override
public void visitExample(IExample node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v2.visitors.IOas20Visitor#visitHeaders(io.apicurio.datamodels.openapi.v2.models.Oas20Headers)
*/
@Override
public void visitHeaders(Oas20Headers node) {
this.acceptAll(node);
}
/**
* @see io.apicurio.datamodels.openapi.v2.visitors.IOas20Visitor#visitResponseDefinitions(io.apicurio.datamodels.openapi.v2.models.Oas20ResponseDefinitions)
*/
@Override
public void visitResponseDefinitions(Oas20ResponseDefinitions node) {
this.acceptAll(node);
}
protected void visitNode(Node node) {
// Does nothing - subclasses should override this. The class is not abstract because we
// want the compiler to yell at us when methods are added to the visitor interfaces and not
// implemented here.
}
}