forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathField.java
More file actions
140 lines (103 loc) · 3.26 KB
/
Field.java
File metadata and controls
140 lines (103 loc) · 3.26 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package graphql.language;
import graphql.PublicApi;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static graphql.language.NodeUtil.directivesByName;
/*
* This is provided to a DataFetcher, therefore it is a public API.
* This might change in the future.
*/
@PublicApi
public class Field extends AbstractNode implements Selection {
private String name;
private String alias;
private List<Argument> arguments = new ArrayList<>();
private List<Directive> directives = new ArrayList<>();
private SelectionSet selectionSet;
public Field() {
}
public Field(String name) {
this.name = name;
}
public Field(String name, SelectionSet selectionSet) {
this.name = name;
this.selectionSet = selectionSet;
}
public Field(String name, List<Argument> arguments) {
this.name = name;
this.arguments = arguments;
}
public Field(String name, List<Argument> arguments, List<Directive> directives) {
this.name = name;
this.arguments = arguments;
this.directives = directives;
}
public Field(String name, List<Argument> arguments, SelectionSet selectionSet) {
this.name = name;
this.arguments = arguments;
this.selectionSet = selectionSet;
}
@Override
public List<Node> getChildren() {
List<Node> result = new ArrayList<>();
result.addAll(arguments);
result.addAll(directives);
if (selectionSet != null) result.add(selectionSet);
return result;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public List<Argument> getArguments() {
return arguments;
}
public void setArguments(List<Argument> arguments) {
this.arguments = arguments;
}
public List<Directive> getDirectives() {
return directives;
}
public Map<String, Directive> getDirectivesByName() {
return directivesByName(directives);
}
public Directive getDirective(String directiveName) {
return getDirectivesByName().get(directiveName);
}
public void setDirectives(List<Directive> directives) {
this.directives = directives;
}
public SelectionSet getSelectionSet() {
return selectionSet;
}
public void setSelectionSet(SelectionSet selectionSet) {
this.selectionSet = selectionSet;
}
@Override
public boolean isEqualTo(Node o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Field field = (Field) o;
if (name != null ? !name.equals(field.name) : field.name != null) return false;
return !(alias != null ? !alias.equals(field.alias) : field.alias != null);
}
@Override
public String toString() {
return "Field{" +
"name='" + name + '\'' +
", alias='" + alias + '\'' +
", arguments=" + arguments +
", directives=" + directives +
", selectionSet=" + selectionSet +
'}';
}
}