Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1511e15

Browse files
committed
Polishing.
Formatting. Simplification of code. Original pull request #2065 See #2064
1 parent e7a7bec commit 1511e15

File tree

2 files changed

+19
-36
lines changed

2 files changed

+19
-36
lines changed

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

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.stream.Stream;
2929
import java.util.stream.StreamSupport;
3030

31-
import org.jspecify.annotations.Nullable;
3231
import org.springframework.context.ApplicationContext;
3332
import org.springframework.context.ApplicationEventPublisher;
3433
import org.springframework.data.domain.Page;
@@ -51,22 +50,10 @@
5150
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
5251
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
5352
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
54-
import org.springframework.data.relational.core.mapping.event.AbstractRelationalEvent;
55-
import org.springframework.data.relational.core.mapping.event.AfterConvertCallback;
56-
import org.springframework.data.relational.core.mapping.event.AfterConvertEvent;
57-
import org.springframework.data.relational.core.mapping.event.AfterDeleteCallback;
58-
import org.springframework.data.relational.core.mapping.event.AfterDeleteEvent;
59-
import org.springframework.data.relational.core.mapping.event.AfterSaveCallback;
60-
import org.springframework.data.relational.core.mapping.event.AfterSaveEvent;
61-
import org.springframework.data.relational.core.mapping.event.BeforeConvertCallback;
62-
import org.springframework.data.relational.core.mapping.event.BeforeConvertEvent;
63-
import org.springframework.data.relational.core.mapping.event.BeforeDeleteCallback;
64-
import org.springframework.data.relational.core.mapping.event.BeforeDeleteEvent;
65-
import org.springframework.data.relational.core.mapping.event.BeforeSaveCallback;
66-
import org.springframework.data.relational.core.mapping.event.BeforeSaveEvent;
67-
import org.springframework.data.relational.core.mapping.event.Identifier;
53+
import org.springframework.data.relational.core.mapping.event.*;
6854
import org.springframework.data.relational.core.query.Query;
6955
import org.springframework.data.support.PageableExecutionUtils;
56+
import org.springframework.lang.Nullable;
7057
import org.springframework.util.Assert;
7158
import org.springframework.util.ClassUtils;
7259

@@ -82,6 +69,7 @@
8269
* @author Chirag Tailor
8370
* @author Diego Krupitza
8471
* @author Sergey Korotaev
72+
* @author Mikhail Polivakha
8573
*/
8674
public class JdbcAggregateTemplate implements JdbcAggregateOperations {
8775

@@ -708,16 +696,13 @@ private <T> T triggerBeforeDelete(@Nullable T aggregateRoot, Object id, MutableA
708696
return null;
709697
}
710698

711-
private record EntityAndPreviousVersion<T>(T entity, @Nullable Number version) {
699+
private record EntityAndPreviousVersion<T>(T entity, @Nullable Number version) {
712700
}
713701

714-
private record EntityAndChangeCreator<T>(T entity, AggregateChangeCreator<T> changeCreator) {
702+
private record EntityAndChangeCreator<T>(T entity, AggregateChangeCreator<T> changeCreator) {
715703
}
716704

717-
private interface AggregateChangeCreator<T> extends Function<T, RootAggregateChange<T>> {
718-
719-
default RootAggregateChange<T> createAggregateChange(T instance) {
720-
return this.apply(instance);
721-
}
705+
private interface AggregateChangeCreator<T> {
706+
RootAggregateChange<T> createAggregateChange(T instance);
722707
}
723708
}

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@
2929
import java.util.stream.IntStream;
3030
import java.util.stream.Stream;
3131

32-
import org.assertj.core.api.Assertions;
3332
import org.junit.jupiter.api.Test;
3433
import org.springframework.beans.factory.annotation.Autowired;
3534
import org.springframework.context.ApplicationContext;
36-
import org.springframework.context.ApplicationEventPublisher;
3735
import org.springframework.context.annotation.Bean;
3836
import org.springframework.context.annotation.Configuration;
3937
import org.springframework.context.annotation.Import;
@@ -54,7 +52,6 @@
5452
import org.springframework.data.jdbc.testing.TestClass;
5553
import org.springframework.data.jdbc.testing.TestConfiguration;
5654
import org.springframework.data.jdbc.testing.TestDatabaseFeatures;
57-
import org.springframework.data.mapping.callback.EntityCallbacks;
5855
import org.springframework.data.mapping.context.InvalidPersistentPropertyPath;
5956
import org.springframework.data.relational.core.conversion.DbActionExecutionException;
6057
import org.springframework.data.relational.core.mapping.Column;
@@ -1377,20 +1374,20 @@ void mapWithEnumKey() {
13771374
assertThat(enumMapOwners).containsExactly(enumMapOwner);
13781375
}
13791376

1380-
@Test //GH-2064
1377+
@Test //GH-2064
13811378
void saveAllBeforeConvertCallback() {
1382-
var first = new BeforeConvertCallbackForSaveBatch("first");
1383-
var second = new BeforeConvertCallbackForSaveBatch("second");
1384-
var third = new BeforeConvertCallbackForSaveBatch("third");
1379+
1380+
BeforeConvertCallbackForSaveBatch first = new BeforeConvertCallbackForSaveBatch("first");
1381+
BeforeConvertCallbackForSaveBatch second = new BeforeConvertCallbackForSaveBatch("second");
1382+
BeforeConvertCallbackForSaveBatch third = new BeforeConvertCallbackForSaveBatch("third");
13851383

13861384
template.saveAll(List.of(first, second, third));
13871385

1388-
var allEntriesInTable = template.findAll(BeforeConvertCallbackForSaveBatch.class);
1386+
List<BeforeConvertCallbackForSaveBatch> allEntriesInTable = template
1387+
.findAll(BeforeConvertCallbackForSaveBatch.class);
13891388

1390-
Assertions.assertThat(allEntriesInTable)
1391-
.hasSize(3)
1392-
.extracting(BeforeConvertCallbackForSaveBatch::getName)
1393-
.containsOnly("first", "second", "third");
1389+
assertThat(allEntriesInTable).hasSize(3).extracting(BeforeConvertCallbackForSaveBatch::getName)
1390+
.containsExactlyInAnyOrder("first", "second", "third");
13941391
}
13951392

13961393
@Test // GH-1684
@@ -2220,9 +2217,8 @@ public String getId() {
22202217
return id;
22212218
}
22222219

2223-
public BeforeConvertCallbackForSaveBatch setId(String id) {
2220+
public void setId(String id) {
22242221
this.id = id;
2225-
return this;
22262222
}
22272223

22282224
public String getName() {
@@ -2260,12 +2256,14 @@ static class WithIdOnly {
22602256

22612257
@Table
22622258
static class WithInsertOnly {
2259+
22632260
@Id Long id;
22642261
@InsertOnlyProperty String insertOnly;
22652262
}
22662263

22672264
@Table
22682265
static class MultipleCollections {
2266+
22692267
@Id Long id;
22702268
String name;
22712269
List<ListElement> listElements = new ArrayList<>();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /