Skip to content

Commit 4ee9eb8

Browse files
committed
DATAJDBC-544 - Removes all Lombok from production code.
1 parent dedaf34 commit 4ee9eb8

23 files changed

+429
-140
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/ArrayUtil.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@
1515
*/
1616
package org.springframework.data.jdbc.core.convert;
1717

18-
import lombok.experimental.UtilityClass;
19-
2018
/**
2119
* A collection of utility methods for dealing with arrays.
2220
*
2321
* @author Jens Schauder
2422
* @since 1.1
2523
*/
26-
@UtilityClass
27-
class ArrayUtil {
24+
final class ArrayUtil {
25+
26+
private ArrayUtil() {
27+
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
28+
}
2829

2930
/**
3031
* Converts an {@code Byte[]} into a {@code byte[]}.

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcValue.java

+44-8
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,57 @@
1515
*/
1616
package org.springframework.data.jdbc.core.convert;
1717

18-
import lombok.Value;
19-
2018
import java.sql.JDBCType;
19+
import java.util.Objects;
20+
21+
import org.springframework.lang.Nullable;
2122

2223
/**
2324
* Wraps a value with the JDBCType that should be used to pass it as a bind parameter to a
24-
* {@link java.sql.PreparedStatement}. Register a converter from any type to {@link JdbcValue} in order to control
25-
* the value and the {@link JDBCType} as which a value should get passed to the JDBC driver.
25+
* {@link java.sql.PreparedStatement}. Register a converter from any type to {@link JdbcValue} in order to control the
26+
* value and the {@link JDBCType} as which a value should get passed to the JDBC driver.
2627
*
2728
* @author Jens Schauder
2829
* @since 1.1
2930
*/
30-
@Value(staticConstructor = "of")
31-
public class JdbcValue {
31+
public final class JdbcValue {
32+
33+
private final Object value;
34+
private final JDBCType jdbcType;
35+
36+
private JdbcValue(@Nullable Object value, @Nullable JDBCType jdbcType) {
37+
38+
this.value = value;
39+
this.jdbcType = jdbcType;
40+
}
41+
42+
public static JdbcValue of(@Nullable Object value, @Nullable JDBCType jdbcType) {
43+
return new JdbcValue(value, jdbcType);
44+
}
45+
46+
@Nullable
47+
public Object getValue() {
48+
return this.value;
49+
}
50+
51+
@Nullable
52+
public JDBCType getJdbcType() {
53+
return this.jdbcType;
54+
}
55+
56+
@Override
57+
public boolean equals(Object o) {
58+
59+
if (this == o)
60+
return true;
61+
if (o == null || getClass() != o.getClass())
62+
return false;
63+
JdbcValue jdbcValue = (JdbcValue) o;
64+
return Objects.equals(value, jdbcValue.value) && jdbcType == jdbcValue.jdbcType;
65+
}
3266

33-
Object value;
34-
JDBCType jdbcType;
67+
@Override
68+
public int hashCode() {
69+
return Objects.hash(value, jdbcType);
70+
}
3571
}

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/MapEntityRowMapper.java

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

18-
import lombok.RequiredArgsConstructor;
19-
2018
import java.sql.ResultSet;
2119
import java.sql.SQLException;
2220
import java.util.HashMap;
@@ -26,7 +24,6 @@
2624
import org.springframework.data.relational.core.sql.IdentifierProcessing;
2725
import org.springframework.data.relational.core.sql.SqlIdentifier;
2826
import org.springframework.jdbc.core.RowMapper;
29-
import org.springframework.lang.NonNull;
3027

3128
/**
3229
* A {@link RowMapper} that maps a row to a {@link Map.Entry} so an {@link Iterable} of those can be converted to a
@@ -35,7 +32,6 @@
3532
*
3633
* @author Jens Schauder
3734
*/
38-
@RequiredArgsConstructor
3935
class MapEntityRowMapper<T> implements RowMapper<Map.Entry<Object, T>> {
4036

4137
private final PersistentPropertyPathExtension path;
@@ -44,7 +40,16 @@ class MapEntityRowMapper<T> implements RowMapper<Map.Entry<Object, T>> {
4440
private final SqlIdentifier keyColumn;
4541
private final IdentifierProcessing identifierProcessing;
4642

47-
@NonNull
43+
MapEntityRowMapper(PersistentPropertyPathExtension path, JdbcConverter converter, Identifier identifier,
44+
SqlIdentifier keyColumn, IdentifierProcessing identifierProcessing) {
45+
46+
this.path = path;
47+
this.converter = converter;
48+
this.identifier = identifier;
49+
this.keyColumn = keyColumn;
50+
this.identifierProcessing = identifierProcessing;
51+
}
52+
4853
@Override
4954
public Map.Entry<Object, T> mapRow(ResultSet rs, int rowNum) throws SQLException {
5055

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlGenerator.java

+59-12
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515
*/
1616
package org.springframework.data.jdbc.core.convert;
1717

18-
import lombok.Value;
19-
20-
import java.util.*;
21-
import java.util.function.Function;
22-
import java.util.regex.Pattern;
23-
import java.util.stream.Collectors;
24-
2518
import org.springframework.data.domain.Pageable;
2619
import org.springframework.data.domain.Sort;
2720
import org.springframework.data.jdbc.repository.support.SimpleJdbcRepository;
@@ -41,6 +34,11 @@
4134
import org.springframework.lang.Nullable;
4235
import org.springframework.util.Assert;
4336

37+
import java.util.*;
38+
import java.util.function.Function;
39+
import java.util.regex.Pattern;
40+
import java.util.stream.Collectors;
41+
4442
/**
4543
* Generates SQL statements to be used by {@link SimpleJdbcRepository}
4644
*
@@ -722,11 +720,60 @@ private OrderByField orderToOrderByField(Sort.Order order) {
722720
/**
723721
* Value object representing a {@code JOIN} association.
724722
*/
725-
@Value
726-
static class Join {
727-
Table joinTable;
728-
Column joinColumn;
729-
Column parentId;
723+
static final class Join {
724+
725+
private final Table joinTable;
726+
private final Column joinColumn;
727+
private final Column parentId;
728+
729+
Join(Table joinTable, Column joinColumn, Column parentId) {
730+
731+
Assert.notNull( joinTable,"JoinTable must not be null.");
732+
Assert.notNull( joinColumn,"JoinColumn must not be null.");
733+
Assert.notNull( parentId,"ParentId must not be null.");
734+
735+
this.joinTable = joinTable;
736+
this.joinColumn = joinColumn;
737+
this.parentId = parentId;
738+
}
739+
740+
Table getJoinTable() {
741+
return this.joinTable;
742+
}
743+
744+
Column getJoinColumn() {
745+
return this.joinColumn;
746+
}
747+
748+
Column getParentId() {
749+
return this.parentId;
750+
}
751+
752+
@Override
753+
public boolean equals(Object o) {
754+
755+
if (this == o) return true;
756+
if (o == null || getClass() != o.getClass()) return false;
757+
Join join = (Join) o;
758+
return joinTable.equals(join.joinTable) &&
759+
joinColumn.equals(join.joinColumn) &&
760+
parentId.equals(join.parentId);
761+
}
762+
763+
@Override
764+
public int hashCode() {
765+
return Objects.hash(joinTable, joinColumn, parentId);
766+
}
767+
768+
@Override
769+
public String toString() {
770+
771+
return "Join{" +
772+
"joinTable=" + joinTable +
773+
", joinColumn=" + joinColumn +
774+
", parentId=" + parentId +
775+
'}';
776+
}
730777
}
731778

732779
/**

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlGeneratorSource.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
*/
1616
package org.springframework.data.jdbc.core.convert;
1717

18-
import lombok.RequiredArgsConstructor;
19-
2018
import java.util.Map;
2119

2220
import org.springframework.data.relational.core.dialect.Dialect;
2321
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
22+
import org.springframework.util.Assert;
2423
import org.springframework.util.ConcurrentReferenceHashMap;
2524

2625
/**
@@ -31,14 +30,24 @@
3130
* @author Mark Paluch
3231
* @author Milan Milanov
3332
*/
34-
@RequiredArgsConstructor
3533
public class SqlGeneratorSource {
3634

3735
private final Map<Class<?>, SqlGenerator> CACHE = new ConcurrentReferenceHashMap<>();
3836
private final RelationalMappingContext context;
3937
private final JdbcConverter converter;
4038
private final Dialect dialect;
4139

40+
public SqlGeneratorSource(RelationalMappingContext context, JdbcConverter converter, Dialect dialect) {
41+
42+
Assert.notNull(context, "Context must not be null.");
43+
Assert.notNull(converter, "Converter must not be null.");
44+
Assert.notNull(dialect, "Dialect must not be null.");
45+
46+
this.context = context;
47+
this.converter = converter;
48+
this.dialect = dialect;
49+
}
50+
4251
/**
4352
* @return the {@link Dialect} used by the created {@link SqlGenerator} instances. Guaranteed to be not
4453
* {@literal null}.

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/AggregateReference.java

+31-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
*/
1616
package org.springframework.data.jdbc.core.mapping;
1717

18-
import lombok.EqualsAndHashCode;
19-
import lombok.RequiredArgsConstructor;
20-
import lombok.ToString;
18+
import java.util.Objects;
2119

2220
import org.springframework.lang.Nullable;
21+
import org.springframework.util.Assert;
2322

2423
/**
2524
* A reference to the aggregate root of a different aggregate.
@@ -49,16 +48,42 @@ static <T, ID> AggregateReference<T, ID> to(ID id) {
4948
* @param <T>
5049
* @param <ID>
5150
*/
52-
@RequiredArgsConstructor
53-
@EqualsAndHashCode
54-
@ToString
5551
class IdOnlyAggregateReference<T, ID> implements AggregateReference<T, ID> {
5652

5753
private final ID id;
5854

55+
public IdOnlyAggregateReference(ID id) {
56+
57+
Assert.notNull(id, "Id must not be null.");
58+
59+
this.id = id;
60+
}
61+
5962
@Override
6063
public ID getId() {
6164
return id;
6265
}
66+
67+
@Override
68+
public boolean equals(Object o) {
69+
70+
if (this == o)
71+
return true;
72+
if (o == null || getClass() != o.getClass())
73+
return false;
74+
IdOnlyAggregateReference<?, ?> that = (IdOnlyAggregateReference<?, ?>) o;
75+
return id.equals(that.id);
76+
}
77+
78+
@Override
79+
public int hashCode() {
80+
return Objects.hash(id);
81+
}
82+
83+
@Override
84+
public String toString() {
85+
86+
return "IdOnlyAggregateReference{" + "id=" + id + '}';
87+
}
6388
}
6489
}

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/JdbcQueryCreator.java

+51-7
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
*/
1616
package org.springframework.data.jdbc.repository.query;
1717

18-
import lombok.Value;
19-
2018
import java.util.ArrayList;
2119
import java.util.List;
20+
import java.util.Objects;
2221

2322
import org.springframework.data.domain.Pageable;
2423
import org.springframework.data.domain.Sort;
@@ -312,10 +311,55 @@ Join getJoin(SqlContext sqlContext, PersistentPropertyPathExtension path) {
312311
/**
313312
* Value object representing a {@code JOIN} association.
314313
*/
315-
@Value
316-
static private class Join {
317-
Table joinTable;
318-
Column joinColumn;
319-
Column parentId;
314+
static private final class Join {
315+
316+
private final Table joinTable;
317+
private final Column joinColumn;
318+
private final Column parentId;
319+
320+
Join(Table joinTable, Column joinColumn, Column parentId) {
321+
322+
Assert.notNull(joinTable, "JoinTable must not be null.");
323+
Assert.notNull(joinColumn, "JoinColumn must not be null.");
324+
Assert.notNull(parentId, "ParentId must not be null.");
325+
326+
this.joinTable = joinTable;
327+
this.joinColumn = joinColumn;
328+
this.parentId = parentId;
329+
}
330+
331+
Table getJoinTable() {
332+
return this.joinTable;
333+
}
334+
335+
Column getJoinColumn() {
336+
return this.joinColumn;
337+
}
338+
339+
Column getParentId() {
340+
return this.parentId;
341+
}
342+
343+
@Override
344+
public boolean equals(Object o) {
345+
346+
if (this == o)
347+
return true;
348+
if (o == null || getClass() != o.getClass())
349+
return false;
350+
Join join = (Join) o;
351+
return joinTable.equals(join.joinTable) && joinColumn.equals(join.joinColumn) && parentId.equals(join.parentId);
352+
}
353+
354+
@Override
355+
public int hashCode() {
356+
return Objects.hash(joinTable, joinColumn, parentId);
357+
}
358+
359+
@Override
360+
public String toString() {
361+
362+
return "Join{" + "joinTable=" + joinTable + ", joinColumn=" + joinColumn + ", parentId=" + parentId + '}';
363+
}
320364
}
321365
}

0 commit comments

Comments
 (0)