forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirective.java
More file actions
78 lines (58 loc) · 1.89 KB
/
Directive.java
File metadata and controls
78 lines (58 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package graphql.language;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;
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<Directive> implements NamedNode<Directive> {
private final String name;
private final List<Argument> arguments = new ArrayList<>();
public Directive(String name) {
this(name, Collections.emptyList());
}
public Directive(String name, List<Argument> arguments) {
this.name = name;
this.arguments.addAll(arguments);
}
public List<Argument> getArguments() {
return arguments;
}
public Map<String, Argument> 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<Node> 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 that = (Directive) o;
return NodeUtil.isEqualTo(this.name, that.name);
}
@Override
public Directive deepCopy() {
return new Directive(name, deepCopy(arguments));
}
@Override
public String toString() {
return "Directive{" +
"name='" + name + '\'' +
", arguments=" + arguments +
'}';
}
@Override
public TraversalControl accept(TraverserContext<Node> context, NodeVisitor visitor) {
return visitor.visitDirective(this, context);
}
}