01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.gl.web.optionfinder;
17:
18: import java.util.Comparator;
19:
20: import org.kuali.module.gl.bo.OriginEntryGroup;
21:
22: /**
23: * An implementation of Comparator which compares origin entry groups by their source attribute
24: */
25: public class OEGTypeComparator implements Comparator {
26: /**
27: * Constructs a OEGTypeComparator instance
28: */
29: public OEGTypeComparator() {
30: }
31:
32: /**
33: * Compares origin entry groups based on the alphabeticality of their source attributes
34: *
35: * @param c1 the first origin entry group to compare
36: * @param c2 the origin entry group compared to
37: * @return a negative if c1's source is less than c2's, 0 if they are equal, a positive if c1's source is greater than c2's
38: * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
39: */
40: public int compare(Object c1, Object c2) {
41:
42: OriginEntryGroup oeg1 = (OriginEntryGroup) c1;
43: OriginEntryGroup oeg2 = (OriginEntryGroup) c2;
44:
45: String sort1 = oeg1.getSourceCode();
46: String sort2 = oeg2.getSourceCode();
47:
48: int c = sort1.compareTo(sort2);
49: if (c != 0) {
50: return c;
51: }
52: return oeg1.getId().compareTo(oeg2.getId());
53: }
54: }
|