001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.gl.businessobject.options; 017 018 import java.util.Comparator; 019 020 import org.kuali.kfs.gl.businessobject.OriginEntryGroup; 021 022 /** 023 * A comparator for two origin entry groups, based on the dates of their creations 024 */ 025 public class OEGDateComparator implements Comparator { 026 027 /** 028 * Constructs a OEGDateComparator 029 */ 030 public OEGDateComparator() { 031 } 032 033 /** 034 * Compares two origin entry groups, based on the dates of their creation 035 * 036 * @param c1 the first origin entry group to compare 037 * @param c2 you can't really compare without two origin groups 038 * @return 0 if the creation dates are equal, a negative number if c1's creation date is less 039 * than c2's; a positive number otherwise 040 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) 041 */ 042 public int compare(Object c1, Object c2) { 043 044 OriginEntryGroup oeg1 = (OriginEntryGroup) c1; 045 OriginEntryGroup oeg2 = (OriginEntryGroup) c2; 046 047 return oeg2.getDate().compareTo(oeg1.getDate()); 048 } 049 050 }