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 import java.util.Date;
021
022
025 public abstract class BaseWorkflowLogCreateDateComparator
026 extends OrderByComparator {
027
028 public BaseWorkflowLogCreateDateComparator() {
029 this(false);
030 }
031
032 public BaseWorkflowLogCreateDateComparator(boolean ascending) {
033 _ascending = ascending;
034 }
035
036 @Override
037 public int compare(Object obj1, Object obj2) {
038 WorkflowLog workflowLog1 = (WorkflowLog)obj1;
039 WorkflowLog workflowLog2 = (WorkflowLog)obj2;
040
041 Date createDate1 = workflowLog1.getCreateDate();
042 Date createDate2 = workflowLog2.getCreateDate();
043
044 int value = createDate1.compareTo(createDate2);
045
046 if (value != 0) {
047 Long workflowLogId1 = workflowLog1.getWorkflowLogId();
048 Long workflowLogId2 = workflowLog2.getWorkflowLogId();
049
050 value = workflowLogId1.compareTo(workflowLogId2);
051 }
052
053 if (_ascending) {
054 return value;
055 }
056 else {
057 return -value;
058 }
059 }
060
061 @Override
062 public boolean isAscending() {
063 return _ascending;
064 }
065
066 private boolean _ascending;
067
068 }