graphql.language.Directive Maven / Gradle / Ivy
package graphql.language;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static graphql.language.NodeUtil.argumentsByName;
public class Directive extends AbstractNode {
private final String name;
private final List arguments = new ArrayList<>();
public Directive(String name) {
this(name, Collections.emptyList());
}
public Directive(String name, List arguments) {
this.name = name;
this.arguments.addAll(arguments);
}
public List getArguments() {
return arguments;
}
public Map getArgumentsByName() {
// the spec says that args MUST be unique within context
return argumentsByName(arguments);
}
public Argument getArgument(String argumentName) {
return getArgumentsByName().get(argumentName);
}
public String getName() {
return name;
}
@Override
public List getChildren() {
return new ArrayList<>(arguments);
}
@Override
public boolean isEqualTo(Node o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Directive directive = (Directive) o;
return !(name != null ? !name.equals(directive.name) : directive.name != null);
}
@Override
public String toString() {
return "Directive{" +
"name='" + name + '\'' +
", arguments=" + arguments +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy