graphql.language.FragmentDefinition Maven / Gradle / Ivy
package graphql.language;
import graphql.PublicApi;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;
import java.util.ArrayList;
import java.util.List;
/**
* Provided to the DataFetcher, therefore public API
*/
@PublicApi
public class FragmentDefinition extends AbstractNode implements Definition, SelectionSetContainer, DirectivesContainer {
private String name;
private TypeName typeCondition;
private List directives;
private SelectionSet selectionSet;
public FragmentDefinition() {
this(null, null, new ArrayList<>(), null);
}
public FragmentDefinition(String name, TypeName typeCondition) {
this(name, typeCondition, new ArrayList<>(), null);
}
public FragmentDefinition(String name, TypeName typeCondition, SelectionSet selectionSet) {
this(name, typeCondition, new ArrayList<>(), selectionSet);
}
public FragmentDefinition(String name, TypeName typeCondition, List directives, SelectionSet selectionSet) {
this.name = name;
this.typeCondition = typeCondition;
this.directives = directives;
this.selectionSet = selectionSet;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public TypeName getTypeCondition() {
return typeCondition;
}
public void setTypeCondition(TypeName typeCondition) {
this.typeCondition = typeCondition;
}
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 List getChildren() {
List result = new ArrayList<>();
result.add(typeCondition);
result.addAll(directives);
result.add(selectionSet);
return result;
}
@Override
public boolean isEqualTo(Node o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FragmentDefinition that = (FragmentDefinition) o;
return NodeUtil.isEqualTo(this.name, that.name);
}
@Override
public FragmentDefinition deepCopy() {
return new FragmentDefinition(name,
deepCopy(typeCondition),
deepCopy(directives),
deepCopy(selectionSet)
);
}
@Override
public String toString() {
return "FragmentDefinition{" +
"name='" + name + '\'' +
", typeCondition='" + typeCondition + '\'' +
", directives=" + directives +
", selectionSet=" + selectionSet +
'}';
}
@Override
public TraversalControl accept(TraverserContext context, NodeVisitor nodeVisitor) {
return nodeVisitor.visitFragmentDefinition(this, context);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy