graphql.language.SchemaDefinition Maven / Gradle / Ivy
package graphql.language;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static graphql.language.NodeUtil.directivesByName;
public class SchemaDefinition extends AbstractNode implements Definition {
private final List directives;
private final List operationTypeDefinitions;
public SchemaDefinition() {
this(new ArrayList<>(), new ArrayList<>());
}
public SchemaDefinition(List directives, List operationTypeDefinitions) {
this.directives = directives;
this.operationTypeDefinitions = operationTypeDefinitions;
}
public List getDirectives() {
return directives;
}
public Map getDirectivesByName() {
return directivesByName(directives);
}
public Directive getDirective(String directiveName) {
return getDirectivesByName().get(directiveName);
}
public List getOperationTypeDefinitions() {
return operationTypeDefinitions;
}
@Override
public List getChildren() {
List result = new ArrayList<>();
result.addAll(directives);
result.addAll(operationTypeDefinitions);
return result;
}
@Override
public boolean isEqualTo(Node o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SchemaDefinition that = (SchemaDefinition) o;
return true;
}
@Override
public SchemaDefinition deepCopy() {
return new SchemaDefinition(deepCopy(directives), deepCopy(operationTypeDefinitions));
}
@Override
public String toString() {
return "SchemaDefinition{" +
"directives=" + directives +
", operationTypeDefinitions=" + operationTypeDefinitions +
"}";
}
@Override
public TraversalControl accept(TraverserContext context, NodeVisitor visitor) {
return visitor.visitSchemaDefinition(this, context);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy