#220 - Polishing.

Formatting.
Fix warnings.
JavaDoc.
Adjusted nullability annotations.

Original pull request: #287.
This commit is contained in:
Jens Schauder
2020-02-12 13:42:12 +01:00
committed by Mark Paluch
parent 01eccbbbd7
commit 49a4ff3189
11 changed files with 19 additions and 47 deletions

View File

@@ -309,9 +309,9 @@ class DefaultDatabaseClient implements DatabaseClient, ConnectionAccessor {
byIndex.forEach((i, o) -> {
if (o.getValue() != null) {
statement.bind(i.intValue(), o.getValue());
statement.bind(i, o.getValue());
} else {
statement.bindNull(i.intValue(), o.getType());
statement.bindNull(i, o.getType());
}
});
}

View File

@@ -255,24 +255,13 @@ class DefaultStatementMapper implements StatementMapper {
* (non-Javadoc)
* @see org.springframework.data.r2dbc.function.StatementMapper#toSql(SqlIdentifier)
*/
public String toSql(SqlIdentifier identifier) {
private String toSql(SqlIdentifier identifier) {
Assert.notNull(identifier, "SqlIdentifier must not be null");
return identifier.toSql(this.dialect.getIdentifierProcessing());
}
private List<String> toSql(List<SqlIdentifier> identifiers) {
List<String> list = new ArrayList<>(identifiers.size());
for (SqlIdentifier sqlIdentifier : identifiers) {
list.add(toSql(sqlIdentifier));
}
return list;
}
/**
* Default implementation of {@link PreparedOperation}.
*
@@ -284,7 +273,8 @@ class DefaultStatementMapper implements StatementMapper {
private final RenderContext renderContext;
private final Bindings bindings;
public DefaultPreparedOperation(T source, RenderContext renderContext, Bindings bindings) {
DefaultPreparedOperation(T source, RenderContext renderContext, Bindings bindings) {
this.source = source;
this.renderContext = renderContext;
this.bindings = bindings;

View File

@@ -73,7 +73,7 @@ public class R2dbcEntityTemplate implements R2dbcEntityOperations, BeanFactoryAw
/**
* Create a new {@link R2dbcEntityTemplate} given {@link DatabaseClient}.
*
* @param databaseClient
* @param databaseClient must not be {@literal null}.
*/
public R2dbcEntityTemplate(DatabaseClient databaseClient) {
this(databaseClient, getDataAccessStrategy(databaseClient));
@@ -82,7 +82,7 @@ public class R2dbcEntityTemplate implements R2dbcEntityOperations, BeanFactoryAw
/**
* Create a new {@link R2dbcEntityTemplate} given {@link DatabaseClient} and {@link ReactiveDataAccessStrategy}.
*
* @param databaseClient
* @param databaseClient must not be {@literal null}.
*/
public R2dbcEntityTemplate(DatabaseClient databaseClient, ReactiveDataAccessStrategy strategy) {

View File

@@ -51,15 +51,13 @@ class ReactiveDeleteOperationSupport implements ReactiveDeleteOperation {
static class ReactiveDeleteSupport implements ReactiveDelete, TerminatingDelete {
private final R2dbcEntityTemplate template;
private final Class<?> domainType;
private final Query query;
private final @Nullable SqlIdentifier tableName;
ReactiveDeleteSupport(R2dbcEntityTemplate template, Class<?> domainType, Query query,
@Nullable SqlIdentifier tableName) {
this.template = template;
this.domainType = domainType;
this.query = query;

View File

@@ -50,12 +50,11 @@ class ReactiveInsertOperationSupport implements ReactiveInsertOperation {
static class ReactiveInsertSupport<T> implements ReactiveInsert<T> {
private final R2dbcEntityTemplate template;
private final Class<T> domainType;
private final @Nullable SqlIdentifier tableName;
ReactiveInsertSupport(R2dbcEntityTemplate template, Class<T> domainType, @Nullable SqlIdentifier tableName) {
this.template = template;
this.domainType = domainType;
this.tableName = tableName;

View File

@@ -52,17 +52,14 @@ class ReactiveSelectOperationSupport implements ReactiveSelectOperation {
static class ReactiveSelectSupport<T> implements ReactiveSelect<T> {
private final R2dbcEntityTemplate template;
private final Class<?> domainType;
private final Class<T> returnType;
private final Query query;
private final @Nullable SqlIdentifier tableName;
ReactiveSelectSupport(R2dbcEntityTemplate template, Class<?> domainType, Class<T> returnType, Query query,
@Nullable SqlIdentifier tableName) {
this.template = template;
this.domainType = domainType;
this.returnType = returnType;

View File

@@ -52,15 +52,13 @@ class ReactiveUpdateOperationSupport implements ReactiveUpdateOperation {
static class ReactiveUpdateSupport implements ReactiveUpdate, TerminatingUpdate {
private final R2dbcEntityTemplate template;
private final Class<?> domainType;
private final Query query;
private final @Nullable SqlIdentifier tableName;
ReactiveUpdateSupport(R2dbcEntityTemplate template, Class<?> domainType, Query query,
@Nullable SqlIdentifier tableName) {
this.template = template;
this.domainType = domainType;
this.query = query;

View File

@@ -460,11 +460,12 @@ public interface StatementMapper {
class UpdateSpec {
private final SqlIdentifier table;
@Nullable
private final Update update;
private final @Nullable Criteria criteria;
protected UpdateSpec(SqlIdentifier table, Update update, @Nullable Criteria criteria) {
protected UpdateSpec(SqlIdentifier table, @Nullable Update update, @Nullable Criteria criteria) {
this.table = table;
this.update = update;
@@ -506,6 +507,7 @@ public interface StatementMapper {
return this.table;
}
@Nullable
public Update getUpdate() {
return this.update;
}

View File

@@ -165,7 +165,6 @@ public class Criteria {
* Creates a {@link Criteria} using equality.
*
* @param value must not be {@literal null}.
* @return
*/
Criteria is(Object value);
@@ -173,7 +172,6 @@ public class Criteria {
* Creates a {@link Criteria} using equality (is not).
*
* @param value must not be {@literal null}.
* @return
*/
Criteria not(Object value);
@@ -181,7 +179,6 @@ public class Criteria {
* Creates a {@link Criteria} using {@code IN}.
*
* @param values must not be {@literal null}.
* @return
*/
Criteria in(Object... values);
@@ -189,15 +186,13 @@ public class Criteria {
* Creates a {@link Criteria} using {@code IN}.
*
* @param values must not be {@literal null}.
* @return
*/
Criteria in(Collection<? extends Object> values);
Criteria in(Collection<?> values);
/**
* Creates a {@link Criteria} using {@code NOT IN}.
*
* @param values must not be {@literal null}.
* @return
*/
Criteria notIn(Object... values);
@@ -205,15 +200,13 @@ public class Criteria {
* Creates a {@link Criteria} using {@code NOT IN}.
*
* @param values must not be {@literal null}.
* @return
*/
Criteria notIn(Collection<? extends Object> values);
Criteria notIn(Collection<?> values);
/**
* Creates a {@link Criteria} using less-than ({@literal <}).
*
* @param value must not be {@literal null}.
* @return
*/
Criteria lessThan(Object value);
@@ -221,7 +214,6 @@ public class Criteria {
* Creates a {@link Criteria} using less-than or equal to ({@literal <=}).
*
* @param value must not be {@literal null}.
* @return
*/
Criteria lessThanOrEquals(Object value);
@@ -229,7 +221,6 @@ public class Criteria {
* Creates a {@link Criteria} using greater-than({@literal >}).
*
* @param value must not be {@literal null}.
* @return
*/
Criteria greaterThan(Object value);
@@ -237,7 +228,6 @@ public class Criteria {
* Creates a {@link Criteria} using greater-than or equal to ({@literal >=}).
*
* @param value must not be {@literal null}.
* @return
*/
Criteria greaterThanOrEquals(Object value);
@@ -245,21 +235,18 @@ public class Criteria {
* Creates a {@link Criteria} using {@code LIKE}.
*
* @param value must not be {@literal null}.
* @return
*/
Criteria like(Object value);
/**
* Creates a {@link Criteria} using {@code IS NULL}.
*
* @return
*/
Criteria isNull();
/**
* Creates a {@link Criteria} using {@code IS NOT NULL}.
*
* @return
*/
Criteria isNotNull();
}

View File

@@ -68,6 +68,7 @@ public class Query {
}
private Query(@Nullable Criteria criteria, List<SqlIdentifier> columns, Sort sort, int limit, long offset) {
this.criteria = criteria;
this.columns = columns;
this.sort = sort;

View File

@@ -156,8 +156,8 @@ public class QueryMapper {
Field field = createPropertyField(entity, column.getName());
Table table = column.getTable();
return column instanceof Aliased ? table.column(field.getMappedColumnName()).as(((Aliased) column).getAlias())
: table.column(field.getMappedColumnName());
Column columnFromTable = table.column(field.getMappedColumnName());
return column instanceof Aliased ? columnFromTable.as(((Aliased) column).getAlias()) : columnFromTable;
}
if (expression instanceof SimpleFunction) {