All Downloads are FREE. Search and download functionalities are using the official Maven repository.

graphql.language.FragmentDefinition Maven / Gradle / Ivy

There is a newer version: 230521-nf-execution
Show newest version
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;
    }

    @Override
    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;
    }

    @Override
    public List getDirectives() {
        return directives;
    }

    public void setDirectives(List directives) {
        this.directives = directives;
    }

    @Override
    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