public static int comp ( Integer v1 , String s1 , Integer v2 , String s2 ) { if ( v1 != null && v2 != null ) { return v1 . compareTo ( v2 ) ; } else if ( v1 != null ) { return 1 ; } else if ( v2 != null ) { return - 1 ; } else if ( null == s1 && null == s2 ) { return 0 ; } else if ( null == s1 ) { return - 1 ; } else if ( null == s2 ) { return 1 ; } else { //compare lexicographically return s1 . compareTo ( s2 ) ; } }
Compares two version strings and their parsed integer values if available . Returns - 1 0 or 1 if value 1 is less than equal to or greater than value 2 respectively . Compares integers if both are available otherwise compares non - integer as less than integer . if no integers are available comparse strings and treats null strings as less than non - null strings .