Skip to content

Commit 5955270

Browse files
committed
#124 - Polishing.
Reduce Lombok usage to within tests.
1 parent 3c3277e commit 5955270

11 files changed

+211
-85
lines changed

src/main/java/org/springframework/data/r2dbc/connectionfactory/SimpleConnectionHandle.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @author Mark Paluch
2626
* @author Christoph Strobl
2727
*/
28-
class SimpleConnectionHandle implements ConnectionHandle {
28+
public class SimpleConnectionHandle implements ConnectionHandle {
2929

3030
private final Connection connection;
3131

src/main/java/org/springframework/data/r2dbc/convert/MappingR2dbcConverter.java

+13-7
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import io.r2dbc.spi.ColumnMetadata;
1919
import io.r2dbc.spi.Row;
2020
import io.r2dbc.spi.RowMetadata;
21-
import lombok.NonNull;
22-
import lombok.RequiredArgsConstructor;
2321

2422
import java.lang.reflect.Array;
2523
import java.util.Collection;
@@ -434,14 +432,22 @@ private static Map<String, ColumnMetadata> createMetadataMap(RowMetadata metadat
434432
return columns;
435433
}
436434

437-
@RequiredArgsConstructor
438435
private static class RowParameterValueProvider implements ParameterValueProvider<RelationalPersistentProperty> {
439436

440-
private final @NonNull Row resultSet;
437+
private final Row resultSet;
441438
private final @Nullable RowMetadata metadata;
442-
private final @NonNull RelationalPersistentEntity<?> entity;
443-
private final @NonNull RelationalConverter converter;
444-
private final @NonNull String prefix;
439+
private final RelationalPersistentEntity<?> entity;
440+
private final RelationalConverter converter;
441+
private final String prefix;
442+
443+
public RowParameterValueProvider(Row resultSet, RowMetadata metadata, RelationalPersistentEntity<?> entity,
444+
RelationalConverter converter, String prefix) {
445+
this.resultSet = resultSet;
446+
this.metadata = metadata;
447+
this.entity = entity;
448+
this.converter = converter;
449+
this.prefix = prefix;
450+
}
445451

446452
/*
447453
* (non-Javadoc)

src/main/java/org/springframework/data/r2dbc/core/DefaultDatabaseClient.java

+70-22
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@
1515
*/
1616
package org.springframework.data.r2dbc.core;
1717

18-
import io.r2dbc.spi.Connection;
19-
import io.r2dbc.spi.ConnectionFactory;
20-
import io.r2dbc.spi.R2dbcException;
21-
import io.r2dbc.spi.Result;
22-
import io.r2dbc.spi.Row;
23-
import io.r2dbc.spi.RowMetadata;
24-
import io.r2dbc.spi.Statement;
25-
import lombok.RequiredArgsConstructor;
26-
import reactor.core.publisher.Flux;
27-
import reactor.core.publisher.Mono;
28-
2918
import java.lang.reflect.InvocationHandler;
3019
import java.lang.reflect.InvocationTargetException;
3120
import java.lang.reflect.Method;
@@ -42,9 +31,18 @@
4231
import java.util.function.Supplier;
4332
import java.util.stream.Collectors;
4433

34+
import io.r2dbc.spi.Connection;
35+
import io.r2dbc.spi.ConnectionFactory;
36+
import io.r2dbc.spi.R2dbcException;
37+
import io.r2dbc.spi.Result;
38+
import io.r2dbc.spi.Row;
39+
import io.r2dbc.spi.RowMetadata;
40+
import io.r2dbc.spi.Statement;
4541
import org.apache.commons.logging.Log;
4642
import org.apache.commons.logging.LogFactory;
4743
import org.reactivestreams.Publisher;
44+
import reactor.core.publisher.Flux;
45+
import reactor.core.publisher.Mono;
4846

4947
import org.springframework.dao.DataAccessException;
5048
import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -305,7 +303,6 @@ private static void bindByIndex(Statement statement, Map<Integer, SettableValue>
305303
/**
306304
* Base class for {@link DatabaseClient.GenericExecuteSpec} implementations.
307305
*/
308-
@RequiredArgsConstructor
309306
class ExecuteSpecSupport {
310307

311308
final Map<Integer, SettableValue> byIndex;
@@ -319,6 +316,13 @@ class ExecuteSpecSupport {
319316
this.sqlSupplier = sqlSupplier;
320317
}
321318

319+
ExecuteSpecSupport(Map<Integer, SettableValue> byIndex, Map<String, SettableValue> byName,
320+
Supplier<String> sqlSupplier) {
321+
this.byIndex = byIndex;
322+
this.byName = byName;
323+
this.sqlSupplier = sqlSupplier;
324+
}
325+
322326
<T> FetchSpec<T> exchange(Supplier<String> sqlSupplier, BiFunction<Row, RowMetadata, T> mappingFunction) {
323327

324328
String sql = getRequiredSql(sqlSupplier);
@@ -630,7 +634,6 @@ public <T> TypedSelectSpec<T> from(Class<T> table) {
630634
/**
631635
* Base class for {@link DatabaseClient.GenericExecuteSpec} implementations.
632636
*/
633-
@RequiredArgsConstructor
634637
private abstract class DefaultSelectSpecSupport {
635638

636639
final String table;
@@ -650,6 +653,14 @@ private abstract class DefaultSelectSpecSupport {
650653
this.page = Pageable.unpaged();
651654
}
652655

656+
DefaultSelectSpecSupport(String table, List<String> projectedFields, Criteria criteria, Sort sort, Pageable page) {
657+
this.table = table;
658+
this.projectedFields = projectedFields;
659+
this.criteria = criteria;
660+
this.sort = sort;
661+
this.page = page;
662+
}
663+
653664
public DefaultSelectSpecSupport project(String... selectedFields) {
654665
Assert.notNull(selectedFields, "Projection fields must not be null!");
655666

@@ -789,7 +800,7 @@ private class DefaultTypedSelectSpec<T> extends DefaultSelectSpecSupport impleme
789800
private final @Nullable Class<T> typeToRead;
790801
private final BiFunction<Row, RowMetadata, T> mappingFunction;
791802

792-
DefaultTypedSelectSpec(Class<T> typeToRead) {
803+
DefaultTypedSelectSpec(@Nullable Class<T> typeToRead) {
793804

794805
super(dataAccessStrategy.getTableName(typeToRead));
795806

@@ -798,7 +809,7 @@ private class DefaultTypedSelectSpec<T> extends DefaultSelectSpecSupport impleme
798809
}
799810

800811
DefaultTypedSelectSpec(String table, List<String> projectedFields, Criteria criteria, Sort sort, Pageable page,
801-
Class<T> typeToRead, BiFunction<Row, RowMetadata, T> mappingFunction) {
812+
@Nullable Class<T> typeToRead, BiFunction<Row, RowMetadata, T> mappingFunction) {
802813

803814
super(table, projectedFields, criteria, sort, page);
804815

@@ -905,13 +916,19 @@ public <T> TypedInsertSpec<T> into(Class<T> table) {
905916
/**
906917
* Default implementation of {@link DatabaseClient.GenericInsertSpec}.
907918
*/
908-
@RequiredArgsConstructor
909919
class DefaultGenericInsertSpec<T> implements GenericInsertSpec<T> {
910920

911921
private final String table;
912922
private final Map<String, SettableValue> byName;
913923
private final BiFunction<Row, RowMetadata, T> mappingFunction;
914924

925+
DefaultGenericInsertSpec(String table, Map<String, SettableValue> byName,
926+
BiFunction<Row, RowMetadata, T> mappingFunction) {
927+
this.table = table;
928+
this.byName = byName;
929+
this.mappingFunction = mappingFunction;
930+
}
931+
915932
@Override
916933
public GenericInsertSpec<T> value(String field, Object value) {
917934

@@ -988,7 +1005,6 @@ private <R> FetchSpec<R> exchange(BiFunction<Row, RowMetadata, R> mappingFunctio
9881005
/**
9891006
* Default implementation of {@link DatabaseClient.TypedInsertSpec}.
9901007
*/
991-
@RequiredArgsConstructor
9921008
class DefaultTypedInsertSpec<T, R> implements TypedInsertSpec<T>, InsertSpec<R> {
9931009

9941010
private final Class<?> typeToInsert;
@@ -1004,6 +1020,14 @@ class DefaultTypedInsertSpec<T, R> implements TypedInsertSpec<T>, InsertSpec<R>
10041020
this.mappingFunction = mappingFunction;
10051021
}
10061022

1023+
DefaultTypedInsertSpec(Class<?> typeToInsert, String table, Publisher<T> objectToInsert,
1024+
BiFunction<Row, RowMetadata, R> mappingFunction) {
1025+
this.typeToInsert = typeToInsert;
1026+
this.table = table;
1027+
this.objectToInsert = objectToInsert;
1028+
this.mappingFunction = mappingFunction;
1029+
}
1030+
10071031
@Override
10081032
public TypedInsertSpec<T> table(String tableName) {
10091033

@@ -1118,14 +1142,21 @@ public <T> TypedUpdateSpec<T> table(Class<T> table) {
11181142
}
11191143
}
11201144

1121-
@RequiredArgsConstructor
11221145
class DefaultGenericUpdateSpec implements GenericUpdateSpec, UpdateMatchingSpec {
11231146

11241147
private final @Nullable Class<?> typeToUpdate;
11251148
private final @Nullable String table;
11261149
private final Update assignments;
11271150
private final Criteria where;
11281151

1152+
DefaultGenericUpdateSpec(@Nullable Class<?> typeToUpdate, @Nullable String table, Update assignments,
1153+
Criteria where) {
1154+
this.typeToUpdate = typeToUpdate;
1155+
this.table = table;
1156+
this.assignments = assignments;
1157+
this.where = where;
1158+
}
1159+
11291160
@Override
11301161
public UpdateMatchingSpec using(Update update) {
11311162

@@ -1181,13 +1212,18 @@ private UpdatedRowsFetchSpec exchange(String table) {
11811212
}
11821213
}
11831214

1184-
@RequiredArgsConstructor
11851215
class DefaultTypedUpdateSpec<T> implements TypedUpdateSpec<T>, UpdateSpec {
11861216

11871217
private final @Nullable Class<T> typeToUpdate;
11881218
private final @Nullable String table;
11891219
private final T objectToUpdate;
11901220

1221+
DefaultTypedUpdateSpec(@Nullable Class<T> typeToUpdate, @Nullable String table, T objectToUpdate) {
1222+
this.typeToUpdate = typeToUpdate;
1223+
this.table = table;
1224+
this.objectToUpdate = objectToUpdate;
1225+
}
1226+
11911227
@Override
11921228
public UpdateSpec using(T objectToUpdate) {
11931229

@@ -1270,13 +1306,18 @@ public <T> DefaultDeleteSpec<T> from(Class<T> table) {
12701306
/**
12711307
* Default implementation of {@link DatabaseClient.TypedInsertSpec}.
12721308
*/
1273-
@RequiredArgsConstructor
12741309
class DefaultDeleteSpec<T> implements DeleteMatchingSpec, TypedDeleteSpec<T> {
12751310

12761311
private final @Nullable Class<T> typeToDelete;
12771312
private final @Nullable String table;
12781313
private final Criteria where;
12791314

1315+
DefaultDeleteSpec(@Nullable Class<T> typeToDelete, @Nullable String table, Criteria where) {
1316+
this.typeToDelete = typeToDelete;
1317+
this.table = table;
1318+
this.where = where;
1319+
}
1320+
12801321
@Override
12811322
public DeleteSpec matching(Criteria criteria) {
12821323

@@ -1483,14 +1524,18 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
14831524
/**
14841525
* Holder for a connection that makes sure the close action is invoked atomically only once.
14851526
*/
1486-
@RequiredArgsConstructor
14871527
static class ConnectionCloseHolder extends AtomicBoolean {
14881528

14891529
private static final long serialVersionUID = -8994138383301201380L;
14901530

14911531
final Connection connection;
14921532
final Function<Connection, Publisher<Void>> closeFunction;
14931533

1534+
ConnectionCloseHolder(Connection connection, Function<Connection, Publisher<Void>> closeFunction) {
1535+
this.connection = connection;
1536+
this.closeFunction = closeFunction;
1537+
}
1538+
14941539
Mono<Void> close() {
14951540

14961541
return Mono.defer(() -> {
@@ -1504,11 +1549,14 @@ Mono<Void> close() {
15041549
}
15051550
}
15061551

1507-
@RequiredArgsConstructor
15081552
static class StatementWrapper implements BindTarget {
15091553

15101554
final Statement statement;
15111555

1556+
StatementWrapper(Statement statement) {
1557+
this.statement = statement;
1558+
}
1559+
15121560
@Override
15131561
public void bind(Object identifier, Object value) {
15141562
this.statement.bind(identifier, value);

src/main/java/org/springframework/data/r2dbc/core/DefaultFetchSpec.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.springframework.data.r2dbc.core;
1717

1818
import io.r2dbc.spi.Connection;
19-
import lombok.RequiredArgsConstructor;
2019
import reactor.core.publisher.Flux;
2120
import reactor.core.publisher.Mono;
2221

@@ -29,14 +28,21 @@
2928
*
3029
* @author Mark Paluch
3130
*/
32-
@RequiredArgsConstructor
3331
class DefaultFetchSpec<T> implements FetchSpec<T> {
3432

3533
private final ConnectionAccessor connectionAccessor;
3634
private final String sql;
3735
private final Function<Connection, Flux<T>> resultFunction;
3836
private final Function<Connection, Mono<Integer>> updatedRowsFunction;
3937

38+
DefaultFetchSpec(ConnectionAccessor connectionAccessor, String sql, Function<Connection, Flux<T>> resultFunction,
39+
Function<Connection, Mono<Integer>> updatedRowsFunction) {
40+
this.connectionAccessor = connectionAccessor;
41+
this.sql = sql;
42+
this.resultFunction = resultFunction;
43+
this.updatedRowsFunction = updatedRowsFunction;
44+
}
45+
4046
/* (non-Javadoc)
4147
* @see org.springframework.data.r2dbc.function.FetchSpec#one()
4248
*/

src/main/java/org/springframework/data/r2dbc/core/DefaultStatementMapper.java

+18-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package org.springframework.data.r2dbc.core;
1717

18-
import lombok.RequiredArgsConstructor;
19-
2018
import java.util.ArrayList;
2119
import java.util.Collection;
2220
import java.util.List;
@@ -45,14 +43,21 @@
4543
*
4644
* @author Mark Paluch
4745
*/
48-
@RequiredArgsConstructor
4946
class DefaultStatementMapper implements StatementMapper {
5047

5148
private final R2dbcDialect dialect;
5249
private final RenderContext renderContext;
5350
private final UpdateMapper updateMapper;
5451
private final MappingContext<RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> mappingContext;
5552

53+
DefaultStatementMapper(R2dbcDialect dialect, RenderContext renderContext, UpdateMapper updateMapper,
54+
MappingContext<RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> mappingContext) {
55+
this.dialect = dialect;
56+
this.renderContext = renderContext;
57+
this.updateMapper = updateMapper;
58+
this.mappingContext = mappingContext;
59+
}
60+
5661
/*
5762
* (non-Javadoc)
5863
* @see org.springframework.data.r2dbc.function.StatementMapper#forType(java.lang.Class)
@@ -255,13 +260,18 @@ private PreparedOperation<Delete> getMappedObject(DeleteSpec deleteSpec,
255260
*
256261
* @param <T>
257262
*/
258-
@RequiredArgsConstructor
259263
static class DefaultPreparedOperation<T> implements PreparedOperation<T> {
260264

261265
private final T source;
262266
private final RenderContext renderContext;
263267
private final Bindings bindings;
264268

269+
public DefaultPreparedOperation(T source, RenderContext renderContext, Bindings bindings) {
270+
this.source = source;
271+
this.renderContext = renderContext;
272+
this.bindings = bindings;
273+
}
274+
265275
/*
266276
* (non-Javadoc)
267277
* @see org.springframework.data.r2dbc.function.PreparedOperation#getSource()
@@ -305,11 +315,14 @@ public void bindTo(BindTarget to) {
305315
}
306316
}
307317

308-
@RequiredArgsConstructor
309318
class DefaultTypedStatementMapper<T> implements TypedStatementMapper<T> {
310319

311320
final RelationalPersistentEntity<T> entity;
312321

322+
DefaultTypedStatementMapper(RelationalPersistentEntity<T> entity) {
323+
this.entity = entity;
324+
}
325+
313326
/*
314327
* (non-Javadoc)
315328
* @see org.springframework.data.r2dbc.function.StatementMapper#forType(java.lang.Class)

0 commit comments

Comments
 (0)