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