Skip to content

Commit

Permalink
#220 - Polishing.
Browse files Browse the repository at this point in the history
Formatting.
Fix warnings.
JavaDoc.
Adjusted nullability annotations.

Original pull request: #287.
  • Loading branch information
schauder authored and mp911de committed Feb 12, 2020
1 parent 01eccbb commit 49a4ff3
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ private static void bindByIndex(Statement statement, Map<Integer, SettableValue>
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());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,24 +255,13 @@ private PreparedOperation<Delete> getMappedObject(DeleteSpec deleteSpec,
* (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}.
*
Expand All @@ -284,7 +273,8 @@ static class DefaultPreparedOperation<T> implements PreparedOperation<T> {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -82,7 +82,7 @@ public R2dbcEntityTemplate(DatabaseClient databaseClient) {
/**
* 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) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,13 @@ public ReactiveDelete delete(Class<?> domainType) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ public <T> ReactiveInsert<T> insert(Class<T> domainType) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,14 @@ public <T> ReactiveSelect<T> select(Class<T> domainType) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,13 @@ public ReactiveUpdate update(Class<?> domainType) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,12 @@ public Map<SqlIdentifier, SettableValue> getAssignments() {
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;
Expand Down Expand Up @@ -506,6 +507,7 @@ public SqlIdentifier getTable() {
return this.table;
}

@Nullable
public Update getUpdate() {
return this.update;
}
Expand Down
17 changes: 2 additions & 15 deletions src/main/java/org/springframework/data/r2dbc/query/Criteria.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,101 +165,88 @@ public interface CriteriaStep {
* Creates a {@link Criteria} using equality.
*
* @param value must not be {@literal null}.
* @return
*/
Criteria is(Object value);

/**
* Creates a {@link Criteria} using equality (is not).
*
* @param value must not be {@literal null}.
* @return
*/
Criteria not(Object value);

/**
* Creates a {@link Criteria} using {@code IN}.
*
* @param values must not be {@literal null}.
* @return
*/
Criteria in(Object... values);

/**
* 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);

/**
* 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);

/**
* Creates a {@link Criteria} using less-than or equal to ({@literal <=}).
*
* @param value must not be {@literal null}.
* @return
*/
Criteria lessThanOrEquals(Object value);

/**
* Creates a {@link Criteria} using greater-than({@literal >}).
*
* @param value must not be {@literal null}.
* @return
*/
Criteria greaterThan(Object value);

/**
* Creates a {@link Criteria} using greater-than or equal to ({@literal >=}).
*
* @param value must not be {@literal null}.
* @return
*/
Criteria greaterThanOrEquals(Object value);

/**
* 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private Query(@Nullable Criteria criteria) {
}

private Query(@Nullable Criteria criteria, List<SqlIdentifier> columns, Sort sort, int limit, long offset) {

this.criteria = criteria;
this.columns = columns;
this.sort = sort;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public Expression getMappedObject(Expression expression, @Nullable RelationalPer
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) {
Expand Down

0 comments on commit 49a4ff3

Please sign in to comment.