Skip to content

Commit dd73625

Browse files
mp911deschauder
authored andcommitted
DATAJDBC-272 - Reformat code and optimize imports.
1 parent 6a60c53 commit dd73625

File tree

46 files changed

+130
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+130
-172
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private String whereClause() {
103103
return conditions.stream() //
104104
.map(WhereCondition::toSql) //
105105
.collect(Collectors.joining("AND", " WHERE ", "") //
106-
);
106+
);
107107
}
108108

109109
private String joinClause() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
2424

2525
/**
26-
* Provides {@link SqlGenerator}s per domain type. Instances get cached, so when asked multiple times for the same domain
27-
* type, the same generator will get returned.
26+
* Provides {@link SqlGenerator}s per domain type. Instances get cached, so when asked multiple times for the same
27+
* domain type, the same generator will get returned.
2828
*
2929
* @author Jens Schauder
3030
*/

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
*
2525
* @param <T> the type of the referenced aggregate root.
2626
* @param <ID> the type of the id of the referenced aggregate root.
27-
*
2827
* @author Jens Schauder
29-
*
3028
* @since 1.0
3129
*/
3230
public interface AggregateReference<T, ID> {
@@ -42,9 +40,8 @@ static <T, ID> AggregateReference<T, ID> to(ID id) {
4240
ID getId();
4341

4442
/**
45-
* An {@link AggregateReference} that only holds the id of the referenced aggregate root.
46-
*
47-
* Note that there is no check that a matching aggregate for this id actually exists.
43+
* An {@link AggregateReference} that only holds the id of the referenced aggregate root. Note that there is no check
44+
* that a matching aggregate for this id actually exists.
4845
*
4946
* @param <T>
5047
* @param <ID>

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
@NonNullApi
55
package org.springframework.data.jdbc.core;
66

7-
import org.springframework.lang.NonNullApi;
7+
import org.springframework.lang.NonNullApi;

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public class MyBatisContext {
3333
private final Class domainType;
3434
private final Map<String, Object> additonalValues;
3535

36-
public MyBatisContext(@Nullable Object id, @Nullable Object instance, Class domainType, Map<String, Object> additonalValues) {
36+
public MyBatisContext(@Nullable Object id, @Nullable Object instance, Class domainType,
37+
Map<String, Object> additonalValues) {
3738

3839
this.id = id;
3940
this.instance = instance;

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ public void setNamespaceStrategy(NamespaceStrategy namespaceStrategy) {
131131
public <T> Object insert(T instance, Class<T> domainType, Map<String, Object> additionalParameters) {
132132

133133
MyBatisContext myBatisContext = new MyBatisContext(null, instance, domainType, additionalParameters);
134-
sqlSession().insert(namespace(domainType) + ".insert",
135-
myBatisContext);
134+
sqlSession().insert(namespace(domainType) + ".insert", myBatisContext);
136135

137136
return myBatisContext.getId();
138137
}

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositories.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545

4646
/**
4747
* Alias for the {@link #basePackages()} attribute. Allows for more concise annotation declarations e.g.:
48-
* {@code @EnableJdbcRepositories("org.my.pkg")} instead of {@code @EnableJdbcRepositories(basePackages="org.my.pkg")}.
48+
* {@code @EnableJdbcRepositories("org.my.pkg")} instead of
49+
* {@code @EnableJdbcRepositories(basePackages="org.my.pkg")}.
4950
*/
5051
String[] value() default {};
5152

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/JdbcConfiguration.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.springframework.data.jdbc.core.convert.BasicJdbcConverter;
2424
import org.springframework.data.jdbc.core.convert.JdbcCustomConversions;
2525
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
26-
import org.springframework.data.relational.core.conversion.BasicRelationalConverter;
2726
import org.springframework.data.relational.core.conversion.RelationalConverter;
2827
import org.springframework.data.relational.core.mapping.NamingStrategy;
2928
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
@@ -49,8 +48,7 @@ public class JdbcConfiguration {
4948
@Bean
5049
protected JdbcMappingContext jdbcMappingContext(Optional<NamingStrategy> namingStrategy) {
5150

52-
JdbcMappingContext mappingContext = new JdbcMappingContext(
53-
namingStrategy.orElse(NamingStrategy.INSTANCE));
51+
JdbcMappingContext mappingContext = new JdbcMappingContext(namingStrategy.orElse(NamingStrategy.INSTANCE));
5452
mappingContext.setSimpleTypeHolder(jdbcCustomConversions().getSimpleTypeHolder());
5553

5654
return mappingContext;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525
import org.springframework.jdbc.core.RowMapper;
2626

2727
/**
28-
* Annotation to provide SQL statements that will get used for executing the method.
29-
*
30-
* The SQL statement may contain named parameters as supported by {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}.
31-
* Those parameters will get bound to the arguments of the annotated method.
28+
* Annotation to provide SQL statements that will get used for executing the method. The SQL statement may contain named
29+
* parameters as supported by {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}. Those
30+
* parameters will get bound to the arguments of the annotated method.
3231
*
3332
* @author Jens Schauder
3433
*/

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryQuery.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class JdbcRepositoryQuery implements RepositoryQuery {
5252
private final RowMapper<?> rowMapper;
5353

5454
/**
55-
* Creates a new {@link JdbcRepositoryQuery} for the given {@link JdbcQueryMethod}, {@link RelationalMappingContext} and
56-
* {@link RowMapper}.
55+
* Creates a new {@link JdbcRepositoryQuery} for the given {@link JdbcQueryMethod}, {@link RelationalMappingContext}
56+
* and {@link RowMapper}.
5757
*
5858
* @param publisher must not be {@literal null}.
5959
* @param context must not be {@literal null}.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ static class LegoSet {
310310
private String name;
311311

312312
private Manual manual;
313-
@Column("alternative")
314-
private Manual alternativeInstructions;
313+
@Column("alternative") private Manual alternativeInstructions;
315314
}
316315

317316
@Data

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,18 @@
3535
public class CascadingDataAccessStrategyUnitTests {
3636

3737
int errorIndex = 1;
38-
String[] errorMessages = {"Sorry I don't support this method. Please try again later", "Still no luck"};
38+
String[] errorMessages = { "Sorry I don't support this method. Please try again later", "Still no luck" };
3939

4040
DataAccessStrategy alwaysFails = mock(DataAccessStrategy.class, i -> {
41-
errorIndex ++;
42-
errorIndex %=2;
41+
errorIndex++;
42+
errorIndex %= 2;
4343
throw new UnsupportedOperationException(errorMessages[errorIndex]);
4444
});
4545
DataAccessStrategy succeeds = mock(DataAccessStrategy.class);
4646
DataAccessStrategy mayNotCall = mock(DataAccessStrategy.class, i -> {
4747
throw new AssertionFailedError("this shouldn't have get called");
4848
});
4949

50-
5150
@Test // DATAJDBC-123
5251
public void findByReturnsFirstSuccess() {
5352

@@ -75,7 +74,8 @@ public void findByFailsIfAllStrategiesFail() {
7574
@Test // DATAJDBC-123
7675
public void findByPropertyReturnsFirstSuccess() {
7776

78-
doReturn(Collections.singletonList("success")).when(succeeds).findAllByProperty(eq(23L), any(RelationalPersistentProperty.class));
77+
doReturn(Collections.singletonList("success")).when(succeeds).findAllByProperty(eq(23L),
78+
any(RelationalPersistentProperty.class));
7979
CascadingDataAccessStrategy access = new CascadingDataAccessStrategy(asList(alwaysFails, succeeds, mayNotCall));
8080

8181
Iterable<Object> findAll = access.findAllByProperty(23L, mock(RelationalPersistentProperty.class));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private static ResultSet mockResultSet(List<String> columns, Object... values) {
247247
"Number of values [%d] must be a multiple of the number of columns [%d]", //
248248
values.length, //
249249
columns.size() //
250-
) //
250+
) //
251251
);
252252

253253
List<Map<String, Object>> result = convertValues(columns, values);

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void insert() {
7878
null, //
7979
String.class, //
8080
"value" //
81-
);
81+
);
8282
}
8383

8484
@Test // DATAJDBC-123
@@ -100,7 +100,7 @@ public void update() {
100100
null, //
101101
String.class, //
102102
null //
103-
);
103+
);
104104
}
105105

106106
@Test // DATAJDBC-123
@@ -122,7 +122,7 @@ public void delete() {
122122
"an-id", //
123123
String.class, //
124124
null //
125-
);
125+
);
126126
}
127127

128128
@Test // DATAJDBC-123
@@ -146,7 +146,7 @@ public void deleteAllByPath() {
146146
null, //
147147
ChildTwo.class, //
148148
null //
149-
);
149+
);
150150
}
151151

152152
@Test // DATAJDBC-123
@@ -168,7 +168,7 @@ public void deleteAllByType() {
168168
null, //
169169
String.class, //
170170
null //
171-
);
171+
);
172172
}
173173

174174
@Test // DATAJDBC-123
@@ -191,7 +191,7 @@ public void deleteByPath() {
191191
null, "rootid", //
192192
ChildTwo.class, //
193193
null //
194-
);
194+
);
195195
}
196196

197197
@Test // DATAJDBC-123
@@ -212,7 +212,7 @@ public void findById() {
212212
null, "an-id", //
213213
String.class, //
214214
null //
215-
);
215+
);
216216
}
217217

218218
@Test // DATAJDBC-123
@@ -234,7 +234,7 @@ public void findAll() {
234234
null, //
235235
String.class, //
236236
null //
237-
);
237+
);
238238
}
239239

240240
@Test // DATAJDBC-123
@@ -256,7 +256,7 @@ public void findAllById() {
256256
asList("id1", "id2"), //
257257
String.class, //
258258
null //
259-
);
259+
);
260260
}
261261

262262
@SuppressWarnings("unchecked")
@@ -285,7 +285,7 @@ public void findAllByProperty() {
285285
"id", //
286286
Number.class, //
287287
null //
288-
);
288+
);
289289
}
290290

291291
@Test // DATAJDBC-123
@@ -307,7 +307,7 @@ public void existsById() {
307307
"id", //
308308
String.class, //
309309
null //
310-
);
310+
);
311311
}
312312

313313
@Test // DATAJDBC-157
@@ -331,7 +331,7 @@ public void count() {
331331
null, //
332332
String.class, //
333333
null //
334-
);
334+
);
335335
}
336336

337337
private static class DummyEntity {

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ public void cascadingDeleteFirstLevel() {
114114

115115
String sql = sqlGenerator.createDeleteByPath(getPath("ref", DummyEntity.class));
116116

117-
assertThat(sql).isEqualTo("DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity "
118-
+ "WHERE dummy_entity = :rootId");
117+
assertThat(sql).isEqualTo(
118+
"DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity " + "WHERE dummy_entity = :rootId");
119119
}
120120

121121
@Test // DATAJDBC-107
@@ -126,9 +126,8 @@ public void cascadingDeleteAllSecondLevel() {
126126
String sql = sqlGenerator.createDeleteByPath(getPath("ref.further", DummyEntity.class));
127127

128128
assertThat(sql).isEqualTo("DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_SecondLevelReferencedEntity "
129-
+ "WHERE referenced_entity IN "
130-
+ "(SELECT FixedCustomPropertyPrefix_l1id " + "FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity "
131-
+ "WHERE dummy_entity = :rootId)");
129+
+ "WHERE referenced_entity IN " + "(SELECT FixedCustomPropertyPrefix_l1id "
130+
+ "FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity " + "WHERE dummy_entity = :rootId)");
132131
}
133132

134133
@Test // DATAJDBC-107
@@ -148,8 +147,8 @@ public void cascadingDeleteAllFirstLevel() {
148147

149148
String sql = sqlGenerator.createDeleteAllSql(getPath("ref", DummyEntity.class));
150149

151-
assertThat(sql).isEqualTo("DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity "
152-
+ "WHERE dummy_entity IS NOT NULL");
150+
assertThat(sql).isEqualTo(
151+
"DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity " + "WHERE dummy_entity IS NOT NULL");
153152
}
154153

155154
@Test // DATAJDBC-107
@@ -160,9 +159,8 @@ public void cascadingDeleteSecondLevel() {
160159
String sql = sqlGenerator.createDeleteAllSql(getPath("ref.further", DummyEntity.class));
161160

162161
assertThat(sql).isEqualTo("DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_SecondLevelReferencedEntity "
163-
+ "WHERE referenced_entity IN "
164-
+ "(SELECT FixedCustomPropertyPrefix_l1id " + "FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity "
165-
+ "WHERE dummy_entity IS NOT NULL)");
162+
+ "WHERE referenced_entity IN " + "(SELECT FixedCustomPropertyPrefix_l1id "
163+
+ "FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity " + "WHERE dummy_entity IS NOT NULL)");
166164
}
167165

168166
@Test // DATAJDBC-113

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ public void joinForOneToOneWithoutIdIncludesTheBackReferenceOfTheOuterJoin() {
199199

200200
String findAll = sqlGenerator.getFindAll();
201201

202-
assertThat(findAll).containsSequence(
203-
"SELECT",
204-
"child.parent_of_no_id_child AS child_parent_of_no_id_child",
202+
assertThat(findAll).containsSequence("SELECT", "child.parent_of_no_id_child AS child_parent_of_no_id_child",
205203
"FROM");
206204
}
207205

@@ -256,8 +254,7 @@ static class ParentOfNoIdChild {
256254
NoIdChild child;
257255
}
258256

259-
static class NoIdChild {
260-
}
257+
static class NoIdChild {}
261258

262259
static class OtherAggregate {
263260
@Id Long id;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ public void convertsFromAggregateReference() {
7272

7373
private static class DummyEntity {
7474

75-
@Id
76-
Long simple;
75+
@Id Long simple;
7776
AggregateReference<DummyEntity, Long> reference;
7877
}
7978
}

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/mapping/BasicJdbcPersistentPropertyUnitTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public void detectsAnnotatedColumnName() {
9797
public void detectsAnnotatedColumnAndKeyName() {
9898

9999
RelationalPersistentProperty listProperty = context //
100-
.getRequiredPersistentEntity(DummyEntity.class) //
101-
.getRequiredPersistentProperty("someList");
100+
.getRequiredPersistentEntity(DummyEntity.class) //
101+
.getRequiredPersistentProperty("someList");
102102

103103
assertThat(listProperty.getReverseColumnName()).isEqualTo("dummy_column_name");
104104
assertThat(listProperty.getKeyColumn()).isEqualTo("dummy_key_column_name");

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/DummyEntity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
@Alias("DummyEntity")
2727
class DummyEntity {
2828

29-
@Wither
30-
@Id final Long id;
29+
@Wither @Id final Long id;
3130
final String name;
3231

3332
public DummyEntity(Long id, String name) {

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisHsqlIntegrationTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory factory) {
9191
DataAccessStrategy dataAccessStrategy(RelationalMappingContext context, RelationalConverter converter,
9292
SqlSession sqlSession, EmbeddedDatabase db) {
9393
return MyBatisDataAccessStrategy.createCombinedAccessStrategy(context, converter,
94-
new NamedParameterJdbcTemplate(db),
95-
sqlSession);
94+
new NamedParameterJdbcTemplate(db), sqlSession);
9695
}
9796
}
9897

0 commit comments

Comments
 (0)