@Test public void testCompareNullCourseMeetingWithNonNull() { CourseMeeting senCM = null; CourseMeeting mikeCM = new CourseMeeting(); assertEquals("They are not equal",-1, new CourseMeetingCompareByRoomAndStreetAddress().compare(senCM,mikeCM)); assertEquals("They are not equal",+1, new CourseMeetingCompareByRoomAndStreetAddress().compare(mikeCM,senCM)); }
@Override public int compare(CourseMeeting cm1, CourseMeeting cm2) { if(cm1 == cm2) return 0; if(null == cm1) return -1; if(null == cm2) return +1; if(cm1.getLocation() == cm2.getLocation()) return 0; if(null == cm1.getLocation()) return -1; if(null == cm2.getLocation()) return +1; if(!(cm1.getLocation().getRoom() == cm2.getLocation().getRoom())) { if(null == cm1.getLocation().getRoom()) return -1; if(null == cm2.getLocation().getRoom()) return +1; return (cm1.getLocation().getRoom().compareTo(cm2.getLocation().getRoom())); } else { if(cm1.getLocation().getStreetAddress() == cm2.getLocation().getStreetAddress()) return 0; if(null == cm1.getLocation().getStreetAddress()) return -1; if(null == cm2.getLocation().getStreetAddress()) return +1; return (cm1.getLocation().getStreetAddress().compareTo(cm2.getLocation().getStreetAddress())); } }
CourseMeetingCompareByRoomAndStreetAddress implements
               Comparator<CourseMeeting> { @Override public int compare(CourseMeeting cm1, CourseMeeting cm2) { if(cm1 == cm2) return 0; if(null == cm1) return -1; if(null == cm2) return +1; if(cm1.getLocation() == cm2.getLocation()) return 0; if(null == cm1.getLocation()) return -1; if(null == cm2.getLocation()) return +1; if(!(cm1.getLocation().getRoom() == cm2.getLocation().getRoom())) { if(null == cm1.getLocation().getRoom()) return -1; if(null == cm2.getLocation().getRoom()) return +1; return (cm1.getLocation().getRoom().compareTo(cm2.getLocation().getRoom())); } else { if(cm1.getLocation().getStreetAddress() == cm2.getLocation().getStreetAddress()) return 0; if(null == cm1.getLocation().getStreetAddress()) return -1; if(null == cm2.getLocation().getStreetAddress()) return +1; return (cm1.getLocation().getStreetAddress().compareTo(cm2.getLocation().getStreetAddress())); } } }
CourseMeetingCompareByRoomAndStreetAddress implements
               Comparator<CourseMeeting> { @Override public int compare(CourseMeeting cm1, CourseMeeting cm2) { if(cm1 == cm2) return 0; if(null == cm1) return -1; if(null == cm2) return +1; if(cm1.getLocation() == cm2.getLocation()) return 0; if(null == cm1.getLocation()) return -1; if(null == cm2.getLocation()) return +1; if(!(cm1.getLocation().getRoom() == cm2.getLocation().getRoom())) { if(null == cm1.getLocation().getRoom()) return -1; if(null == cm2.getLocation().getRoom()) return +1; return (cm1.getLocation().getRoom().compareTo(cm2.getLocation().getRoom())); } else { if(cm1.getLocation().getStreetAddress() == cm2.getLocation().getStreetAddress()) return 0; if(null == cm1.getLocation().getStreetAddress()) return -1; if(null == cm2.getLocation().getStreetAddress()) return +1; return (cm1.getLocation().getStreetAddress().compareTo(cm2.getLocation().getStreetAddress())); } }  }
CourseMeetingCompareByRoomAndStreetAddress implements
               Comparator<CourseMeeting> { @Override public int compare(CourseMeeting cm1, CourseMeeting cm2) { if(cm1 == cm2) return 0; if(null == cm1) return -1; if(null == cm2) return +1; if(cm1.getLocation() == cm2.getLocation()) return 0; if(null == cm1.getLocation()) return -1; if(null == cm2.getLocation()) return +1; if(!(cm1.getLocation().getRoom() == cm2.getLocation().getRoom())) { if(null == cm1.getLocation().getRoom()) return -1; if(null == cm2.getLocation().getRoom()) return +1; return (cm1.getLocation().getRoom().compareTo(cm2.getLocation().getRoom())); } else { if(cm1.getLocation().getStreetAddress() == cm2.getLocation().getStreetAddress()) return 0; if(null == cm1.getLocation().getStreetAddress()) return -1; if(null == cm2.getLocation().getStreetAddress()) return +1; return (cm1.getLocation().getStreetAddress().compareTo(cm2.getLocation().getStreetAddress())); } }  @Override int compare(CourseMeeting cm1, CourseMeeting cm2); }
CourseMeetingCompareByRoomAndStreetAddress implements
               Comparator<CourseMeeting> { @Override public int compare(CourseMeeting cm1, CourseMeeting cm2) { if(cm1 == cm2) return 0; if(null == cm1) return -1; if(null == cm2) return +1; if(cm1.getLocation() == cm2.getLocation()) return 0; if(null == cm1.getLocation()) return -1; if(null == cm2.getLocation()) return +1; if(!(cm1.getLocation().getRoom() == cm2.getLocation().getRoom())) { if(null == cm1.getLocation().getRoom()) return -1; if(null == cm2.getLocation().getRoom()) return +1; return (cm1.getLocation().getRoom().compareTo(cm2.getLocation().getRoom())); } else { if(cm1.getLocation().getStreetAddress() == cm2.getLocation().getStreetAddress()) return 0; if(null == cm1.getLocation().getStreetAddress()) return -1; if(null == cm2.getLocation().getStreetAddress()) return +1; return (cm1.getLocation().getStreetAddress().compareTo(cm2.getLocation().getStreetAddress())); } }  @Override int compare(CourseMeeting cm1, CourseMeeting cm2);  }