1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.api.util;
17
18
19 import org.apache.commons.lang.ObjectUtils;
20 import org.apache.commons.lang.StringUtils;
21
22 public class KpmeUtils {
23 public static String formatAssignmentKey(String groupKeyCode, Long jobNumber, Long workArea, Long task) {
24 String assignmentKey = StringUtils.EMPTY;
25
26 String jobNumberString = ObjectUtils.toString(jobNumber, "0");
27 String workAreaString = ObjectUtils.toString(workArea, "0");
28 String taskString = ObjectUtils.toString(task, "0");
29
30 if (!jobNumberString.equals("0") || !workAreaString.equals("0") || !taskString.equals("0")) {
31 assignmentKey = StringUtils.join(new String[] {groupKeyCode, jobNumberString, workAreaString, taskString}, HrApiConstants.ASSIGNMENT_KEY_DELIMITER);
32 }
33
34 return assignmentKey;
35 }
36
37 public static <T extends Comparable<? super T>> int nullSafeCompare(T s1, T s2) {
38 if(s1 == null && s2 != null) { return -1;}
39 if(s1 != null && s2 == null) { return 1;}
40 if(s1 == null) { return 0;}
41 return s1.compareTo(s2);
42 }
43 }