public static boolean equals(Collection<?> actual,Object... reference){
  final Collection<Object> collection=new HashSet<>();
  Collections.addAll(collection,reference);
  if (actual == collection) {
    return true;
  }
  if (actual == null) {
    return false;
  }
  if (actual.size() != collection.size()) {
    log.warn("Actual collection has different size compared to reference collection: " + actual.size() + " / "+ collection.size());
    return false;
  }
  for (  Object object : actual) {
    if (!collection.contains(object)) {
      log.warn("Object in actual collection not part of reference collection: " + object);
      return false;
    }
  }
  for (  Object object : collection) {
    if (!actual.contains(object)) {
      log.warn("Object in reference collection not part of actual collection: " + object);
      return false;
    }
  }
  return true;
}

public static boolean equals ( Collection < ? > actual , Object ... reference ) { final Collection < Object > collection = new HashSet < > ( ) ; Collections . addAll ( collection , reference ) ; if ( actual == collection ) { return true ; } if ( actual == null ) { return false ; } if ( actual . size ( ) != collection . size ( ) ) { log . warn ( "Actual collection has different size compared to reference collection: " + actual . size ( ) + " / " + collection . size ( ) ) ; return false ; } for ( Object object : actual ) { if ( ! collection . contains ( object ) ) { log . warn ( "Object in actual collection not part of reference collection: " + object ) ; return false ; } } for ( Object object : collection ) { if ( ! actual . contains ( object ) ) { log . warn ( "Object in reference collection not part of actual collection: " + object ) ; return false ; } } return true ; }
compares two collections for equality . this method does not check for the implementation type of the collection in contrast to the native equals method . this is useful for black - box testing where one will not know the implementation type of the returned collection for a method .
