public static <T>int compare(Comparable<T> object1,T object2){
  if ((null != object1) && (null != object2)) {
    return object1.compareTo(object2);
  }
 else   if (null != object1) {
    return 1;
  }
 else   if (null != object2) {
    return -1;
  }
 else {
    return 0;
  }
}

public static < T > int compare ( Comparable < T > object1 , T object2 ) { if ( ( null != object1 ) && ( null != object2 ) ) { return object1 . compareTo ( object2 ) ; } else if ( null != object1 ) { return 1 ; } else if ( null != object2 ) { return - 1 ; } else { return 0 ; } }
null safe compare . returns following results : objectutils . equals ( comparable , object ) = comparable . compareto ( object ) objectutils . equals ( null , object ) = - 1 objectutils . equals ( comparable , null ) = 1 objectutils . equals ( null , null ) = 0
