| UserTrackerModifiedDateComparator.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
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 }