I'm using unitils tool for deep objects comparing, via ReflectionComparator:
ReflectionComparatorMode[] modes = {ReflectionComparatorMode.LENIENT_ORDER, ReflectionComparatorMode.IGNORE_DEFAULTS};
ReflectionComparator comparator = ReflectionComparatorFactory.createRefectionComparator(modes);
Difference difference = comparator.getDifference(oldObject, newObject);
It turns out that this ReflectionComparator doesn't ignore case in String fields values. And there isn't sprecial mode for this purpose in ReflectionComparatorMode enum:
public enum ReflectionComparatorMode {
IGNORE_DEFAULTS,
LENIENT_DATES,
LENIENT_ORDER
}
Any ideas, how it could be achieved?
Investigation of how
ReflectionComparatorworks gave me this workable solution. Saying in brief, we have to add another one specialComparatorobject for dealing withStringobjects in comparators chain.Also we have to do some bedlam with extracting one needed
protectedstatic method fromReflectionComparatorFactoryin order to reduce code doubling.