static void validateCollation(final AsyncConnection connection, final Collation collation, final AsyncCallableWithConnection callable) { Throwable throwable = null; if (!ServerVersionHelper.serverIsAtLeastVersionThreeDotFour(connection.getDescription()) && collation != null) { throwable = new IllegalArgumentException(format("Collation not supported by server version: %s", connection.getDescription().getServerVersion())); } callable.call(connection, throwable); }
static void validateReadConcern(final AsyncConnection connection, final ReadConcern readConcern, final AsyncCallableWithConnection callable) { Throwable throwable = null; if (!ServerVersionHelper.serverIsAtLeastVersionThreeDotTwo(connection.getDescription()) && !readConcern.isServerDefault()) { throwable = new IllegalArgumentException(format("ReadConcern not supported by server version: %s", connection.getDescription().getServerVersion())); } callable.call(connection, throwable); }
static void validateCollation(final AsyncConnection connection, final Collation collation, final AsyncCallableWithConnection callable) { Throwable throwable = null; if (!ServerVersionHelper.serverIsAtLeastVersionThreeDotFour(connection.getDescription()) && collation != null) { throwable = new IllegalArgumentException(format("Collation not supported by server version: %s", connection.getDescription().getServerVersion())); } callable.call(connection, throwable); }
static void validateIndexRequestCollations(final AsyncConnection connection, final List<IndexRequest> requests, final AsyncCallableWithConnection callable) { boolean calledTheCallable = false; for (IndexRequest request : requests) { if (request.getCollation() != null) { calledTheCallable = true; validateCollation(connection, request.getCollation(), new AsyncCallableWithConnection() { @Override public void call(final AsyncConnection connection, final Throwable t) { callable.call(connection, t); } }); break; } } if (!calledTheCallable) { callable.call(connection, null); } }
static void validateWriteRequests(final AsyncConnection connection, final Boolean bypassDocumentValidation, final List<? extends WriteRequest> requests, final WriteConcern writeConcern, final AsyncCallableWithConnection callable) { try { validateWriteRequests(connection.getDescription(), bypassDocumentValidation, requests, writeConcern); callable.call(connection, null); } catch (Throwable t) { callable.call(connection, t); } } static void validateIndexRequestCollations(final Connection connection, final List<IndexRequest> requests) {
static void validateReadConcern(final AsyncConnection connection, final ReadConcern readConcern, final AsyncCallableWithConnection callable) { Throwable throwable = null; if (!ServerVersionHelper.serverIsAtLeastVersionThreeDotTwo(connection.getDescription()) && !readConcern.isServerDefault()) { throwable = new IllegalArgumentException(format("ReadConcern not supported by server version: %s", connection.getDescription().getServerVersion())); } callable.call(connection, throwable); }
@Override public void onResult(final AsyncConnectionSource source, final Throwable t) { if (t != null) { callable.call(null, t); } else { withConnectionSource(source, callable); } } }
@Override public void call(final AsyncConnection connection, final Throwable t) { callable.call(connection, t); } });
@Override public void call(final AsyncConnection connection, final Throwable t) { if (t != null) { callable.call(connection, t); } else { validateCollation(connection, collation, callable); } } });
static void validateIndexRequestCollations(final AsyncConnection connection, final List<IndexRequest> requests, final AsyncCallableWithConnection callable) { boolean calledTheCallable = false; for (IndexRequest request : requests) { if (request.getCollation() != null) { calledTheCallable = true; validateCollation(connection, request.getCollation(), new AsyncCallableWithConnection() { @Override public void call(final AsyncConnection connection, final Throwable t) { callable.call(connection, t); } }); break; } } if (!calledTheCallable) { callable.call(connection, null); } }
@Override public void onResult(final AsyncConnectionSource source, final Throwable t) { if (t != null) { callable.call(null, t); } else { withConnectionSource(source, callable); } } }
static void validateWriteRequests(final AsyncConnection connection, final Boolean bypassDocumentValidation, final List<? extends WriteRequest> requests, final WriteConcern writeConcern, final AsyncCallableWithConnection callable) { try { validateWriteRequests(connection.getDescription(), bypassDocumentValidation, requests, writeConcern); callable.call(connection, null); } catch (Throwable t) { callable.call(connection, t); } } static void validateIndexRequestCollations(final Connection connection, final List<IndexRequest> requests) {
@Override public void call(final AsyncConnection connection, final Throwable t) { if (t != null) { callable.call(connection, t); } else { validateCollation(connection, collation, callable); } } });
@Override public void call(final AsyncConnection connection, final Throwable t) { callable.call(connection, t); } });