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.api.service.name;
|
10
|
|
11
|
import java.util.Comparator;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
14
|
import eu.etaxonomy.cdm.ref.TypedEntityReference;
|
15
|
|
16
|
/**
|
17
|
* @author pplitzner
|
18
|
* @since May 3, 2018
|
19
|
*/
|
20
|
public class TypedEntityComparator implements Comparator<TypedEntityReference<TypeDesignationBase<?>> >{
|
21
|
|
22
|
@Override
|
23
|
public int compare(TypedEntityReference<TypeDesignationBase<?>> o1, TypedEntityReference<TypeDesignationBase<?>> o2) {
|
24
|
if(o1==null){
|
25
|
return 1;
|
26
|
}
|
27
|
if(o2==null){
|
28
|
return -1;
|
29
|
}
|
30
|
if(o1.getUuid()==null){
|
31
|
return 1;
|
32
|
}
|
33
|
if(o2.getUuid()==null){
|
34
|
return-1;
|
35
|
}
|
36
|
|
37
|
return o1.getLabel().compareTo(o2.getLabel());
|
38
|
}
|
39
|
}
|