Project

General

Profile

Revision 782d98d9

ID782d98d93e60dc00bfa12051eac48c1c51992e13
Parent e7f22f90
Child 42c0aaf3

Added by Katja Luther about 3 years ago

add TypeDesignationComparator

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/name/TypeDesignationComparator.java
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

  
15
/**
16
 * @author k.luther
17
 * @since 06.09.2018
18
 *
19
 */
20
public class TypeDesignationComparator implements Comparator<TypeDesignationBase> {
21

  
22

  
23
    private TypeDesignationStatusComparator statusComparator = new TypeDesignationStatusComparator();
24

  
25
    @SuppressWarnings("unchecked")
26
    @Override
27
    public int compare(TypeDesignationBase o1, TypeDesignationBase o2) {
28

  
29
        if(o1==null){
30
            return 1;
31
        }
32
        if(o2==null){
33
            return -1;
34
        }
35
        if(o1.getTypeStatus()==null){
36
            return 1;
37
        }
38
        if(o2.getUuid()==null){
39
            return-1;
40
        }
41
        return statusComparator.compare(o1.getTypeStatus(), o2.getTypeStatus()) ;
42
    }
43
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)