graphql.language.AbstractNode Maven / Gradle / Ivy
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 implements Node {
private SourceLocation sourceLocation;
private List comments = Collections.emptyList();
public void setSourceLocation(SourceLocation sourceLocation) {
this.sourceLocation = sourceLocation;
}
@Override
public SourceLocation getSourceLocation() {
return sourceLocation;
}
public List getComments() {
return comments;
}
public void setComments(List comments) {
assertNotNull(comments, "You must provide non null comments");
this.comments = comments;
}
@SuppressWarnings("unchecked")
protected V deepCopy(V nullableObj) {
if (nullableObj == null) {
return null;
}
return (V) nullableObj.deepCopy();
}
@SuppressWarnings("unchecked")
protected List deepCopy(List extends Node> list) {
if (list == null) {
return null;
}
return list.stream().map(Node::deepCopy).map(node -> (V) node).collect(Collectors.toList());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy