2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.e4
;
11 import java
.util
.Comparator
;
13 import eu
.etaxonomy
.cdm
.api
.service
.dto
.TaxonDistributionDTO
;
14 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
21 public class TaxonDistributionDtoComparator
implements Comparator
<TaxonDistributionDTO
> {
27 public int compare(TaxonDistributionDTO arg0
, TaxonDistributionDTO arg1
) {
32 if (arg0
.getTaxonUuid().equals(arg1
.getTaxonUuid())){
36 String name1
= arg0
.getNameCache();
37 String name2
= arg1
.getNameCache();
38 Rank rankTax1
= arg0
.getRank();
39 Rank rankTax2
= arg1
.getRank();
41 if (rankTax1
== null && rankTax2
!= null){
43 }else if(rankTax2
== null && rankTax1
!= null){
45 }else if (rankTax1
!= null && rankTax1
.isHigher(rankTax2
)){
47 }else if (rankTax1
== null && rankTax2
== null || rankTax1
.equals(rankTax2
)) {
48 //same rank, order by name
49 return name1
.compareTo(name2
);