Repository navigation
Expand file tree
/
Copy pathObjectValue.java
More file actions
114 lines (87 loc) · 2.98 KB
/
Copy pathObjectValue.java
File metadata and controls
114 lines (87 loc) · 2.98 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
package graphql.language;
import graphql.PublicApi;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@PublicApi
public class ObjectValue extends AbstractNode<ObjectValue> implements Value<ObjectValue> {
private final List<ObjectField> objectFields = new ArrayList<>();
private ObjectValue(List<ObjectField> objectFields, SourceLocation sourceLocation, List<Comment> comments) {
super(sourceLocation, comments);
this.objectFields.addAll(objectFields);
}
/**
* alternative to using a Builder for convenience
*/
public ObjectValue() {
this(new ArrayList<>(), null, new ArrayList<>());
}
/**
* alternative to using a Builder for convenience
*/
public ObjectValue(List<ObjectField> objectFields) {
this(objectFields, null, new ArrayList<>());
}
public List<ObjectField> getObjectFields() {
return new ArrayList<>(objectFields);
}
@Override
public List<Node> getChildren() {
List<Node> result = new ArrayList<>();
result.addAll(objectFields);
return result;
}
@Override
public boolean isEqualTo(Node o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ObjectValue that = (ObjectValue) o;
return true;
}
@Override
public ObjectValue deepCopy() {
return new ObjectValue(deepCopy(objectFields), getSourceLocation(), getComments());
}
@Override
public String toString() {
return "ObjectValue{" +
"objectFields=" + objectFields +
'}';
}
@Override
public TraversalControl accept(TraverserContext<Node> context, NodeVisitor visitor) {
return visitor.visitObjectValue(this, context);
}
public static Builder newObjectValue() {
return new Builder();
}
public static final class Builder implements NodeBuilder {
private SourceLocation sourceLocation;
private List<ObjectField> objectFields = new ArrayList<>();
private List<Comment> comments = Collections.emptyList();
private Builder() {
}
public Builder sourceLocation(SourceLocation sourceLocation) {
this.sourceLocation = sourceLocation;
return this;
}
public Builder objectFields(List<ObjectField> objectFields) {
this.objectFields = objectFields;
return this;
}
public Builder objectField(ObjectField objectField) {
this.objectFields.add(objectField);
return this;
}
public Builder comments(List<Comment> comments) {
this.comments = comments;
return this;
}
public ObjectValue build() {
ObjectValue objectValue = new ObjectValue(objectFields, sourceLocation, comments);
return objectValue;
}
}
}