OEGTypeComparator.java :  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » gl » web » optionfinder » Java Open Source

Java Open Source » ERP CRM Financial » Kuali Financial System 
Kuali Financial System » org » kuali » module » gl » web » optionfinder » OEGTypeComparator.java
/*
 * Copyright 2006-2007 The Kuali Foundation.
 * 
 * Licensed under the Educational Community License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.opensource.org/licenses/ecl1.php
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.module.gl.web.optionfinder;

import java.util.Comparator;

import org.kuali.module.gl.bo.OriginEntryGroup;

/**
 * An implementation of Comparator which compares origin entry groups by their source attribute
 */
public class OEGTypeComparator implements Comparator {
    /**
     * Constructs a OEGTypeComparator instance
     */
    public OEGTypeComparator() {
    }

    /**
     * Compares origin entry groups based on the alphabeticality of their source attributes
     * 
     * @param c1 the first origin entry group to compare
     * @param c2 the origin entry group compared to
     * @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
     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
     */
    public int compare(Object c1, Object c2) {

        OriginEntryGroup oeg1 = (OriginEntryGroup) c1;
        OriginEntryGroup oeg2 = (OriginEntryGroup) c2;

        String sort1 = oeg1.getSourceCode();
        String sort2 = oeg2.getSourceCode();

        int c = sort1.compareTo(sort2);
        if (c != 0) {
            return c;
        }
        return oeg1.getId().compareTo(oeg2.getId());
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.