Project

General

Profile

Download (1.2 KB) Statistics
| Branch: | Tag: | Revision:
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.api.service.name.TypeDesignationSetManager.NullTypeDesignationStatus;
14
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
15

    
16
/**
17
 * @author pplitzner
18
 * @since May 3, 2018
19
 *
20
 */
21
public class TypeDesignationStatusComparator implements Comparator<TypeDesignationStatusBase> {
22
    @SuppressWarnings("unchecked")
23
    @Override
24
    public int compare(TypeDesignationStatusBase o1, TypeDesignationStatusBase o2) {
25
        // fix inverted order of cdm terms by -1*
26
        if(o1 == null && o2 == null || o1 instanceof NullTypeDesignationStatus && o2 instanceof NullTypeDesignationStatus){
27
            return 0;
28
        }
29
        if(o1 == null || o1 instanceof NullTypeDesignationStatus){
30
            return -1;
31
        }
32

    
33
        if(o2 == null || o2 instanceof NullTypeDesignationStatus){
34
            return 1;
35
        }
36
        return -1 * o1.compareTo(o2);
37
    }
38
}
(3-3/3)