Given your answer to my comment, just do a boolean comparison.
.compare(c1.getX() == null, c2.getX() == null)
And given your revised reply, if your class has a method
public XType getX() {...}
then consider making XType
implement Comparable<XType>
or providing a Comparator<XType>
.