Project

General

Profile

Download (1.03 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.cdm.compare;
10

    
11
import java.util.Comparator;
12

    
13
/**
14
 * @author k.luther
15
 * @since 07.12.2018
16
 */
17
public class OrderIndexComparator implements Comparator<Integer> {
18

    
19
    private static OrderIndexComparator instance;
20

    
21
    public static OrderIndexComparator instance(){
22
        if(instance == null){
23
            instance = new OrderIndexComparator();
24
        }
25
        return instance;
26
    }
27

    
28
    @Override
29
    public int compare(Integer orderIndex1, Integer orderIndex2) {
30
       if (orderIndex1 == orderIndex2){
31
           return 0;
32
       }
33
       if (orderIndex1 == null){
34
           return 1;
35
       }
36
       if (orderIndex2 == null){
37
           return -1;
38
       }
39
       if (orderIndex1<orderIndex2){
40
           return -1;
41
       }else{
42
           return 1;
43
       }
44
    }
45
}
(2-2/3)