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 376dce4

Browse files
committed
Polishing.
Formatting. Simplification of code. Original pull request #2065 See #2064
1 parent e2c0851 commit 376dce4

File tree

2 files changed

+19
-37
lines changed

2 files changed

+19
-37
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
@@ -27,7 +27,6 @@
2727
import java.util.stream.Collectors;
2828
import java.util.stream.StreamSupport;
2929

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

@@ -80,6 +67,7 @@
8067
* @author Myeonghyeon Lee
8168
* @author Chirag Tailor
8269
* @author Diego Krupitza
70+
* @author Mikhail Polivakha
8371
*/
8472
public class JdbcAggregateTemplate implements JdbcAggregateOperations {
8573

@@ -674,16 +662,13 @@ private <T> T triggerBeforeDelete(@Nullable T aggregateRoot, Object id, MutableA
674662
return null;
675663
}
676664

677-
private record EntityAndPreviousVersion<T>(T entity, @Nullable Number version) {
665+
private record EntityAndPreviousVersion<T>(T entity, @Nullable Number version) {
678666
}
679667

680-
private record EntityAndChangeCreator<T>(T entity, AggregateChangeCreator<T> changeCreator) {
668+
private record EntityAndChangeCreator<T>(T entity, AggregateChangeCreator<T> changeCreator) {
681669
}
682670

683-
private interface AggregateChangeCreator<T> extends Function<T, RootAggregateChange<T>> {
684-
685-
default RootAggregateChange<T> createAggregateChange(T instance) {
686-
return this.apply(instance);
687-
}
671+
private interface AggregateChangeCreator<T> {
672+
RootAggregateChange<T> createAggregateChange(T instance);
688673
}
689674
}

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@
2828
import java.util.function.Function;
2929
import java.util.stream.IntStream;
3030

31-
import org.assertj.core.api.Assertions;
32-
import org.assertj.core.api.SoftAssertions;
3331
import org.junit.jupiter.api.Test;
3432
import org.springframework.beans.factory.annotation.Autowired;
3533
import org.springframework.context.ApplicationContext;
36-
import org.springframework.context.ApplicationEventPublisher;
3734
import org.springframework.context.annotation.Bean;
3835
import org.springframework.context.annotation.Configuration;
3936
import org.springframework.context.annotation.Import;
@@ -54,7 +51,6 @@
5451
import org.springframework.data.jdbc.testing.TestClass;
5552
import org.springframework.data.jdbc.testing.TestConfiguration;
5653
import org.springframework.data.jdbc.testing.TestDatabaseFeatures;
57-
import org.springframework.data.mapping.callback.EntityCallbacks;
5854
import org.springframework.data.mapping.context.InvalidPersistentPropertyPath;
5955
import org.springframework.data.relational.core.conversion.DbActionExecutionException;
6056
import org.springframework.data.relational.core.mapping.Column;
@@ -1332,20 +1328,20 @@ void mapWithEnumKey() {
13321328
assertThat(enumMapOwners).containsExactly(enumMapOwner);
13331329
}
13341330

1335-
@Test //GH-2064
1331+
@Test //GH-2064
13361332
void saveAllBeforeConvertCallback() {
1337-
var first = new BeforeConvertCallbackForSaveBatch("first");
1338-
var second = new BeforeConvertCallbackForSaveBatch("second");
1339-
var third = new BeforeConvertCallbackForSaveBatch("third");
1333+
1334+
BeforeConvertCallbackForSaveBatch first = new BeforeConvertCallbackForSaveBatch("first");
1335+
BeforeConvertCallbackForSaveBatch second = new BeforeConvertCallbackForSaveBatch("second");
1336+
BeforeConvertCallbackForSaveBatch third = new BeforeConvertCallbackForSaveBatch("third");
13401337

13411338
template.saveAll(List.of(first, second, third));
13421339

1343-
var allEntriesInTable = template.findAll(BeforeConvertCallbackForSaveBatch.class);
1340+
List<BeforeConvertCallbackForSaveBatch> allEntriesInTable = template
1341+
.findAll(BeforeConvertCallbackForSaveBatch.class);
13441342

1345-
Assertions.assertThat(allEntriesInTable)
1346-
.hasSize(3)
1347-
.extracting(BeforeConvertCallbackForSaveBatch::getName)
1348-
.containsOnly("first", "second", "third");
1343+
assertThat(allEntriesInTable).hasSize(3).extracting(BeforeConvertCallbackForSaveBatch::getName)
1344+
.containsExactlyInAnyOrder("first", "second", "third");
13491345
}
13501346

13511347
@Test // GH-1684
@@ -2175,9 +2171,8 @@ public String getId() {
21752171
return id;
21762172
}
21772173

2178-
public BeforeConvertCallbackForSaveBatch setId(String id) {
2174+
public void setId(String id) {
21792175
this.id = id;
2180-
return this;
21812176
}
21822177

21832178
public String getName() {
@@ -2215,12 +2210,14 @@ static class WithIdOnly {
22152210

22162211
@Table
22172212
static class WithInsertOnly {
2213+
22182214
@Id Long id;
22192215
@InsertOnlyProperty String insertOnly;
22202216
}
22212217

22222218
@Table
22232219
static class MultipleCollections {
2220+
22242221
@Id Long id;
22252222
String name;
22262223
List<ListElement> listElements = new ArrayList<>();

0 commit comments

Comments
(0)

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