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.model.common;
|
10
|
|
11
|
import java.util.Comparator;
|
12
|
|
13
|
/**
|
14
|
* @author k.luther
|
15
|
* @since 07.12.2018
|
16
|
*
|
17
|
*/
|
18
|
public class OrderIndexComparator implements Comparator<Integer> {
|
19
|
|
20
|
private static OrderIndexComparator instance;
|
21
|
|
22
|
|
23
|
|
24
|
public static OrderIndexComparator instance(){
|
25
|
if(instance == null){
|
26
|
instance = new OrderIndexComparator();
|
27
|
}
|
28
|
return instance;
|
29
|
}
|
30
|
|
31
|
/**
|
32
|
* {@inheritDoc}
|
33
|
*/
|
34
|
@Override
|
35
|
public int compare(Integer orderIndex1, Integer orderIndex2) {
|
36
|
if (orderIndex1 == orderIndex2){
|
37
|
return 0;
|
38
|
}
|
39
|
if (orderIndex1 == null){
|
40
|
return 1;
|
41
|
}
|
42
|
if (orderIndex2 == null){
|
43
|
return -1;
|
44
|
}
|
45
|
if (orderIndex1<orderIndex2){
|
46
|
return -1;
|
47
|
}else{
|
48
|
return 1;
|
49
|
}
|
50
|
|
51
|
}
|
52
|
|
53
|
}
|