Skip to content

Commit 1443669

Browse files
committedNov 10, 2022
Polishing
1 parent 4c2072d commit 1443669

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed
 

‎spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DatabaseClient.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,36 @@
3737
import org.springframework.util.Assert;
3838

3939
/**
40-
* A non-blocking, reactive client for performing database calls requests with
40+
* A non-blocking, reactive client for performing database calls with
4141
* Reactive Streams back pressure. Provides a higher level, common API over
4242
* R2DBC client libraries.
4343
*
44-
* <p>Use one of the static factory methods {@link #create(ConnectionFactory)}
45-
* or obtain a {@link DatabaseClient#builder()} to create an instance.
44+
* <p>Use the static factory method {@link #create(ConnectionFactory)} or obtain
45+
* a {@linkplain DatabaseClient#builder() builder} to create an instance.
4646
*
47-
* Usage example:
47+
* <p>Usage example:
4848
* <pre class="code">
4949
* ConnectionFactory factory = …
5050
*
5151
* DatabaseClient client = DatabaseClient.create(factory);
5252
* Mono&lt;Actor&gt; actor = client.sql("select first_name, last_name from t_actor")
5353
* .map(row -&gt; new Actor(row.get("first_name", String.class),
5454
* row.get("last_name", String.class)))
55-
* .first();
56-
* </pre>
55+
* .first();</pre>
5756
*
5857
* @author Mark Paluch
5958
* @since 5.3
6059
*/
6160
public interface DatabaseClient extends ConnectionAccessor {
6261

6362
/**
64-
* Return the {@link ConnectionFactory} that this client uses.
63+
* Get the {@link ConnectionFactory} that this client uses.
6564
* @return the connection factory
6665
*/
6766
ConnectionFactory getConnectionFactory();
6867

6968
/**
70-
* Specify a static {@code sql} statement to run. Contract for specifying a
69+
* Specify a static {@code sql} statement to run. Contract for specifying an
7170
* SQL call along with options leading to the execution. The SQL string can
7271
* contain either native parameter bind markers or named parameters (e.g.
7372
* {@literal :foo, :bar}) when {@link NamedParameterExpander} is enabled.
@@ -79,7 +78,7 @@ public interface DatabaseClient extends ConnectionAccessor {
7978
GenericExecuteSpec sql(String sql);
8079

8180
/**
82-
* Specify a {@link Supplier SQL supplier} that provides SQL to run.
81+
* Specify an {@linkplain Supplier SQL supplier} that provides SQL to run.
8382
* Contract for specifying an SQL call along with options leading to
8483
* the execution. The SQL string can contain either native parameter
8584
* bind markers or named parameters (e.g. {@literal :foo, :bar}) when
@@ -99,7 +98,7 @@ public interface DatabaseClient extends ConnectionAccessor {
9998
/**
10099
* Create a {@code DatabaseClient} that will use the provided {@link ConnectionFactory}.
101100
* @param factory the {@code ConnectionFactory} to use for obtaining connections
102-
* @return a new {@code DatabaseClient}. Guaranteed to be not {@code null}.
101+
* @return a new {@code DatabaseClient}; never {@code null}
103102
*/
104103
static DatabaseClient create(ConnectionFactory factory) {
105104
return new DefaultDatabaseClientBuilder().connectionFactory(factory).build();
@@ -129,22 +128,22 @@ interface Builder {
129128
Builder connectionFactory(ConnectionFactory factory);
130129

131130
/**
132-
* Configure a {@link ExecuteFunction} to execute {@link Statement} objects.
131+
* Configure an {@link ExecuteFunction} to execute {@link Statement} objects.
133132
* @see Statement#execute()
134133
*/
135134
Builder executeFunction(ExecuteFunction executeFunction);
136135

137136
/**
138137
* Configure whether to use named parameter expansion.
139-
* Defaults to {@code true}.
138+
* <p>Defaults to {@code true}.
140139
* @param enabled {@code true} to use named parameter expansion;
141140
* {@code false} to disable named parameter expansion
142141
* @see NamedParameterExpander
143142
*/
144143
Builder namedParameters(boolean enabled);
145144

146145
/**
147-
* Configures a {@link Consumer} to configure this builder.
146+
* Apply a {@link Consumer} to configure this builder.
148147
*/
149148
Builder apply(Consumer<Builder> builderConsumer);
150149

@@ -238,7 +237,7 @@ default GenericExecuteSpec filter(Function<? super Statement, ? extends Statemen
238237
* Perform the SQL call and apply {@link BiFunction function} to the {@link Result}.
239238
* @param mappingFunction a function that maps from {@link Result} into a result publisher
240239
* @param <R> the result type
241-
* @return a {@link Flux} emitting mapped elements
240+
* @return a {@link Flux} that emits mapped elements
242241
* @since 6.0
243242
* @see Result#filter(Predicate)
244243
* @see Result#flatMap(Function)

‎spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,15 @@ private static Mono<Long> sumRowsUpdated(
200200
}
201201

202202
/**
203-
* Determine SQL from potential provider object.
204-
* @param sqlProvider object that's potentially a SqlProvider
203+
* Get SQL from a potential provider object.
204+
* @param object an object that is potentially an SqlProvider
205205
* @return the SQL string, or {@code null}
206206
* @see SqlProvider
207207
*/
208208
@Nullable
209-
private static String getSql(Object sqlProvider) {
210-
211-
if (sqlProvider instanceof SqlProvider) {
212-
return ((SqlProvider) sqlProvider).getSql();
209+
private static String getSql(Object object) {
210+
if (object instanceof SqlProvider sqlProvider) {
211+
return sqlProvider.getSql();
213212
}
214213
else {
215214
return null;
@@ -218,7 +217,7 @@ private static String getSql(Object sqlProvider) {
218217

219218

220219
/**
221-
* Base class for {@link DatabaseClient.GenericExecuteSpec} implementations.
220+
* Default {@link DatabaseClient.GenericExecuteSpec} implementation.
222221
*/
223222
class DefaultGenericExecuteSpec implements GenericExecuteSpec {
224223

@@ -352,10 +351,10 @@ private ResultFunction getResultFunction(Supplier<String> sqlSupplier) {
352351
if (logger.isDebugEnabled()) {
353352
logger.debug("Executing SQL statement [" + sql + "]");
354353
}
355-
if (sqlSupplier instanceof PreparedOperation<?>) {
354+
if (sqlSupplier instanceof PreparedOperation<?> preparedOperation) {
356355
Statement statement = connection.createStatement(sql);
357356
BindTarget bindTarget = new StatementWrapper(statement);
358-
((PreparedOperation<?>) sqlSupplier).bindTo(bindTarget);
357+
preparedOperation.bindTo(bindTarget);
359358
return statement;
360359
}
361360

@@ -397,7 +396,7 @@ private ResultFunction getResultFunction(Supplier<String> sqlSupplier) {
397396
Function<Connection, Flux<Result>> resultFunction = connection -> {
398397
Statement statement = statementFunction.apply(connection);
399398
return Flux.from(this.filterFunction.filter(statement, DefaultDatabaseClient.this.executeFunction))
400-
.cast(Result.class).checkpoint("SQL \"" + sql + "\" [DatabaseClient]");
399+
.cast(Result.class).checkpoint("SQL \"" + sql + "\" [DatabaseClient]");
401400
};
402401

403402
return new ResultFunction(resultFunction, sql);

‎spring-r2dbc/src/main/java/org/springframework/r2dbc/core/PreparedOperation.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,25 +23,25 @@
2323
/**
2424
* Extension to {@link QueryOperation} for a prepared SQL query
2525
* {@link Supplier} with bound parameters. Contains parameter
26-
* bindings that can be {@link #bindTo bound} bound to a {@link BindTarget}.
26+
* bindings that can be {@link #bindTo bound} to a {@link BindTarget}.
2727
*
2828
* <p>Can be executed with {@link org.springframework.r2dbc.core.DatabaseClient}.
2929
*
3030
* @author Mark Paluch
3131
* @since 5.3
32-
* @param <T> underlying operation source.
32+
* @param <T> underlying operation source
3333
* @see org.springframework.r2dbc.core.DatabaseClient#sql(Supplier)
3434
*/
3535
public interface PreparedOperation<T> extends QueryOperation {
3636

3737
/**
38-
* Return the underlying query source.
38+
* Get the underlying query source.
3939
* @return the query source, such as a statement/criteria object
4040
*/
4141
T getSource();
4242

4343
/**
44-
* Apply bindings to {@link BindTarget}.
44+
* Apply bindings to the supplied {@link BindTarget}.
4545
* @param target the target to apply bindings to
4646
*/
4747
void bindTo(BindTarget target);

0 commit comments

Comments
 (0)
Please sign in to comment.