| UserTrackerModifiedDateComparator.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * The contents of this file are subject to the terms of the Liferay Enterprise
5 * Subscription License ("License"). You may not use this file except in
6 * compliance with the License. You can obtain a copy of the License by
7 * contacting Liferay, Inc. See the License for the specific language governing
8 * permissions and limitations under the License, including but not limited to
9 * distribution rights of the Software.
10 *
11 *
12 *
13 */
14
15 package com.liferay.portal.util.comparator;
16
17 import com.liferay.portal.kernel.util.DateUtil;
18 import com.liferay.portal.model.UserTracker;
19
20 import java.io.Serializable;
21
22 import java.util.Comparator;
23
24 /**
25 * <a href="UserTrackerModifiedDateComparator.java.html"><b><i>View Source</i>
26 * </b></a>
27 *
28 * @author Brian Wing Shun Chan
29 */
30 public class UserTrackerModifiedDateComparator
31 implements Comparator<UserTracker>, Serializable {
32
33 public UserTrackerModifiedDateComparator() {
34 this(false);
35 }
36
37 public UserTrackerModifiedDateComparator(boolean asc) {
38 _asc = asc;
39 }
40
41 public int compare(UserTracker userTracker1, UserTracker userTracker2) {
42 int value = DateUtil.compareTo(
43 userTracker1.getModifiedDate(), userTracker2.getModifiedDate());
44
45 if (_asc) {
46 return value;
47 }
48 else {
49 return -value;
50 }
51 }
52
53 private boolean _asc;
54
55 }