1 |
1c3cb06b
|
Patrick Plitzner
|
/**
|
2 |
|
|
* Copyright (C) 2018 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*
|
6 |
|
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7 |
|
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8 |
|
|
*/
|
9 |
|
|
package eu.etaxonomy.taxeditor.ui.section;
|
10 |
|
|
|
11 |
|
|
import java.util.Comparator;
|
12 |
|
|
|
13 |
|
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
14 |
|
|
|
15 |
|
|
/**
|
16 |
|
|
* @author pplitzner
|
17 |
|
|
* @since Mar 5, 2018
|
18 |
|
|
*
|
19 |
|
|
*/
|
20 |
|
|
public class DefaultCdmBaseComparator<T extends CdmBase> implements Comparator<T> {
|
21 |
|
|
|
22 |
|
|
/**
|
23 |
|
|
* {@inheritDoc}
|
24 |
|
|
*/
|
25 |
|
|
@Override
|
26 |
|
|
public int compare(T o1, T o2) {
|
27 |
|
|
if(o1==null){
|
28 |
|
|
return -1;
|
29 |
|
|
}
|
30 |
|
|
if(o2==null){
|
31 |
|
|
return 1;
|
32 |
|
|
}
|
33 |
82a57421
|
Patrick Plitzner
|
int diff = o1.getId()-o2.getId();
|
34 |
|
|
if(diff==0){
|
35 |
|
|
diff = o1.getCreated().compareTo(o2.getCreated());
|
36 |
|
|
}
|
37 |
|
|
return diff;
|
38 |
1c3cb06b
|
Patrick Plitzner
|
}
|
39 |
|
|
|
40 |
|
|
}
|