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

graphql.language.EnumTypeDefinition 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 EnumTypeDefinition extends AbstractNode implements TypeDefinition {
    private final String name;
    private final List enumValueDefinitions;
    private final List directives;

    public EnumTypeDefinition(String name) {
        this(name, null);
    }

    public EnumTypeDefinition(String name, List directives) {
        this.name = name;
        this.directives = (null == directives) ? new ArrayList<>() : directives;
        this.enumValueDefinitions = new ArrayList<>();
    }

    public List getEnumValueDefinitions() {
        return enumValueDefinitions;
    }

    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(enumValueDefinitions);
        result.addAll(directives);
        return result;
    }

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

        EnumTypeDefinition that = (EnumTypeDefinition) o;

        if (null == name) {
            if (null != that.name) return false;
        } else if (!name.equals(that.name)) {
            return false;
        }
        return true;

    }


    @Override
    public String toString() {
        return "EnumTypeDefinition{" +
                "name='" + name + '\'' +
                ", enumValueDefinitions=" + enumValueDefinitions +
                ", directives=" + directives +
                '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy