Revision df366db5
Added by Katja Luther about 7 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/TitleCacheComparator.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 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 |
*/ |
... | ... | |
21 | 21 |
* @version 1.0 |
22 | 22 |
*/ |
23 | 23 |
public class TitleCacheComparator<T extends IIdentifiableEntity> implements Comparator<T> { |
24 |
|
|
24 |
|
|
25 | 25 |
private boolean fIgnoreCase; |
26 | 26 |
|
27 | 27 |
private String getTitleCache(T o) { |
28 | 28 |
return o == null ? null : o.getTitleCache(); |
29 | 29 |
} |
30 |
|
|
30 |
|
|
31 | 31 |
/* (non-Javadoc) |
32 | 32 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
33 | 33 |
*/ |
34 | 34 |
/** {@inheritDoc} */ |
35 |
public int compare(T o1, T o2) { |
|
35 |
@Override |
|
36 |
public int compare(T o1, T o2) { |
|
36 | 37 |
String titleCache1 = getTitleCache(o1); |
37 | 38 |
String titleCache2 = getTitleCache(o2); |
38 | 39 |
if (titleCache1 == null && titleCache2 == null) { |
... | ... | |
43 | 44 |
} |
44 | 45 |
if (titleCache2 == null) { |
45 | 46 |
return 1; |
46 |
}
|
|
47 |
return fIgnoreCase ? titleCache1.compareToIgnoreCase(titleCache2) :
|
|
47 |
} |
|
48 |
int result = fIgnoreCase ? titleCache1.compareToIgnoreCase(titleCache2) :
|
|
48 | 49 |
titleCache1.compareTo(titleCache2); |
50 |
|
|
51 |
if (result == 0){ |
|
52 |
result = o1.getUuid().compareTo(o2.getUuid()); |
|
53 |
} |
|
54 |
return result; |
|
49 | 55 |
} |
50 | 56 |
} |
Also available in: Unified diff
ref #4232: some more comparators to adapt