class DataTypeConfigCompare {

    public CompareResult run(Configuration left, Configuration right) {
        SortedSet<String> same = new TreeSet<>();
        SortedSet<String> diff = new TreeSet<>();
        SortedSet<String> leftOnly = new TreeSet<>();
        SortedSet<String> rightOnly = new TreeSet<>();
        
        String leftPrefix = getPrefix(left);
        String rightPrefix = getPrefix(right);
        
        for (Map.Entry<String,String> entry : left) {
            ConfField field = new ConfField(leftPrefix, entry.getKey());
            
            String leftValue = entry.getValue();
            String rightValue = right.get(field.getField(rightPrefix));
            
            if (nullSafeEquals(leftValue, rightValue)) {
                same.add(field.getField());
            } else if (rightValue == null) {
                leftOnly.add(field.getField());
            } else {
                diff.add(field.getField());
            }
        }
        
        // To find values only in right, we just iterate through
        // and verify each property does not exist in left, since
        // we already checked equivalence above.
        for (Map.Entry<String,String> entry : right) {
            ConfField field = new ConfField(rightPrefix, entry.getKey());
            if (left.get(field.getField(leftPrefix)) == null) {
                rightOnly.add(field.getField());
            }
        }
        
        return new CompareResult(same, diff, leftOnly, rightOnly);
    }

}