root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonComparatorSearch.java

Revision 12520, 1.0 kB (checked in by a.mueller, 10 months ago)

javadoc for TaxonComparatoSearch?

Line 
1/**
2* Copyright (C) 2007 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*/
9package eu.etaxonomy.cdm.model.taxon;
10
11import java.io.Serializable;
12import java.util.Comparator;
13
14import eu.etaxonomy.cdm.model.name.Rank;
15
16/**
17 * @author k.luther
18 * @date 18.03.2010
19 *
20 */
21public class TaxonComparatorSearch implements Serializable, Comparator<TaxonBase> {
22
23        public int compare(TaxonBase taxon1, TaxonBase taxon2) {
24               
25                Rank rankTax1 = taxon1.getName().getRank();
26                Rank rankTax2 = taxon2.getName().getRank();
27               
28                if (rankTax1 == null) return 2;
29                if (rankTax2 == null) return 1;
30                if (rankTax1.isHigher(rankTax2)) return 1;
31                else if (rankTax1.equals(rankTax2)) {
32                        //same rank, order by name
33                        return taxon1.getName().compareTo(taxon2.getName());
34                       
35                }
36                else return 2;
37        }
38
39}
Note: See TracBrowser for help on using the browser.