|
16 | 16 |
|
17 | 17 | package org.springframework.data.ebean.domain; |
18 | 18 |
|
19 | | -import org.springframework.data.domain.AfterDomainEventPublication; |
20 | | -import org.springframework.data.domain.DomainEvents; |
21 | | -import org.springframework.util.Assert; |
22 | | - |
23 | | -import javax.persistence.MappedSuperclass; |
24 | | -import javax.persistence.Transient; |
25 | 19 | import java.util.ArrayList; |
26 | 20 | import java.util.Collection; |
27 | 21 | import java.util.Collections; |
28 | 22 | import java.util.List; |
| 23 | +import javax.persistence.MappedSuperclass; |
| 24 | +import javax.persistence.Transient; |
| 25 | +import org.springframework.data.domain.AfterDomainEventPublication; |
| 26 | +import org.springframework.data.domain.DomainEvents; |
| 27 | +import org.springframework.util.Assert; |
29 | 28 |
|
30 | 29 | /** |
31 | 30 | * Abstract base class for aggregate root, aggregate extends {@link AbstractEntity} and add |
|
35 | 34 | */ |
36 | 35 | @MappedSuperclass |
37 | 36 | public abstract class AbstractAggregateRoot extends AbstractEntity { |
38 | | - @Transient |
39 | | - private transient final List<DomainEvent> domainEvents = new ArrayList<>(); |
| 37 | + @Transient |
| 38 | + private transient final List<DomainEvent> domainEvents = new ArrayList<>(); |
40 | 39 |
|
41 | | - /** |
42 | | - * Registers the given event object for publication on a call to a Spring Data repository's save methods. |
43 | | - * |
44 | | - * @param event must not be {@literal null}. |
45 | | - * @return the event that has been added. |
46 | | - */ |
47 | | - protected <T extends DomainEvent> T registerEvent(T event) { |
48 | | - Assert.notNull(event, "Domain event must not be null!"); |
| 40 | + /** |
| 41 | + * Registers the given event object for publication on a call to a Spring Data repository's save methods. |
| 42 | + * |
| 43 | + * @param event must not be {@literal null}. |
| 44 | + * @return the event that has been added. |
| 45 | + */ |
| 46 | + protected <T extends DomainEvent> T registerEvent(T event) { |
| 47 | + Assert.notNull(event, "Domain event must not be null!"); |
49 | 48 |
|
50 | | - this.domainEvents.add(event); |
51 | | - return event; |
52 | | - } |
| 49 | + this.domainEvents.add(event); |
| 50 | + return event; |
| 51 | + } |
53 | 52 |
|
54 | | - /** |
55 | | - * Clears all domain events currently held. Usually invoked by the infrastructure in place in Spring Data |
56 | | - * repositories. |
57 | | - */ |
58 | | - @AfterDomainEventPublication |
59 | | - protected void clearDomainEvents() { |
60 | | - this.domainEvents.clear(); |
61 | | - } |
| 53 | + /** |
| 54 | + * Clears all domain events currently held. Usually invoked by the infrastructure in place in Spring Data |
| 55 | + * repositories. |
| 56 | + */ |
| 57 | + @AfterDomainEventPublication |
| 58 | + protected void clearDomainEvents() { |
| 59 | + this.domainEvents.clear(); |
| 60 | + } |
62 | 61 |
|
63 | | - /** |
64 | | - * All domain events currently captured by the aggregate. |
65 | | - */ |
66 | | - @DomainEvents |
67 | | - protected Collection<DomainEvent> domainEvents() { |
68 | | - return Collections.unmodifiableList(domainEvents); |
69 | | - } |
| 62 | + /** |
| 63 | + * All domain events currently captured by the aggregate. |
| 64 | + */ |
| 65 | + @DomainEvents |
| 66 | + protected Collection<DomainEvent> domainEvents() { |
| 67 | + return Collections.unmodifiableList(domainEvents); |
| 68 | + } |
70 | 69 |
|
71 | 70 | } |
0 commit comments