001
014
015 package com.liferay.portal.kernel.workflow.comparator;
016
017 import com.liferay.portal.kernel.util.OrderByComparator;
018 import com.liferay.portal.kernel.workflow.WorkflowLog;
019
020
023 public class WorkflowLogUserIdComparator extends OrderByComparator {
024
025 public WorkflowLogUserIdComparator(
026 boolean ascending, String orderByAsc, String orderByDesc,
027 String[] orderByFields) {
028
029 _ascending = ascending;
030 _orderByAsc = orderByAsc;
031 _orderByDesc = orderByDesc;
032 _orderByFields = orderByFields;
033 }
034
035 @Override
036 public int compare(Object obj1, Object obj2) {
037 WorkflowLog workflowLog1 = (WorkflowLog)obj1;
038 WorkflowLog workflowLog2 = (WorkflowLog)obj2;
039
040 Long userId1 = workflowLog1.getUserId();
041 Long userId2 = workflowLog2.getUserId();
042
043 int value = userId1.compareTo(userId2);
044
045 if (value == 0) {
046 Long workflowLogId1 = workflowLog1.getWorkflowLogId();
047 Long workflowLogId2 = workflowLog2.getWorkflowLogId();
048
049 value = workflowLogId1.compareTo(workflowLogId2);
050 }
051
052 if (_ascending) {
053 return value;
054 }
055 else {
056 return -value;
057 }
058 }
059
060 @Override
061 public String getOrderBy() {
062 if (isAscending()) {
063 return _orderByAsc;
064 }
065 else {
066 return _orderByDesc;
067 }
068 }
069
070 @Override
071 public String[] getOrderByFields() {
072 return _orderByFields;
073 }
074
075 @Override
076 public boolean isAscending() {
077 return _ascending;
078 }
079
080 private boolean _ascending;
081 private String _orderByAsc;
082 private String _orderByDesc;
083 private String[] _orderByFields;
084
085 }