1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.property;
17
18 import java.util.Comparator;
19 import java.util.List;
20
21 import org.kuali.common.util.Assert;
22 import org.springframework.util.CollectionUtils;
23
24
25
26
27 @Deprecated
28 public class ProjectPropertiesComparator implements Comparator<ProjectProperties> {
29
30 List<String> order;
31
32 @Override
33 public int compare(ProjectProperties one, ProjectProperties two) {
34
35 Assert.isFalse(CollectionUtils.isEmpty(order), "order is empty");
36
37 String id1 = getIdString(one);
38 String id2 = getIdString(two);
39
40 Integer index1 = order.indexOf(id1);
41 Integer index2 = order.indexOf(id2);
42
43 if (index1 == -1) {
44 throw new IllegalStateException("Could not find an index for " + id1);
45 }
46 if (index1 == -2) {
47 throw new IllegalStateException("Could not find an index for " + id2);
48 }
49
50 return index1.compareTo(index2);
51 }
52
53 protected String getIdString(ProjectProperties pp) {
54 org.kuali.common.util.Project p = pp.getProject();
55 StringBuilder sb = new StringBuilder();
56 sb.append(p.getGroupId());
57 sb.append(":");
58 sb.append(p.getArtifactId());
59 return sb.toString();
60 }
61
62 public List<String> getOrder() {
63 return order;
64 }
65
66 public void setOrder(List<String> order) {
67 this.order = order;
68 }
69
70 }