graphql.language.OperationDefinition Maven / Gradle / Ivy
package graphql.language;
import java.util.ArrayList;
import java.util.List;
public class OperationDefinition extends AbstractNode implements Definition {
public enum Operation {
QUERY, MUTATION, SUBSCRIPTION
}
private String name;
private Operation operation;
private List variableDefinitions = new ArrayList<>();
private List directives = new ArrayList<>();
private SelectionSet selectionSet;
public OperationDefinition() {
}
public OperationDefinition(String name, Operation operation, List variableDefinitions, List directives, SelectionSet selectionSet) {
this.name = name;
this.operation = operation;
this.variableDefinitions = variableDefinitions;
this.directives = directives;
this.selectionSet = selectionSet;
}
public OperationDefinition(String name, Operation operation, List variableDefinitions, SelectionSet selectionSet) {
this.name = name;
this.operation = operation;
this.variableDefinitions = variableDefinitions;
this.selectionSet = selectionSet;
}
public OperationDefinition(String name, Operation operation, SelectionSet selectionSet) {
this.name = name;
this.operation = operation;
this.selectionSet = selectionSet;
}
@Override
public List getChildren() {
List result = new ArrayList<>();
result.addAll(variableDefinitions);
result.addAll(directives);
result.add(selectionSet);
return result;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Operation getOperation() {
return operation;
}
public void setOperation(Operation operation) {
this.operation = operation;
}
public List getVariableDefinitions() {
return variableDefinitions;
}
public void setVariableDefinitions(List variableDefinitions) {
this.variableDefinitions = variableDefinitions;
}
public List getDirectives() {
return directives;
}
public void setDirectives(List directives) {
this.directives = directives;
}
public SelectionSet getSelectionSet() {
return selectionSet;
}
public void setSelectionSet(SelectionSet selectionSet) {
this.selectionSet = selectionSet;
}
@Override
public boolean isEqualTo(Node o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OperationDefinition that = (OperationDefinition) o;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
return operation == that.operation;
}
@Override
public String toString() {
return "OperationDefinition{" +
"name='" + name + '\'' +
", operation=" + operation +
", variableDefinitions=" + variableDefinitions +
", directives=" + directives +
", selectionSet=" + selectionSet +
'}';
}
}