### Question:
NullSafeComparableComparator implements Comparator<T>, Serializable { @Override public int compare(T obj1, T obj2) { if (obj1 == null) { return obj2 == null ? 0 : -1; } else if (obj2 == null) { return 1; } else { return obj1.compareTo(obj2); } }  @Override int compare(T obj1, T obj2);  }### Answer:
@Test public void null_before_object() { assertTrue(comparator.compare(null, "X") < 0); }
@Test public void object_after_null() { assertTrue(comparator.compare("X", null) > 0); }
@Test public void object_eq_object() { assertEquals(0, comparator.compare("X", "X")); }
@Test public void object_lt_object() { assertTrue(comparator.compare("X", "Y") < 0); }
@Test public void object_gt_object() { assertTrue(comparator.compare("Z", "Y") > 0); }