Skip to content

Commit 448f0e0

Browse files
committed
DATAJDBC-428 - Polishing.
Code formatting.
1 parent 6e715cb commit 448f0e0

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public class BasicJdbcConverter extends BasicRelationalConverter implements Jdbc
7575
/**
7676
* Creates a new {@link BasicRelationalConverter} given {@link MappingContext} and a
7777
* {@link JdbcTypeFactory#unsupported() no-op type factory} throwing {@link UnsupportedOperationException} on type
78-
* creation. Use {@link #BasicJdbcConverter(MappingContext, RelationResolver, JdbcTypeFactory)} to convert arrays and
79-
* large objects into JDBC-specific types.
78+
* creation. Use {@link #BasicJdbcConverter(MappingContext, RelationResolver, CustomConversions, JdbcTypeFactory)}
79+
* (MappingContext, RelationResolver, JdbcTypeFactory)} to convert arrays and large objects into JDBC-specific types.
8080
*
8181
* @param context must not be {@literal null}.
8282
* @param relationResolver used to fetch additional relations from the database. Must not be {@literal null}.
@@ -131,6 +131,7 @@ public Object readValue(@Nullable Object value, TypeInformation<?> type) {
131131
}
132132

133133
if (AggregateReference.class.isAssignableFrom(type.getType())) {
134+
134135
if (type.getType().isAssignableFrom(value.getClass())) {
135136
return value;
136137
}
@@ -297,7 +298,7 @@ private ReadingContext(RelationalPersistentEntity<T> entity, ResultSet resultSet
297298
}
298299

299300
private <S> ReadingContext<S> extendBy(RelationalPersistentProperty property) {
300-
return new ReadingContext<S>(
301+
return new ReadingContext<>(
301302
(RelationalPersistentEntity<S>) getMappingContext().getRequiredPersistentEntity(property.getActualType()),
302303
resultSet, rootPath.extendBy(property), path.extendBy(property), identifier, key);
303304
}
@@ -382,7 +383,7 @@ private Object readEmbeddedEntityFrom(@Nullable Object idValue, RelationalPersis
382383

383384
ReadingContext<?> newContext = extendBy(property);
384385

385-
if(shouldCreateEmptyEmbeddedInstance(property) || newContext.hasInstanceValues(idValue)) {
386+
if (shouldCreateEmptyEmbeddedInstance(property) || newContext.hasInstanceValues(idValue)) {
386387
return newContext.createInstanceInternal(idValue);
387388
}
388389

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/EntityRowMapperUnitTests.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.mockito.ArgumentMatchers;
4949
import org.mockito.invocation.InvocationOnMock;
5050
import org.mockito.stubbing.Answer;
51-
5251
import org.springframework.data.annotation.Id;
5352
import org.springframework.data.annotation.PersistenceConstructor;
5453
import org.springframework.data.jdbc.core.mapping.AggregateReference;
@@ -131,19 +130,19 @@ public void namingStrategyGetsHonoredForConstructor() throws SQLException {
131130
.containsExactly(ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha");
132131
}
133132

134-
@Test // DATAJDBC-427
133+
@Test // DATAJDBC-427
135134
public void simpleWithReferenceGetProperlyExtracted() throws SQLException {
136135

137136
ResultSet rs = mockResultSet(asList("id", "name", "trivial_id"), //
138-
ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 100L);
137+
ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 100L);
139138
rs.next();
140139

141140
WithReference extracted = createRowMapper(WithReference.class).mapRow(rs, 1);
142141

143142
assertThat(extracted) //
144-
.isNotNull() //
145-
.extracting(e -> e.id, e -> e.name, e -> e.trivialId) //
146-
.containsExactly(ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", AggregateReference.to(100L));
143+
.isNotNull() //
144+
.extracting(e -> e.id, e -> e.name, e -> e.trivialId) //
145+
.containsExactly(ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", AggregateReference.to(100L));
147146
}
148147

149148
@Test // DATAJDBC-113
@@ -176,19 +175,19 @@ public void immutableOneToOneGetsProperlyExtracted() throws SQLException {
176175
.containsExactly(ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 24L, "beta");
177176
}
178177

179-
@Test // DATAJDBC-427
178+
@Test // DATAJDBC-427
180179
public void immutableWithReferenceGetsProperlyExtracted() throws SQLException {
181180

182181
ResultSet rs = mockResultSet(asList("id", "name", "trivial_id"), //
183-
ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 100L);
182+
ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 100L);
184183
rs.next();
185184

186185
WithReferenceImmutable extracted = createRowMapper(WithReferenceImmutable.class).mapRow(rs, 1);
187186

188187
assertThat(extracted) //
189-
.isNotNull() //
190-
.extracting(e -> e.id, e -> e.name, e -> e.trivialId) //
191-
.containsExactly(ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", AggregateReference.to(100L));
188+
.isNotNull() //
189+
.extracting(e -> e.id, e -> e.name, e -> e.trivialId) //
190+
.containsExactly(ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", AggregateReference.to(100L));
192191
}
193192

194193
// TODO add additional test for multilevel embeddables
@@ -334,7 +333,8 @@ public void simpleNullableImmutableEmbeddedGetsProperlyExtracted() throws SQLExc
334333
ID_FOR_ENTITY_NOT_REFERENCING_MAP, "ru'Ha'");
335334
rs.next();
336335

337-
WithNullableEmbeddedImmutableValue extracted = createRowMapper(WithNullableEmbeddedImmutableValue.class).mapRow(rs, 1);
336+
WithNullableEmbeddedImmutableValue extracted = createRowMapper(WithNullableEmbeddedImmutableValue.class) //
337+
.mapRow(rs, 1);
338338

339339
assertThat(extracted) //
340340
.isNotNull() //
@@ -365,7 +365,8 @@ public void simplePrimitiveImmutableEmbeddedGetsProperlyExtracted() {
365365
ID_FOR_ENTITY_NOT_REFERENCING_MAP, 24);
366366
rs.next();
367367

368-
WithEmbeddedPrimitiveImmutableValue extracted = createRowMapper(WithEmbeddedPrimitiveImmutableValue.class).mapRow(rs, 1);
368+
WithEmbeddedPrimitiveImmutableValue extracted = createRowMapper(WithEmbeddedPrimitiveImmutableValue.class)
369+
.mapRow(rs, 1);
369370

370371
assertThat(extracted) //
371372
.isNotNull() //
@@ -380,7 +381,8 @@ public void simpleImmutableEmbeddedShouldBeNullIfAllOfTheEmbeddableAreNull() thr
380381
ID_FOR_ENTITY_NOT_REFERENCING_MAP, null);
381382
rs.next();
382383

383-
WithNullableEmbeddedImmutableValue extracted = createRowMapper(WithNullableEmbeddedImmutableValue.class).mapRow(rs, 1);
384+
WithNullableEmbeddedImmutableValue extracted = createRowMapper(WithNullableEmbeddedImmutableValue.class) //
385+
.mapRow(rs, 1);
384386

385387
assertThat(extracted) //
386388
.isNotNull() //
@@ -428,7 +430,8 @@ public void primitiveEmbeddedShouldBeNullWhenNoValuePresent() {
428430
ID_FOR_ENTITY_NOT_REFERENCING_MAP, null);
429431
rs.next();
430432

431-
WithEmbeddedPrimitiveImmutableValue extracted = createRowMapper(WithEmbeddedPrimitiveImmutableValue.class).mapRow(rs, 1);
433+
WithEmbeddedPrimitiveImmutableValue extracted = createRowMapper(WithEmbeddedPrimitiveImmutableValue.class)
434+
.mapRow(rs, 1);
432435

433436
assertThat(extracted) //
434437
.isNotNull() //

0 commit comments

Comments
 (0)