// (c) MIT 2003.  All rights reserved.

// -*-Mode: Java-*- 
// WidgetStrengthComparator.java -- 
// Author: Christine Alvarado <calvarad@ai.mit.edu> 
// Maintainer: Christine Alvarado <calvarad@ai.mit.edu> 
// Version: 
// Created: <Sun Mar 12 16:00:40 2000> 
// Time-stamp: <2000-03-12 17:12:59 calvarad> 
// Keywords: 

package rec.util;

import rec.sys.*;

/** Orders from greatest to least strength **/
public class WidgetStrengthComparator implements java.util.Comparator
{
  public WidgetStrengthComparator()
  {
  }
  
  public int compare( Object o1, Object o2 )
  {
    Assert.check( (o1 instanceof Widget) && (o2 instanceof Widget) );
    int t1 = ((Widget)o1).getStrength();
    int t2 = ((Widget)o2).getStrength();
    
    if ( o1.equals( o2 ) ) {
      return 0;
    }

    if ( t1 == t2 ) {
      return 0;
    }
    
    if ( t1 < t2 ) {
      return 1;
    }
    
    return -1;
    
  }
  
}
