Revision df366db5
Added by Katja Luther about 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DefaultTermComparator.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2009 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
17 | 17 |
* Implements a {@link Comparator} for {@link DefinedTermBase} objects based on the term's label. |
18 | 18 |
* The compare algorithm compares a term's label. Example: If used on an unsorted list of terms, the |
19 | 19 |
* list will be alphabetically sorted by label afterwards. |
20 |
*
|
|
20 |
* |
|
21 | 21 |
* @author n.hoffmann |
22 | 22 |
* @date Jan 18, 2012 |
23 | 23 |
* |
... | ... | |
36 | 36 |
} |
37 | 37 |
String label1 = o1.getLabel(CdmStore.getDefaultLanguage()) != null ? o1.getLabel(CdmStore.getDefaultLanguage()) : o1.getTitleCache(); |
38 | 38 |
String label2 = o2.getLabel(CdmStore.getDefaultLanguage()) != null ? o2.getLabel(CdmStore.getDefaultLanguage()) : o2.getTitleCache(); |
39 |
return label1.compareTo(label2); |
|
39 |
int result = label1.compareTo(label2); |
|
40 |
if (result == 0){ |
|
41 |
return o1.getUuid().compareTo(o2.getUuid()); |
|
42 |
} |
|
43 |
return result; |
|
40 | 44 |
} |
41 | 45 |
}; |
Also available in: Unified diff
ref #4232: some more comparators to adapt