Project

General

Profile

Download (1.26 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.taxeditor.editor.view.checklist.e4;
10

    
11
import java.util.Comparator;
12

    
13
import eu.etaxonomy.cdm.api.service.dto.TaxonDistributionDTO;
14
import eu.etaxonomy.cdm.compare.OrderIndexComparator;
15

    
16
/**
17
 * @author k.luther
18
 * @since 28.11.2018
19
 */
20
public class TaxonDistributionDtoComparator implements Comparator<TaxonDistributionDTO> {
21

    
22
    @Override
23
    public int compare(TaxonDistributionDTO arg0, TaxonDistributionDTO arg1) {
24
        if (arg0 == arg1){
25
            return 0;
26
        }
27

    
28
        if (arg0.getTaxonUuid().equals(arg1.getTaxonUuid())){
29
            return 0;
30
        }
31

    
32
        String name1 = arg0.getNameCache();
33
        String name2 = arg1.getNameCache();
34
        Integer rankTax1 = arg0.getRankOrderIndex();
35
        Integer rankTax2 = arg1.getRankOrderIndex();
36

    
37
        int rankOrder = OrderIndexComparator.instance().compare(rankTax1, rankTax2);
38

    
39
        if (rankOrder == 0) {
40
            //same rank, order by name
41
            return name1.compareTo(name2);
42
        }
43
        return rankOrder;
44

    
45

    
46
    }
47

    
48
}
(19-19/19)