public static void onDatabase(MongoClient client,String dbName,Consumer<MongoDatabase> dbOperation){
  if (contains(client.listDatabaseNames(),dbName)) {
    dbOperation.accept(client.getDatabase(dbName));
  }
}

public static void onDatabase ( MongoClient client , String dbName , Consumer < MongoDatabase > dbOperation ) { if ( contains ( client . listDatabaseNames ( ) , dbName ) ) { dbOperation . accept ( client . getDatabase ( dbName ) ) ; } }
perform the given operation on the database with the given name , only if that database exists .
