diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DatabaseClient.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DatabaseClient.java index 3f1f28d53b..072adb7a9f 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DatabaseClient.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DatabaseClient.java @@ -37,14 +37,14 @@ import org.springframework.r2dbc.core.binding.BindMarkersFactory; import org.springframework.util.Assert; /** - * A non-blocking, reactive client for performing database calls requests with + * A non-blocking, reactive client for performing database calls with * Reactive Streams back pressure. Provides a higher level, common API over * R2DBC client libraries. * - *

Use one of the static factory methods {@link #create(ConnectionFactory)} - * or obtain a {@link DatabaseClient#builder()} to create an instance. + *

Use the static factory method {@link #create(ConnectionFactory)} or obtain + * a {@linkplain DatabaseClient#builder() builder} to create an instance. * - * Usage example: + *

Usage example: *

  * ConnectionFactory factory = …
  *
@@ -52,8 +52,7 @@ import org.springframework.util.Assert;
  * Mono<Actor> actor = client.sql("select first_name, last_name from t_actor")
  *     .map(row -> new Actor(row.get("first_name", String.class),
  *          row.get("last_name", String.class)))
- *     .first();
- * 
+ * .first(); * * @author Mark Paluch * @since 5.3 @@ -61,13 +60,13 @@ import org.springframework.util.Assert; public interface DatabaseClient extends ConnectionAccessor { /** - * Return the {@link ConnectionFactory} that this client uses. + * Get the {@link ConnectionFactory} that this client uses. * @return the connection factory */ ConnectionFactory getConnectionFactory(); /** - * Specify a static {@code sql} statement to run. Contract for specifying a + * Specify a static {@code sql} statement to run. Contract for specifying an * SQL call along with options leading to the execution. The SQL string can * contain either native parameter bind markers or named parameters (e.g. * {@literal :foo, :bar}) when {@link NamedParameterExpander} is enabled. @@ -79,7 +78,7 @@ public interface DatabaseClient extends ConnectionAccessor { GenericExecuteSpec sql(String sql); /** - * Specify a {@link Supplier SQL supplier} that provides SQL to run. + * Specify an {@linkplain Supplier SQL supplier} that provides SQL to run. * Contract for specifying an SQL call along with options leading to * the execution. The SQL string can contain either native parameter * bind markers or named parameters (e.g. {@literal :foo, :bar}) when @@ -99,7 +98,7 @@ public interface DatabaseClient extends ConnectionAccessor { /** * Create a {@code DatabaseClient} that will use the provided {@link ConnectionFactory}. * @param factory the {@code ConnectionFactory} to use for obtaining connections - * @return a new {@code DatabaseClient}. Guaranteed to be not {@code null}. + * @return a new {@code DatabaseClient}; never {@code null} */ static DatabaseClient create(ConnectionFactory factory) { return new DefaultDatabaseClientBuilder().connectionFactory(factory).build(); @@ -129,14 +128,14 @@ public interface DatabaseClient extends ConnectionAccessor { Builder connectionFactory(ConnectionFactory factory); /** - * Configure a {@link ExecuteFunction} to execute {@link Statement} objects. + * Configure an {@link ExecuteFunction} to execute {@link Statement} objects. * @see Statement#execute() */ Builder executeFunction(ExecuteFunction executeFunction); /** * Configure whether to use named parameter expansion. - * Defaults to {@code true}. + *

Defaults to {@code true}. * @param enabled {@code true} to use named parameter expansion; * {@code false} to disable named parameter expansion * @see NamedParameterExpander @@ -144,7 +143,7 @@ public interface DatabaseClient extends ConnectionAccessor { Builder namedParameters(boolean enabled); /** - * Configures a {@link Consumer} to configure this builder. + * Apply a {@link Consumer} to configure this builder. */ Builder apply(Consumer builderConsumer); @@ -238,7 +237,7 @@ public interface DatabaseClient extends ConnectionAccessor { * Perform the SQL call and apply {@link BiFunction function} to the {@link Result}. * @param mappingFunction a function that maps from {@link Result} into a result publisher * @param the result type - * @return a {@link Flux} emitting mapped elements + * @return a {@link Flux} that emits mapped elements * @since 6.0 * @see Result#filter(Predicate) * @see Result#flatMap(Function) diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java index 1f1673ce64..4c4b03027b 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java @@ -200,16 +200,15 @@ class DefaultDatabaseClient implements DatabaseClient { } /** - * Determine SQL from potential provider object. - * @param sqlProvider object that's potentially a SqlProvider + * Get SQL from a potential provider object. + * @param object an object that is potentially an SqlProvider * @return the SQL string, or {@code null} * @see SqlProvider */ @Nullable - private static String getSql(Object sqlProvider) { - - if (sqlProvider instanceof SqlProvider) { - return ((SqlProvider) sqlProvider).getSql(); + private static String getSql(Object object) { + if (object instanceof SqlProvider sqlProvider) { + return sqlProvider.getSql(); } else { return null; @@ -218,7 +217,7 @@ class DefaultDatabaseClient implements DatabaseClient { /** - * Base class for {@link DatabaseClient.GenericExecuteSpec} implementations. + * Default {@link DatabaseClient.GenericExecuteSpec} implementation. */ class DefaultGenericExecuteSpec implements GenericExecuteSpec { @@ -352,10 +351,10 @@ class DefaultDatabaseClient implements DatabaseClient { if (logger.isDebugEnabled()) { logger.debug("Executing SQL statement [" + sql + "]"); } - if (sqlSupplier instanceof PreparedOperation) { + if (sqlSupplier instanceof PreparedOperation preparedOperation) { Statement statement = connection.createStatement(sql); BindTarget bindTarget = new StatementWrapper(statement); - ((PreparedOperation) sqlSupplier).bindTo(bindTarget); + preparedOperation.bindTo(bindTarget); return statement; } @@ -397,7 +396,7 @@ class DefaultDatabaseClient implements DatabaseClient { Function> resultFunction = connection -> { Statement statement = statementFunction.apply(connection); return Flux.from(this.filterFunction.filter(statement, DefaultDatabaseClient.this.executeFunction)) - .cast(Result.class).checkpoint("SQL \"" + sql + "\" [DatabaseClient]"); + .cast(Result.class).checkpoint("SQL \"" + sql + "\" [DatabaseClient]"); }; return new ResultFunction(resultFunction, sql); diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/PreparedOperation.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/PreparedOperation.java index 6164063f68..29361e78aa 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/PreparedOperation.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/PreparedOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,25 +23,25 @@ import org.springframework.r2dbc.core.binding.BindTarget; /** * Extension to {@link QueryOperation} for a prepared SQL query * {@link Supplier} with bound parameters. Contains parameter - * bindings that can be {@link #bindTo bound} bound to a {@link BindTarget}. + * bindings that can be {@link #bindTo bound} to a {@link BindTarget}. * *

Can be executed with {@link org.springframework.r2dbc.core.DatabaseClient}. * * @author Mark Paluch * @since 5.3 - * @param underlying operation source. + * @param underlying operation source * @see org.springframework.r2dbc.core.DatabaseClient#sql(Supplier) */ public interface PreparedOperation extends QueryOperation { /** - * Return the underlying query source. + * Get the underlying query source. * @return the query source, such as a statement/criteria object */ T getSource(); /** - * Apply bindings to {@link BindTarget}. + * Apply bindings to the supplied {@link BindTarget}. * @param target the target to apply bindings to */ void bindTo(BindTarget target);