//# 0 errors, 54 messages
//#
/*
    //#StatCountCountComparator.java:1:1: class: org.apache.roller.weblogger.pojos.StatCountCountComparator
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
 *
 * 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.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.pojos;

import java.util.Comparator;
import java.io.Serializable;

/**
 * @author Markus Fuchs
 */
public class StatCountCountComparator implements Comparator, Serializable {

    private static final long serialVersionUID = 4811314286365625712L;
    
    private static StatCountCountComparator instance = new StatCountCountComparator();
    //#StatCountCountComparator.java:31: method: org.apache.roller.weblogger.pojos.StatCountCountComparator.org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init
    //#output(org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init): __Descendant_Table[org/apache/roller/weblogger/pojos/StatCountCountComparator]
    //#output(org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init): __Dispatch_Table.compare(Ljava/lang/Object;Ljava/lang/Object;)I
    //#output(org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init): instance
    //#output(org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init): new StatCountCountComparator(StatCountCountComparator__static_init#1) num objects
    //#output(org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init): instance.__Tag
    //#new obj(org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init): new StatCountCountComparator(StatCountCountComparator__static_init#1)
    //#post(org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init): __Descendant_Table[org/apache/roller/weblogger/pojos/StatCountCountComparator] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init): __Dispatch_Table.compare(Ljava/lang/Object;Ljava/lang/Object;)I == &compare
    //#post(org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init): instance == &new StatCountCountComparator(StatCountCountComparator__static_init#1)
    //#post(org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init): new StatCountCountComparator(StatCountCountComparator__static_init#1) num objects == 1
    //#post(org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init): instance.__Tag == org/apache/roller/weblogger/pojos/StatCountCountComparator
    //#StatCountCountComparator.java:31: end of method: org.apache.roller.weblogger.pojos.StatCountCountComparator.org.apache.roller.weblogger.pojos.StatCountCountComparator__static_init

    /**
     * 
     */
    private StatCountCountComparator() {
    //#StatCountCountComparator.java:36: method: void org.apache.roller.weblogger.pojos.StatCountCountComparator.org.apache.roller.weblogger.pojos.StatCountCountComparator()

    }
    //#StatCountCountComparator.java:38: end of method: void org.apache.roller.weblogger.pojos.StatCountCountComparator.org.apache.roller.weblogger.pojos.StatCountCountComparator()

    /** 
     * Compares two <em>StatCount</em> instances according to their count values.
     * 
     * @throws ClassCastException if arguments are not instances of <em>StatCount</em>
     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
     */
    public int compare(Object obj1, Object obj2) throws ClassCastException {
        StatCount sc1 = (StatCount) obj1;
    //#StatCountCountComparator.java:47: method: int org.apache.roller.weblogger.pojos.StatCountCountComparator.compare(Object, Object)
    //#input(int compare(Object, Object)): obj1
    //#input(int compare(Object, Object)): obj1.__Tag
    //#input(int compare(Object, Object)): obj1.count
    //#input(int compare(Object, Object)): obj1.subjectId
    //#input(int compare(Object, Object)): obj1.typeKey
    //#input(int compare(Object, Object)): obj2
    //#input(int compare(Object, Object)): obj2.__Tag
    //#input(int compare(Object, Object)): obj2.count
    //#input(int compare(Object, Object)): obj2.subjectId
    //#input(int compare(Object, Object)): obj2.typeKey
    //#input(int compare(Object, Object)): org/apache/roller/weblogger/pojos/StatCount.__Descendant_Table[org/apache/roller/weblogger/pojos/StatCount]
    //#input(int compare(Object, Object)): org/apache/roller/weblogger/pojos/StatCount.__Descendant_Table[others]
    //#input(int compare(Object, Object)): org/apache/roller/weblogger/pojos/StatCount.__Dispatch_Table.getCount()J
    //#input(int compare(Object, Object)): org/apache/roller/weblogger/pojos/StatCount.__Dispatch_Table.getSubjectId()Ljava/lang/String;
    //#input(int compare(Object, Object)): org/apache/roller/weblogger/pojos/StatCount.__Dispatch_Table.getTypeKey()Ljava/lang/String;
    //#output(int compare(Object, Object)): return_value
    //#pre[1] (int compare(Object, Object)): obj1 != null
    //#pre[2] (int compare(Object, Object)): obj1.__Tag == org/apache/roller/weblogger/pojos/StatCount
    //#pre[3] (int compare(Object, Object)): init'ed(obj1.count)
    //#pre[6] (int compare(Object, Object)): obj2 != null
    //#pre[7] (int compare(Object, Object)): obj2.__Tag == org/apache/roller/weblogger/pojos/StatCount
    //#pre[8] (int compare(Object, Object)): init'ed(obj2.count)
    //#pre[4] (int compare(Object, Object)): (soft) obj1.subjectId != null
    //#pre[5] (int compare(Object, Object)): (soft) obj1.typeKey != null
    //#pre[10] (int compare(Object, Object)): (soft) init'ed(obj2.subjectId)
    //#pre[11] (int compare(Object, Object)): (soft) init'ed(obj2.typeKey)
    //#post(int compare(Object, Object)): init'ed(return_value)
    //#test_vector(int compare(Object, Object)): java.lang.String:compareTo(...)@53: {-2_147_483_648..-1, 1..4_294_967_295}, {0}
        StatCount sc2 = (StatCount) obj2;
        int compVal = sc1.getCount() < sc2.getCount() ? -1 :
                (sc1.getCount() == sc2.getCount() ? 0 : 1);
        
        if (compVal == 0) {
            compVal = sc1.getSubjectId().compareTo(sc2.getSubjectId());
            if (compVal == 0) {
                compVal = sc1.getTypeKey().compareTo(sc2.getTypeKey());   
            }
        }
        return compVal;
    //#StatCountCountComparator.java:58: end of method: int org.apache.roller.weblogger.pojos.StatCountCountComparator.compare(Object, Object)
    }

    public static StatCountCountComparator getInstance() {
        return instance;
    //#StatCountCountComparator.java:62: method: StatCountCountComparator org.apache.roller.weblogger.pojos.StatCountCountComparator.getInstance()
    //#input(StatCountCountComparator getInstance()): instance
    //#output(StatCountCountComparator getInstance()): return_value
    //#pre[1] (StatCountCountComparator getInstance()): init'ed(instance)
    //#post(StatCountCountComparator getInstance()): return_value == instance
    //#post(StatCountCountComparator getInstance()): init'ed(return_value)
    //#StatCountCountComparator.java:62: end of method: StatCountCountComparator org.apache.roller.weblogger.pojos.StatCountCountComparator.getInstance()
    }
}
    //#StatCountCountComparator.java:: end of class: org.apache.roller.weblogger.pojos.StatCountCountComparator
