public static < T extends Comparable < T > > int compare ( Collection < T > collection1 , Collection < T > collection2 , ComparisonStyle style ) { if ( style != ComparisonStyle . LEXICOGRAPHIC ) { int diff = collection1 . size ( ) - collection2 . size ( ) ; if ( diff != 0 ) { return ( diff < 0 ) == ( style == ComparisonStyle . SHORTER_FIRST ) ? - 1 : 1 ; } } return compare ( collection1 , collection2 ) ; }
Utility to compare two collections optionally by size and then lexicographically .