forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractNode.java
More file actions
50 lines (37 loc) · 1.27 KB
/
AbstractNode.java
File metadata and controls
50 lines (37 loc) · 1.27 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
package graphql.language;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static graphql.Assert.assertNotNull;
public abstract class AbstractNode<T extends Node> implements Node<T> {
private SourceLocation sourceLocation;
private List<Comment> comments = Collections.emptyList();
public void setSourceLocation(SourceLocation sourceLocation) {
this.sourceLocation = sourceLocation;
}
@Override
public SourceLocation getSourceLocation() {
return sourceLocation;
}
public List<Comment> getComments() {
return comments;
}
public void setComments(List<Comment> comments) {
assertNotNull(comments, "You must provide non null comments");
this.comments = comments;
}
@SuppressWarnings("unchecked")
protected <V extends Node> V deepCopy(V nullableObj) {
if (nullableObj == null) {
return null;
}
return (V) nullableObj.deepCopy();
}
@SuppressWarnings("unchecked")
protected <V extends Node> List<V> deepCopy(List<? extends Node> list) {
if (list == null) {
return null;
}
return list.stream().map(Node::deepCopy).map(node -> (V) node).collect(Collectors.toList());
}
}