graphql.language.AstComparator Maven / Gradle / Ivy
package graphql.language;
import java.util.Iterator;
import java.util.List;
public class AstComparator {
public boolean isEqual(Node node1, Node node2) {
if (null == node1) return null == node2;
if (!node1.isEqualTo(node2)) return false;
List childs1 = node1.getChildren();
List childs2 = node2.getChildren();
if (childs1.size() != childs2.size()) return false;
for (int i = 0; i < childs1.size(); i++) {
if (!isEqual(childs1.get(i), childs2.get(i))) return false;
}
return true;
}
public boolean isEqual(List nodes1, List nodes2) {
if (nodes1.size() != nodes2.size()) return false;
Iterator iter1 = nodes1.iterator();
Iterator iter2 = nodes2.iterator();
while (iter1.hasNext()) {
if (!isEqual(iter1.next(), iter2.next())) return false;
}
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy