public class MyComparableUtil { /** * Returns the larger among the two objects. If objects are equal returns null. */ public static MyComparable findLarger(MyComparable object1, MyComparable object2) throws InvalidComparableTypeException { if(object1.isLarger(object2)) return object1; else if( object1.isEqual(object2) ) return null; return object2; } /** * Returns the smaller among the two objects. If objects are equal returns null. */ public static MyComparable findSmaller(MyComparable object1, MyComparable object2) throws InvalidComparableTypeException { if(!object1.isLarger(object2)) return object1; else if( object1.isEqual(object2) ) return null; return object2; } }