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.kernel.workflow.comparator;
16  
17  import com.liferay.portal.kernel.util.OrderByComparator;
18  import com.liferay.portal.kernel.workflow.WorkflowLog;
19  
20  /**
21   * <a href="BaseWorkflowLogUserIdComparator.java.html"><b><i>View Source</i></b>
22   * </a>
23   *
24   * @author Michael C. Han
25   */
26  public abstract class BaseWorkflowLogUserIdComparator
27      extends OrderByComparator {
28  
29      public BaseWorkflowLogUserIdComparator() {
30          this(false);
31      }
32  
33      public BaseWorkflowLogUserIdComparator(boolean ascending) {
34          _ascending = ascending;
35      }
36  
37      public int compare(Object obj1, Object obj2) {
38          WorkflowLog workflowLog1 = (WorkflowLog)obj1;
39          WorkflowLog workflowLog2 = (WorkflowLog)obj2;
40  
41          Long userId1 = workflowLog1.getUserId();
42          Long userId2 = workflowLog2.getUserId();
43  
44          int value = userId1.compareTo(userId2);
45  
46          if (value == 0) {
47              Long workflowLogId1 = workflowLog1.getWorkflowLogId();
48              Long workflowLogId2 = workflowLog2.getWorkflowLogId();
49  
50              value = workflowLogId1.compareTo(workflowLogId2);
51          }
52  
53          if (_ascending) {
54              return value;
55          }
56          else {
57              return -value;
58          }
59      }
60  
61      public boolean isAscending() {
62          return _ascending;
63      }
64  
65      private boolean _ascending;
66  
67  }