Project

General

Profile

Download (1.19 KB) Statistics
| Branch: | Tag: | Revision:
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.User;
14

    
15
/**
16
 * @author k.luther
17
 * @since 02.07.2018
18
 *
19
 */
20
public class UserNameComparator implements Comparator<User> {
21
    private boolean fIgnoreCase;
22
    /**
23
     * {@inheritDoc}
24
     */
25
    @Override
26
    public int compare(User user0, User user1) {
27
        String userName0 = user0.getUsername();
28
        String userName1 = user1.getUsername();
29
        if (userName0 == null && userName1 == null) {
30
            return 0;
31
        }
32
        if (userName0 == null) {
33
            return -1;
34
        }
35
        if (userName1 == null) {
36
            return 1;
37
        }
38
        int result =  fIgnoreCase ? userName0.compareToIgnoreCase(userName1) :
39
            userName0.compareTo(userName1);
40

    
41
        if (result == 0){
42
            result = user0.getUuid().compareTo(user1.getUuid());
43
        }
44
        return result;
45

    
46
    }
47

    
48
}
(8-8/8)