How to simplify a null-safe compareTo() implementation?

You can simply use Apache Commons Lang:

result = ObjectUtils.compare(firstComparable, secondComparable)

Leave a Comment