Skip to content

Commit 8ab97b9

Browse files
committed
Rename AggregateChangeWithRoot to RootAggregateChange.
1 parent 671074a commit 8ab97b9

16 files changed

+114
-114
lines changed

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.springframework.data.mapping.IdentifierAccessor;
3333
import org.springframework.data.mapping.callback.EntityCallbacks;
3434
import org.springframework.data.relational.core.conversion.AggregateChange;
35-
import org.springframework.data.relational.core.conversion.AggregateChangeWithRoot;
35+
import org.springframework.data.relational.core.conversion.RootAggregateChange;
3636
import org.springframework.data.relational.core.conversion.BatchingAggregateChange;
3737
import org.springframework.data.relational.core.conversion.MutableAggregateChange;
3838
import org.springframework.data.relational.core.conversion.RelationalEntityDeleteWriter;
@@ -292,14 +292,14 @@ private <T> T afterExecute(AggregateChange<T> change, T entityAfterExecution) {
292292
return triggerAfterSave(entityAfterExecution, change);
293293
}
294294

295-
private <T> AggregateChangeWithRoot<T> beforeExecute(T aggregateRoot,
296-
Function<T, AggregateChangeWithRoot<T>> changeCreator) {
295+
private <T> RootAggregateChange<T> beforeExecute(T aggregateRoot,
296+
Function<T, RootAggregateChange<T>> changeCreator) {
297297

298298
Assert.notNull(aggregateRoot, "Aggregate instance must not be null!");
299299

300300
aggregateRoot = triggerBeforeConvert(aggregateRoot);
301301

302-
AggregateChangeWithRoot<T> change = changeCreator.apply(aggregateRoot);
302+
RootAggregateChange<T> change = changeCreator.apply(aggregateRoot);
303303

304304
aggregateRoot = triggerBeforeSave(change.getRoot(), change);
305305

@@ -319,10 +319,10 @@ private <T> void deleteTree(Object id, @Nullable T entity, Class<T> domainType)
319319
triggerAfterDelete(entity, id, change);
320320
}
321321

322-
private <T> T performSave(T instance, Function<T, AggregateChangeWithRoot<T>> changeCreator) {
322+
private <T> T performSave(T instance, Function<T, RootAggregateChange<T>> changeCreator) {
323323

324324
// noinspection unchecked
325-
BatchingAggregateChange<T, AggregateChangeWithRoot<T>> batchingAggregateChange = //
325+
BatchingAggregateChange<T, RootAggregateChange<T>> batchingAggregateChange = //
326326
BatchingAggregateChange.forSave((Class<T>) ClassUtils.getUserClass(instance));
327327
batchingAggregateChange.add(beforeExecute(instance, changeCreator));
328328

@@ -339,7 +339,7 @@ private <T> List<T> performSaveAll(Iterable<T> instances) {
339339
T firstInstance = iterator.next();
340340

341341
// noinspection unchecked
342-
BatchingAggregateChange<T, AggregateChangeWithRoot<T>> batchingAggregateChange = //
342+
BatchingAggregateChange<T, RootAggregateChange<T>> batchingAggregateChange = //
343343
BatchingAggregateChange.forSave((Class<T>) ClassUtils.getUserClass(firstInstance));
344344
batchingAggregateChange.add(beforeExecute(firstInstance, changeCreatorSelectorForSave(firstInstance)));
345345

@@ -358,23 +358,23 @@ private <T> List<T> performSaveAll(Iterable<T> instances) {
358358
return results;
359359
}
360360

361-
private <T> Function<T, AggregateChangeWithRoot<T>> changeCreatorSelectorForSave(T instance) {
361+
private <T> Function<T, RootAggregateChange<T>> changeCreatorSelectorForSave(T instance) {
362362

363363
return context.getRequiredPersistentEntity(instance.getClass()).isNew(instance)
364364
? entity -> createInsertChange(prepareVersionForInsert(entity))
365365
: entity -> createUpdateChange(prepareVersionForUpdate(entity));
366366
}
367367

368-
private <T> AggregateChangeWithRoot<T> createInsertChange(T instance) {
368+
private <T> RootAggregateChange<T> createInsertChange(T instance) {
369369

370-
AggregateChangeWithRoot<T> aggregateChange = MutableAggregateChange.forSave(instance);
370+
RootAggregateChange<T> aggregateChange = MutableAggregateChange.forSave(instance);
371371
new RelationalEntityInsertWriter<T>(context).write(instance, aggregateChange);
372372
return aggregateChange;
373373
}
374374

375-
private <T> AggregateChangeWithRoot<T> createUpdateChange(EntityAndPreviousVersion<T> entityAndVersion) {
375+
private <T> RootAggregateChange<T> createUpdateChange(EntityAndPreviousVersion<T> entityAndVersion) {
376376

377-
AggregateChangeWithRoot<T> aggregateChange = MutableAggregateChange.forSave(entityAndVersion.entity,
377+
RootAggregateChange<T> aggregateChange = MutableAggregateChange.forSave(entityAndVersion.entity,
378378
entityAndVersion.version);
379379
new RelationalEntityUpdateWriter<T>(context).write(entityAndVersion.entity,
380380
aggregateChange);

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

+13-13
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.springframework.data.jdbc.core.convert.JdbcConverter;
4040
import org.springframework.data.mapping.PersistentPropertyPath;
4141
import org.springframework.data.mapping.PersistentPropertyPaths;
42-
import org.springframework.data.relational.core.conversion.AggregateChangeWithRoot;
42+
import org.springframework.data.relational.core.conversion.RootAggregateChange;
4343
import org.springframework.data.relational.core.conversion.DbAction;
4444
import org.springframework.data.relational.core.conversion.IdValueSource;
4545
import org.springframework.data.relational.core.conversion.MutableAggregateChange;
@@ -80,7 +80,7 @@ public class AggregateChangeIdGenerationImmutableUnitTests {
8080
@Test // DATAJDBC-291
8181
public void singleRoot() {
8282

83-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
83+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
8484
aggregateChange.setRootAction(rootInsert);
8585

8686
List<DummyEntity> result = executor.executeSave(aggregateChange);
@@ -94,7 +94,7 @@ public void simpleReference() {
9494

9595
entity = entity.withSingle(content);
9696

97-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
97+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
9898
aggregateChange.setRootAction(rootInsert);
9999
aggregateChange.addAction(createInsert("single", content, null));
100100

@@ -113,7 +113,7 @@ public void listReference() {
113113

114114
entity = entity.withContentList(asList(content, content2));
115115

116-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
116+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
117117
aggregateChange.setRootAction(rootInsert);
118118
aggregateChange.addAction(createInsert("contentList", content, 0));
119119
aggregateChange.addAction(createInsert("contentList", content2, 1));
@@ -133,7 +133,7 @@ public void mapReference() {
133133

134134
entity = entity.withContentMap(createContentMap("a", content, "b", content2));
135135

136-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
136+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
137137
aggregateChange.setRootAction(rootInsert);
138138
aggregateChange.addAction(createInsert("contentMap", content, "a"));
139139
aggregateChange.addAction(createInsert("contentMap", content2, "b"));
@@ -154,7 +154,7 @@ public void setIdForDeepReference() {
154154
DbAction.Insert<?> parentInsert = createInsert("single", content, null);
155155
DbAction.Insert<?> insert = createDeepInsert("single", tag1, null, parentInsert);
156156

157-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
157+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
158158
aggregateChange.setRootAction(rootInsert);
159159
aggregateChange.addAction(parentInsert);
160160
aggregateChange.addAction(insert);
@@ -177,7 +177,7 @@ public void setIdForDeepReferenceElementList() {
177177
DbAction.Insert<?> insert1 = createDeepInsert("tagList", tag1, 0, parentInsert);
178178
DbAction.Insert<?> insert2 = createDeepInsert("tagList", tag2, 1, parentInsert);
179179

180-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
180+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
181181
aggregateChange.setRootAction(rootInsert);
182182
aggregateChange.addAction(parentInsert);
183183
aggregateChange.addAction(insert1);
@@ -204,7 +204,7 @@ public void setIdForDeepElementSetElementSet() {
204204
DbAction.Insert<?> insert1 = createDeepInsert("tagSet", tag1, null, parentInsert);
205205
DbAction.Insert<?> insert2 = createDeepInsert("tagSet", tag2, null, parentInsert);
206206

207-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
207+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
208208
aggregateChange.setRootAction(rootInsert);
209209
aggregateChange.addAction(parentInsert);
210210
aggregateChange.addAction(insert1);
@@ -238,7 +238,7 @@ public void setIdForDeepElementListSingleReference() {
238238
DbAction.Insert<?> insert1 = createDeepInsert("single", tag1, null, parentInsert1);
239239
DbAction.Insert<?> insert2 = createDeepInsert("single", tag2, null, parentInsert2);
240240

241-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
241+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
242242
aggregateChange.setRootAction(rootInsert);
243243
aggregateChange.addAction(parentInsert1);
244244
aggregateChange.addAction(parentInsert2);
@@ -270,7 +270,7 @@ public void setIdForDeepElementListElementList() {
270270
DbAction.Insert<?> insert2 = createDeepInsert("tagList", tag2, 0, parentInsert2);
271271
DbAction.Insert<?> insert3 = createDeepInsert("tagList", tag3, 1, parentInsert2);
272272

273-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
273+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
274274
aggregateChange.setRootAction(rootInsert);
275275
aggregateChange.addAction(parentInsert1);
276276
aggregateChange.addAction(parentInsert2);
@@ -306,7 +306,7 @@ public void setIdForDeepElementMapElementMap() {
306306
DbAction.Insert<?> insert2 = createDeepInsert("tagMap", tag2, "222", parentInsert2);
307307
DbAction.Insert<?> insert3 = createDeepInsert("tagMap", tag3, "333", parentInsert2);
308308

309-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
309+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
310310
aggregateChange.setRootAction(rootInsert);
311311
aggregateChange.addAction(parentInsert1);
312312
aggregateChange.addAction(parentInsert2);
@@ -346,7 +346,7 @@ public void setIdForDeepElementListSingleReferenceWithIntermittentNoId() {
346346
DbAction.Insert<?> insert1 = createDeepInsert("single", tag1, null, parentInsert1);
347347
DbAction.Insert<?> insert2 = createDeepInsert("single", tag2, null, parentInsert2);
348348

349-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
349+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
350350
aggregateChange.setRootAction(rootInsert);
351351
aggregateChange.addAction(parentInsert1);
352352
aggregateChange.addAction(parentInsert2);
@@ -373,7 +373,7 @@ public void setIdForEmbeddedDeepReference() {
373373

374374
DbAction.Insert<?> parentInsert = createInsert("embedded.single", tag1, null);
375375

376-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
376+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
377377
aggregateChange.setRootAction(rootInsert);
378378
aggregateChange.addAction(parentInsert);
379379

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.springframework.data.jdbc.core.convert.JdbcConverter;
3737
import org.springframework.data.mapping.PersistentPropertyPath;
3838
import org.springframework.data.mapping.PersistentPropertyPaths;
39-
import org.springframework.data.relational.core.conversion.AggregateChangeWithRoot;
39+
import org.springframework.data.relational.core.conversion.RootAggregateChange;
4040
import org.springframework.data.relational.core.conversion.DbAction;
4141
import org.springframework.data.relational.core.conversion.IdValueSource;
4242
import org.springframework.data.relational.core.conversion.MutableAggregateChange;
@@ -71,7 +71,7 @@ public class AggregateChangeIdGenerationUnitTests {
7171
@Test // DATAJDBC-291
7272
public void singleRoot() {
7373

74-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
74+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
7575
aggregateChange.setRootAction(rootInsert);
7676

7777
executor.executeSave(aggregateChange);
@@ -84,7 +84,7 @@ public void simpleReference() {
8484

8585
entity.single = content;
8686

87-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
87+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
8888
aggregateChange.setRootAction(rootInsert);
8989
aggregateChange.addAction(createInsert("single", content, null));
9090

@@ -103,7 +103,7 @@ public void listReference() {
103103
entity.contentList.add(content);
104104
entity.contentList.add(content2);
105105

106-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
106+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
107107
aggregateChange.setRootAction(rootInsert);
108108
aggregateChange.addAction(createInsert("contentList", content, 0));
109109
aggregateChange.addAction(createInsert("contentList", content2, 1));
@@ -123,7 +123,7 @@ public void mapReference() {
123123
entity.contentMap.put("a", content);
124124
entity.contentMap.put("b", content2);
125125

126-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
126+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
127127
aggregateChange.setRootAction(rootInsert);
128128
aggregateChange.addAction(createInsert("contentMap", content, "a"));
129129
aggregateChange.addAction(createInsert("contentMap", content2, "b"));
@@ -143,7 +143,7 @@ public void setIdForDeepReference() {
143143
DbAction.Insert<?> parentInsert = createInsert("single", content, null);
144144
DbAction.Insert<?> insert = createDeepInsert("single", tag1, null, parentInsert);
145145

146-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
146+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
147147
aggregateChange.setRootAction(rootInsert);
148148
aggregateChange.addAction(parentInsert);
149149
aggregateChange.addAction(insert);
@@ -166,7 +166,7 @@ public void setIdForDeepReferenceElementList() {
166166
DbAction.Insert<?> insert1 = createDeepInsert("tagList", tag1, 0, parentInsert);
167167
DbAction.Insert<?> insert2 = createDeepInsert("tagList", tag2, 1, parentInsert);
168168

169-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
169+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
170170
aggregateChange.setRootAction(rootInsert);
171171
aggregateChange.addAction(parentInsert);
172172
aggregateChange.addAction(insert1);
@@ -193,7 +193,7 @@ public void setIdForDeepElementSetElementSet() {
193193
DbAction.Insert<?> insert1 = createDeepInsert("tagSet", tag1, null, parentInsert);
194194
DbAction.Insert<?> insert2 = createDeepInsert("tagSet", tag2, null, parentInsert);
195195

196-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
196+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
197197
aggregateChange.setRootAction(rootInsert);
198198
aggregateChange.addAction(parentInsert);
199199
aggregateChange.addAction(insert1);
@@ -227,7 +227,7 @@ public void setIdForDeepElementListSingleReference() {
227227
DbAction.Insert<?> insert1 = createDeepInsert("single", tag1, null, parentInsert1);
228228
DbAction.Insert<?> insert2 = createDeepInsert("single", tag2, null, parentInsert2);
229229

230-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
230+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
231231
aggregateChange.setRootAction(rootInsert);
232232
aggregateChange.addAction(parentInsert1);
233233
aggregateChange.addAction(parentInsert2);
@@ -260,7 +260,7 @@ public void setIdForDeepElementListElementList() {
260260
DbAction.Insert<?> insert2 = createDeepInsert("tagList", tag2, 0, parentInsert2);
261261
DbAction.Insert<?> insert3 = createDeepInsert("tagList", tag3, 1, parentInsert2);
262262

263-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
263+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
264264
aggregateChange.setRootAction(rootInsert);
265265
aggregateChange.addAction(parentInsert1);
266266
aggregateChange.addAction(parentInsert2);
@@ -298,7 +298,7 @@ public void setIdForDeepElementMapElementMap() {
298298
DbAction.Insert<?> insert2 = createDeepInsert("tagMap", tag2, "222", parentInsert2);
299299
DbAction.Insert<?> insert3 = createDeepInsert("tagMap", tag3, "333", parentInsert2);
300300

301-
AggregateChangeWithRoot<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
301+
RootAggregateChange<DummyEntity> aggregateChange = MutableAggregateChange.forSave(entity);
302302
aggregateChange.setRootAction(rootInsert);
303303
aggregateChange.addAction(parentInsert1);
304304
aggregateChange.addAction(parentInsert2);

spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/BatchingAggregateChange.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public interface BatchingAggregateChange<T, C extends MutableAggregateChange<T>>
4141
* @return the {@link BatchingAggregateChange} for saving root entities.
4242
* @since 3.0
4343
*/
44-
static <T> BatchingAggregateChange<T, AggregateChangeWithRoot<T>> forSave(Class<T> entityClass) {
44+
static <T> BatchingAggregateChange<T, RootAggregateChange<T>> forSave(Class<T> entityClass) {
4545

4646
Assert.notNull(entityClass, "Entity class must not be null");
4747

Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* Represents the change happening to the aggregate (as used in the context of Domain Driven Design) as a whole.
2727
*
2828
* @author Chirag Tailor
29-
* @since 2.6
29+
* @since 3.0
3030
*/
31-
class DefaultAggregateChangeWithRoot<T> implements AggregateChangeWithRoot<T> {
31+
class DefaultRootAggregateChange<T> implements RootAggregateChange<T> {
3232

3333
private final Kind kind;
3434

@@ -42,7 +42,7 @@ class DefaultAggregateChangeWithRoot<T> implements AggregateChangeWithRoot<T> {
4242
/** The previous version assigned to the instance being changed, if available */
4343
@Nullable private final Number previousVersion;
4444

45-
public DefaultAggregateChangeWithRoot(Kind kind, Class<T> entityType, @Nullable Number previousVersion) {
45+
public DefaultRootAggregateChange(Kind kind, Class<T> entityType, @Nullable Number previousVersion) {
4646

4747
this.kind = kind;
4848
this.entityType = entityType;

spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/MutableAggregateChange.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,32 @@
3030
public interface MutableAggregateChange<T> extends AggregateChange<T> {
3131

3232
/**
33-
* Factory method to create an {@link AggregateChangeWithRoot} for saving entities.
33+
* Factory method to create a {@link RootAggregateChange} for saving entities.
3434
*
3535
* @param entity aggregate root to save.
3636
* @param <T> entity type.
37-
* @return the {@link AggregateChangeWithRoot} for saving the root {@code entity}.
37+
* @return the {@link RootAggregateChange} for saving the root {@code entity}.
3838
* @since 1.2
3939
*/
40-
static <T> AggregateChangeWithRoot<T> forSave(T entity) {
40+
static <T> RootAggregateChange<T> forSave(T entity) {
4141
return forSave(entity, null);
4242
}
4343

4444
/**
45-
* Factory method to create an {@link AggregateChangeWithRoot} for saving entities.
45+
* Factory method to create a {@link RootAggregateChange} for saving entities.
4646
*
4747
* @param entity aggregate root to save.
4848
* @param previousVersion the previous version assigned to the instance being saved. May be {@literal null}.
4949
* @param <T> entity type.
50-
* @return the {@link AggregateChangeWithRoot} for saving the root {@code entity}.
50+
* @return the {@link RootAggregateChange} for saving the root {@code entity}.
5151
* @since 2.4
5252
*/
5353
@SuppressWarnings("unchecked")
54-
static <T> AggregateChangeWithRoot<T> forSave(T entity, @Nullable Number previousVersion) {
54+
static <T> RootAggregateChange<T> forSave(T entity, @Nullable Number previousVersion) {
5555

5656
Assert.notNull(entity, "Entity must not be null");
5757

58-
return new DefaultAggregateChangeWithRoot<>(Kind.SAVE, (Class<T>) ClassUtils.getUserClass(entity), previousVersion);
58+
return new DefaultRootAggregateChange<>(Kind.SAVE, (Class<T>) ClassUtils.getUserClass(entity), previousVersion);
5959
}
6060

6161
/**

0 commit comments

Comments
 (0)