1 package org.andromda.timetracker.vo;
2
3 import java.util.Comparator;
4
5
6
7
8 public class UserVOComparator implements Comparator<UserVO>
9 {
10
11
12
13
14
15
16
17
18
19 @Override
20 public int compare(UserVO o1, UserVO o2) {
21 int result = 0;
22
23 if (o1 == null) {
24 result = (o2 == null) ? 0 : -1;
25 }
26 else if (o2 == null) {
27 result = 1;
28 }
29 else if ((o1.getUsername() != null) && (o2.getUsername() != null)) {
30
31 result = o1.getUsername().compareTo(o2.getUsername());
32 }
33 else if ((o1.getId() != null) && (o2.getId() != null)) {
34
35 result = o1.getId().compareTo(o2.getId());
36 }
37
38 return result;
39 }
40 }