Skip to content

Commit 1fb404a

Browse files
committed
DATAJDBC-400 - Polishing.
Add version since which deprecations are in place. Inline variables. Original pull request: #164.
1 parent af3b9f8 commit 1fb404a

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

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

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,7 @@ private <T> T store(T aggregateRoot, Function<T, AggregateChange<T>> changeCreat
301301

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

304-
aggregateRoot = triggerBeforeConvert(aggregateRoot,
305-
persistentEntity.getIdentifierAccessor(aggregateRoot).getIdentifier());
304+
aggregateRoot = triggerBeforeConvert(aggregateRoot);
306305

307306
AggregateChange<T> change = changeCreator.apply(aggregateRoot);
308307

@@ -376,26 +375,19 @@ private <T> Iterable<T> triggerAfterLoad(Iterable<T> all) {
376375

377376
private <T> T triggerAfterLoad(Object id, T entity) {
378377

379-
Specified identifier = Identifier.of(id);
380-
381-
publisher.publishEvent(new AfterLoadEvent(identifier, entity));
378+
publisher.publishEvent(new AfterLoadEvent(Identifier.of(id), entity));
382379

383380
return entityCallbacks.callback(AfterLoadCallback.class, entity);
384381
}
385382

386-
private <T> T triggerBeforeConvert(T aggregateRoot, @Nullable Object id) {
387-
388-
Identifier identifier = Identifier.ofNullable(id);
389-
383+
private <T> T triggerBeforeConvert(T aggregateRoot) {
390384
return entityCallbacks.callback(BeforeConvertCallback.class, aggregateRoot);
391385
}
392386

393387
private <T> T triggerBeforeSave(T aggregateRoot, @Nullable Object id, AggregateChange<T> change) {
394388

395-
Identifier identifier = Identifier.ofNullable(id);
396-
397389
publisher.publishEvent(new BeforeSaveEvent( //
398-
identifier, //
390+
Identifier.ofNullable(id), //
399391
aggregateRoot, //
400392
change //
401393
));
@@ -418,9 +410,7 @@ private <T> T triggerAfterSave(T aggregateRoot, Object id, AggregateChange<T> ch
418410

419411
private <T> void triggerAfterDelete(@Nullable T aggregateRoot, Object id, AggregateChange<?> change) {
420412

421-
Specified identifier = Identifier.of(id);
422-
423-
publisher.publishEvent(new AfterDeleteEvent(identifier, Optional.ofNullable(aggregateRoot), change));
413+
publisher.publishEvent(new AfterDeleteEvent(Identifier.of(id), Optional.ofNullable(aggregateRoot), change));
424414

425415
if (aggregateRoot != null) {
426416
entityCallbacks.callback(AfterDeleteCallback.class, aggregateRoot);
@@ -430,9 +420,7 @@ private <T> void triggerAfterDelete(@Nullable T aggregateRoot, Object id, Aggreg
430420
@Nullable
431421
private <T> T triggerBeforeDelete(@Nullable T aggregateRoot, Object id, AggregateChange<?> change) {
432422

433-
Specified identifier = Identifier.of(id);
434-
435-
publisher.publishEvent(new BeforeDeleteEvent(identifier, Optional.ofNullable(aggregateRoot), change));
423+
publisher.publishEvent(new BeforeDeleteEvent(Identifier.of(id), Optional.ofNullable(aggregateRoot), change));
436424

437425
if (aggregateRoot != null) {
438426
return entityCallbacks.callback(BeforeDeleteCallback.class, aggregateRoot, change);

spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/RelationalEventWithId.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public RelationalEventWithId(Specified id, Optional<?> entity, @Nullable Aggrega
4242
/**
4343
* Events with an identifier will always return a {@link Specified} one.
4444
*
45-
* @deprecated obtain the id from the entity instead.
45+
* @deprecated since 1.1, obtain the id from the entity instead.
4646
*/
4747
@Override
4848
@Deprecated

spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/SimpleRelationalEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class SimpleRelationalEvent extends ApplicationEvent implements RelationalEvent
4444
}
4545

4646
/**
47-
* @deprecated obtain the id from the entity instead.
47+
* @deprecated since 1.1, obtain the id from the entity instead.
4848
*/
4949
@Override
5050
@Deprecated
@@ -64,7 +64,7 @@ public Optional<Object> getOptionalEntity() {
6464
/**
6565
* Returns the an {@link AggregateChange} instance representing the SQL statements performed by the action that
6666
* triggered this event.
67-
*
67+
*
6868
* @return Guaranteed to be not {@literal null}.
6969
* @deprecated There is currently no replacement for this. If something like this is required please create an issue
7070
* outlining your use case.

0 commit comments

Comments
 (0)