ComparableFactory { public Comparable createDefault() { return create(Comparator.CompareMode.DEFAULT); } private  ComparableFactory(); static ComparableFactory instance(); Comparable createDefault(); Comparable create(Comparator.CompareMode compareMode);  }
@Test public void testCreateDefault() throws ParseException { Comparable comparable = ComparableFactory.instance().create(Comparator.CompareMode.DEFAULT); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Student left = Student.builder() .name("java") .age(12) .birthday(dateFormat.parse("2007-12-12 00:00:01")) .school("w3c") .build(); Student right = Student.builder() .name("python") .age(10) .birthday(dateFormat.parse("2009-12-12 00:00:01")) .school("w3c") .build(); CompareResult result = comparable.compare(left, right); Assert.assertNotEquals(result, null); Assert.assertTrue(result.hasDifference()); Assert.assertEquals(result.getDifferences().size(), 3); }