class Validator {

    static void validateOrbitReference(Document[] manifests) throws PDUStitchingException {
        if (manifests.length < 2) {
            return;
        }
        String[] tagNames = new String[]{"sentinel-safe:orbitNumber", "sentinel-safe:relativeOrbitNumber",
                "sentinel-safe:passNumber", "sentinel-safe:relativePassNumber",
                "sentinel-safe:cycleNumber", "sentinel-safe:phaseIdentifier",
                "sentinel-safe:epoch", "sentinel-safe:x", "sentinel-safe:y", "sentinel-safe:z"
        };
        for (String tagName : tagNames) {
            final NodeList referenceNodes = manifests[0].getElementsByTagName(tagName);
            for (int j = 1; j < manifests.length; j++) {
                final NodeList testNodes = manifests[j].getElementsByTagName(tagName);
                if (referenceNodes.getLength() != testNodes.getLength()) {
                    throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName);
                }
                for (int k = 0; k < referenceNodes.getLength(); k++) {
                    referenceNodes.item(k).normalize();
                    testNodes.item(k).normalize();
                    if (!referenceNodes.item(k).isEqualNode(testNodes.item(k))) {
                        throw new PDUStitchingException("Invalid orbit reference due to different element " + tagName);
                    }
                }
            }
        }
    }

}