protected boolean collectionsEqual ( Collection a1 , Collection a2 ) { if ( a1 != null && a2 != null && a1 . size ( ) == a2 . size ( ) ) { // Loop over each element and compare them using our comparator Iterator iterA1 = a1 . iterator ( ) ; Iterator iterA2 = a2 . iterator ( ) ; while ( iterA1 . hasNext ( ) ) { if ( ! equalByComparator ( iterA1 . next ( ) , iterA2 . next ( ) ) ) { return false ; } } } else if ( a1 == null && a2 == null ) { return true ; } return false ; }
Compare two collections for equality using the configured comparator . Element order must be the same for the collections to compare equal .