1
|
/**
|
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.cdm.compare.name;
|
10
|
|
11
|
import java.util.Comparator;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
14
|
|
15
|
/**
|
16
|
* @author k.luther
|
17
|
* @since 06.09.2018
|
18
|
*/
|
19
|
public class TypeDesignationComparator implements Comparator<TypeDesignationBase> {
|
20
|
|
21
|
@SuppressWarnings("rawtypes")
|
22
|
private TypeDesignationStatusComparator statusComparator = new TypeDesignationStatusComparator();
|
23
|
|
24
|
@SuppressWarnings("unchecked")
|
25
|
@Override
|
26
|
public int compare(@SuppressWarnings("rawtypes") TypeDesignationBase o1, @SuppressWarnings("rawtypes") TypeDesignationBase o2) {
|
27
|
|
28
|
if (o1 == o2){
|
29
|
return 0;
|
30
|
}else if(o1==null){
|
31
|
return 1;
|
32
|
}else if(o2==null){
|
33
|
return -1;
|
34
|
}
|
35
|
|
36
|
if (o1.getTypeStatus()==null && o2.getTypeStatus()==null){
|
37
|
return o1.getUuid().compareTo(o2.getUuid());
|
38
|
}else if (o1.getTypeStatus() != null && o2.getTypeStatus() != null){
|
39
|
return statusComparator.compare(o1.getTypeStatus(), o2.getTypeStatus()) ;
|
40
|
}else if (o1.getTypeStatus()==null){
|
41
|
return 1;
|
42
|
}else {
|
43
|
return -1; //o2.getTypeStatus()==null
|
44
|
}
|
45
|
}
|
46
|
}
|