BiopsyTreatmentResponseData implements Comparable<BiopsyTreatmentResponseData> { @Nullable public abstract LocalDate responseDate();  @Nullable abstract Integer treatmentId(); @Nullable abstract LocalDate assessmentDate(); @Nullable abstract LocalDate responseDate(); @Nullable abstract String response(); @Nullable abstract String measurementDone(); @Nullable abstract String boneOnlyDisease(); @NotNull abstract FormStatus formStatus(); @NotNull static BiopsyTreatmentResponseData of(@Nullable Integer treatmentId, @Nullable LocalDate assessmentDate,
            @Nullable LocalDate responseDate, @Nullable String response, @Nullable String measurementDone, @Nullable String boneOnlyDisease,
            @NotNull FormStatus formStatus); @Nullable LocalDate date(); boolean isNotDoneResponse(); @Override String toString(); @Override int compareTo(@NotNull BiopsyTreatmentResponseData other);  }
@Test public void sortsCorrectly() { BiopsyTreatmentResponseData response2017 = biopsyTreatmentResponseBuilder().responseDate(LocalDate.parse("2017-01-01")).build(); BiopsyTreatmentResponseData responseNull = biopsyTreatmentResponseBuilder().responseDate(null).build(); BiopsyTreatmentResponseData response2015 = biopsyTreatmentResponseBuilder().responseDate(LocalDate.parse("2015-01-01")).build(); BiopsyTreatmentResponseData response2016 = biopsyTreatmentResponseBuilder().responseDate(LocalDate.parse("2016-01-01")).build(); List<BiopsyTreatmentResponseData> responses = Lists.newArrayList(response2017, responseNull, response2015, response2016); Collections.sort(responses); assertEquals(response2015, responses.get(0)); assertEquals(response2016, responses.get(1)); assertEquals(response2017, responses.get(2)); assertEquals(responseNull, responses.get(3)); }