1 /*
2 * Copyright 2007 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
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.ole.gl.businessobject.options;
17
18 import java.util.Comparator;
19
20 import org.kuali.ole.gl.businessobject.OriginEntryGroup;
21
22 /**
23 * A comparator for two origin entry groups, based on the dates of their creations
24 */
25 public class OEGDateComparator implements Comparator {
26
27 /**
28 * Constructs a OEGDateComparator
29 */
30 public OEGDateComparator() {
31 }
32
33 /**
34 * Compares two origin entry groups, based on the dates of their creation
35 *
36 * @param c1 the first origin entry group to compare
37 * @param c2 you can't really compare without two origin groups
38 * @return 0 if the creation dates are equal, a negative number if c1's creation date is less
39 * than c2's; a positive number otherwise
40 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
41 */
42 public int compare(Object c1, Object c2) {
43
44 OriginEntryGroup oeg1 = (OriginEntryGroup) c1;
45 OriginEntryGroup oeg2 = (OriginEntryGroup) c2;
46
47 return oeg2.getDate().compareTo(oeg1.getDate());
48 }
49
50 }