1 package org.incava.util; 2 3 import java.util.Comparator ; 4 5 6 9 public class ReverseComparator implements Comparator  10 { 11 14 public int compare(Object o1, Object o2) 15 { 16 if (o2 instanceof Comparable ) { 17 Comparable c2 = (Comparable )o2; 18 return c2.compareTo(o1); 19 } 20 else { 21 throw new IllegalArgumentException ("argument " + o2.getClass() + " does not implement Comparable"); 22 } 23 } 24 25 28 public boolean equals(Object o1, Object o2) 29 { 30 return o1.equals(o2); 31 } 32 } 33 | Popular Tags |