1 16 17 package org.springframework.util.comparator; 18 19 import java.util.Comparator ; 20 21 import org.springframework.util.Assert; 22 23 32 public class ComparableComparator implements Comparator { 33 34 public int compare(Object o1, Object o2) { 35 Assert.isTrue(o1 instanceof Comparable , "The first object provided is not Comparable"); 36 Assert.isTrue(o2 instanceof Comparable , "The second object provided is not Comparable"); 37 return ((Comparable ) o1).compareTo(o2); 38 } 39 40 } 41 | Popular Tags |