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.bulkeditor.input.sortprovider;
|
10
|
|
11
|
import java.util.Comparator;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.common.Group;
|
14
|
|
15
|
/**
|
16
|
* @author k.luther
|
17
|
* @since 02.07.2018
|
18
|
*
|
19
|
*/
|
20
|
public class GroupNameComparator implements Comparator<Group> {
|
21
|
private boolean fIgnoreCase;
|
22
|
/**
|
23
|
* {@inheritDoc}
|
24
|
*/
|
25
|
@Override
|
26
|
public int compare(Group o1, Group o2) {
|
27
|
String groupName0 = o1.getName();
|
28
|
String groupName1 = o2.getName();
|
29
|
if (groupName0 == null && groupName1 == null) {
|
30
|
return 0;
|
31
|
}
|
32
|
if (groupName0 == null) {
|
33
|
return -1;
|
34
|
}
|
35
|
if (groupName1 == null) {
|
36
|
return 1;
|
37
|
}
|
38
|
int result = fIgnoreCase ? groupName0.compareToIgnoreCase(groupName1) :
|
39
|
groupName0.compareTo(groupName1);
|
40
|
|
41
|
if (result == 0){
|
42
|
result = o1.getUuid().compareTo(o2.getUuid());
|
43
|
}
|
44
|
return result;
|
45
|
}
|
46
|
|
47
|
}
|