All Downloads are FREE. Search and download functionalities are using the official Maven repository.

graphql.language.AstComparator Maven / Gradle / Ivy

There is a newer version: 230521-nf-execution
Show newest version
package graphql.language;


import graphql.Internal;

import java.util.Iterator;
import java.util.List;

@Internal
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