@Test public void compare() { final TrackedEntityInstance tei1 = new TrackedEntityInstance( "efg" ); final TrackedEntityInstance tei2 = new TrackedEntityInstance(); final TrackedEntityInstance tei3 = new TrackedEntityInstance( "abc" ); final TrackedEntityInstance tei4 = new TrackedEntityInstance( "hij" ); final List<TrackedEntityInstance> list = new ArrayList<>( Arrays.asList( tei1, tei2, tei3, tei4 ) ); list.sort( DhisResourceComparator.INSTANCE ); Assert.assertNull( list.get( 0 ).getId() ); Assert.assertEquals( "abc", list.get( 1 ).getId() ); Assert.assertEquals( "efg", list.get( 2 ).getId() ); Assert.assertEquals( "hij", list.get( 3 ).getId() ); }
@Override public int compare( DhisResource o1, DhisResource o2 ) { return ObjectUtils.compare( o1 == null ? null : o1.getId(), o2 == null ? null : o2.getId() ); }
DhisResourceComparator implements Comparator<DhisResource> { @Override public int compare( DhisResource o1, DhisResource o2 ) { return ObjectUtils.compare( o1 == null ? null : o1.getId(), o2 == null ? null : o2.getId() ); } }
DhisResourceComparator implements Comparator<DhisResource> { @Override public int compare( DhisResource o1, DhisResource o2 ) { return ObjectUtils.compare( o1 == null ? null : o1.getId(), o2 == null ? null : o2.getId() ); }  }
DhisResourceComparator implements Comparator<DhisResource> { @Override public int compare( DhisResource o1, DhisResource o2 ) { return ObjectUtils.compare( o1 == null ? null : o1.getId(), o2 == null ? null : o2.getId() ); }  @Override int compare( DhisResource o1, DhisResource o2 ); }
DhisResourceComparator implements Comparator<DhisResource> { @Override public int compare( DhisResource o1, DhisResource o2 ) { return ObjectUtils.compare( o1 == null ? null : o1.getId(), o2 == null ? null : o2.getId() ); }  @Override int compare( DhisResource o1, DhisResource o2 ); static final DhisResourceComparator INSTANCE; }