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

graphql.language.InterfaceTypeDefinition Maven / Gradle / Ivy

There is a newer version: 230521-nf-execution
Show newest version
package graphql.language;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static graphql.language.NodeUtil.directivesByName;

public class InterfaceTypeDefinition extends AbstractNode implements TypeDefinition {
    private final String name;
    private final List definitions;
    private final List directives;

    public InterfaceTypeDefinition(String name) {
        this(name, new ArrayList<>(), new ArrayList<>());
    }

    public InterfaceTypeDefinition(String name, List definitions, List directives) {
        this.name = name;
        this.definitions = definitions;
        this.directives = directives;
    }

    public List getFieldDefinitions() {
        return definitions;
    }

    public List getDirectives() {
        return directives;
    }

    public Map getDirectivesByName() {
        return directivesByName(directives);
    }

    public Directive getDirective(String directiveName) {
        return getDirectivesByName().get(directiveName);
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public List getChildren() {
        List result = new ArrayList<>();
        result.addAll(definitions);
        result.addAll(directives);
        return result;
    }

    @Override
    public boolean isEqualTo(Node o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        InterfaceTypeDefinition that = (InterfaceTypeDefinition) o;

        return NodeUtil.isEqualTo(this.name, that.name);
    }

    @Override
    public InterfaceTypeDefinition deepCopy() {
        return new InterfaceTypeDefinition(name,
                deepCopy(definitions),
                deepCopy(directives)
        );
    }

    @Override
    public String toString() {
        return "InterfaceTypeDefinition{" +
                "name='" + name + '\'' +
                ", fieldDefinitions=" + definitions +
                ", directives=" + directives +
                '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy