//# 0 errors, 48 messages
//#
/*
    //#TagStatCountComparator.java:1:1: class: org.apache.roller.weblogger.pojos.TagStatCountComparator
 * 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 TagStatCountComparator implements Comparator, Serializable {

    private static final long serialVersionUID = 1155112837815739929L;

    private static TagStatCountComparator instance = new TagStatCountComparator();
    //#TagStatCountComparator.java:31: method: org.apache.roller.weblogger.pojos.TagStatCountComparator.org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init
    //#output(org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init): __Descendant_Table[org/apache/roller/weblogger/pojos/TagStatCountComparator]
    //#output(org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init): __Dispatch_Table.compare(Ljava/lang/Object;Ljava/lang/Object;)I
    //#output(org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init): instance
    //#output(org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init): new TagStatCountComparator(TagStatCountComparator__static_init#1) num objects
    //#output(org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init): instance.__Tag
    //#new obj(org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init): new TagStatCountComparator(TagStatCountComparator__static_init#1)
    //#post(org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init): __Descendant_Table[org/apache/roller/weblogger/pojos/TagStatCountComparator] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init): __Dispatch_Table.compare(Ljava/lang/Object;Ljava/lang/Object;)I == &compare
    //#post(org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init): instance == &new TagStatCountComparator(TagStatCountComparator__static_init#1)
    //#post(org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init): new TagStatCountComparator(TagStatCountComparator__static_init#1) num objects == 1
    //#post(org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init): instance.__Tag == org/apache/roller/weblogger/pojos/TagStatCountComparator
    //#TagStatCountComparator.java:31: end of method: org.apache.roller.weblogger.pojos.TagStatCountComparator.org.apache.roller.weblogger.pojos.TagStatCountComparator__static_init
    
    /**
     * 
     */
    public TagStatCountComparator() {
    //#TagStatCountComparator.java:36: method: void org.apache.roller.weblogger.pojos.TagStatCountComparator.org.apache.roller.weblogger.pojos.TagStatCountComparator()

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

    /** 
     * Compares two <em>TagStat</em> instances according to their count values.
     * 
     * @throws ClassCastException if arguments are not instances of <em>TagStat</em>
     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
     */
    public int compare(Object obj1, Object obj2) throws ClassCastException {
        TagStat st1 = (TagStat) obj1;
    //#TagStatCountComparator.java:47: method: int org.apache.roller.weblogger.pojos.TagStatCountComparator.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.name
    //#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.name
    //#input(int compare(Object, Object)): org/apache/roller/weblogger/pojos/TagStat.__Descendant_Table[org/apache/roller/weblogger/pojos/TagStat]
    //#input(int compare(Object, Object)): org/apache/roller/weblogger/pojos/TagStat.__Descendant_Table[others]
    //#input(int compare(Object, Object)): org/apache/roller/weblogger/pojos/TagStat.__Dispatch_Table.getCount()I
    //#input(int compare(Object, Object)): org/apache/roller/weblogger/pojos/TagStat.__Dispatch_Table.getName()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/TagStat
    //#pre[3] (int compare(Object, Object)): init'ed(obj1.count)
    //#pre[5] (int compare(Object, Object)): obj2 != null
    //#pre[6] (int compare(Object, Object)): obj2.__Tag == org/apache/roller/weblogger/pojos/TagStat
    //#pre[7] (int compare(Object, Object)): init'ed(obj2.count)
    //#pre[4] (int compare(Object, Object)): (soft) obj1.name != null
    //#pre[9] (int compare(Object, Object)): (soft) init'ed(obj2.name)
    //#post(int compare(Object, Object)): init'ed(return_value)
        TagStat st2 = (TagStat) obj2;
        int compVal = st1.getCount() < st2.getCount() ? -1 :
                (st1.getCount() == st2.getCount() ? 0 : 1);
        
        if (compVal == 0) {
            compVal = st1.getName().compareTo(st2.getName());
        }
        return compVal;
    //#TagStatCountComparator.java:55: end of method: int org.apache.roller.weblogger.pojos.TagStatCountComparator.compare(Object, Object)
    }

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