1
14
15 package com.liferay.portal.util.comparator;
16
17 import com.liferay.portal.kernel.util.OrderByComparator;
18 import com.liferay.portal.model.UserGroup;
19
20
25 public class UserGroupNameComparator extends OrderByComparator {
26
27 public static String ORDER_BY_ASC = "UserGroup.name ASC";
28
29 public static String ORDER_BY_DESC = "UserGroup.name DESC";
30
31 public static String[] ORDER_BY_FIELDS = {"name"};
32
33 public UserGroupNameComparator() {
34 this(false);
35 }
36
37 public UserGroupNameComparator(boolean asc) {
38 _asc = asc;
39 }
40
41 public int compare(Object obj1, Object obj2) {
42 UserGroup userGroup1 = (UserGroup)obj1;
43 UserGroup userGroup2 = (UserGroup)obj2;
44
45 int value = userGroup1.getName().compareTo(userGroup2.getName());
46
47 if (_asc) {
48 return value;
49 }
50 else {
51 return -value;
52 }
53 }
54
55 public String getOrderBy() {
56 if (_asc) {
57 return ORDER_BY_ASC;
58 }
59 else {
60 return ORDER_BY_DESC;
61 }
62 }
63
64 public String[] getOrderByFields() {
65 return ORDER_BY_FIELDS;
66 }
67
68 public boolean isAscending() {
69 return _asc;
70 }
71
72 private boolean _asc;
73
74 }