private static ComparisonResults.Builder compareMaps(ComparisonResults.Builder builder, Map<?,?> mapA, Map<?,?> mapB, String beanName) { int countA = mapA.size(); int countB = mapB.size(); if (countA != countB) { builder.add(beanName+":count()", countA, countB, ComparisonResults.SIZE); } Collection<?> keysA = mapA.keySet(); Collection<?> keysB = mapB.keySet(); List<?> intersection = BeanUtils.intersection(keysA, keysB); for (Object key : intersection) { Object valueA = mapA.get(key); Object valueB = mapB.get(key); compare(builder, null, valueA, valueB, beanName+"["+key+"]"); } for (Object key : mapA.keySet()) { if (intersection.contains(key) == false) { builder.add(beanName+"["+key+"]", mapA.get(key), null, ComparisonResults.MISSING_B); } } for (Object key : mapB.keySet()) { if (intersection.contains(key) == false) { builder.add(beanName+"["+key+"]", null, mapA.get(key), ComparisonResults.MISSING_A); } } return builder; }