Skip to content

Commit d632d71

Browse files
committed
Changed the access level of AbstractAggregateRoot's methods to public
1 parent ecc4005 commit d632d71

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

src/main/java/org/springframework/data/domain/AbstractAggregateRoot.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*
3232
* @author Oliver Gierke
3333
* @author Christoph Strobl
34+
* @author Mikhail Polivakha
3435
* @since 1.13
3536
*/
3637
public class AbstractAggregateRoot<A extends AbstractAggregateRoot<A>> {
@@ -44,7 +45,7 @@ public class AbstractAggregateRoot<A extends AbstractAggregateRoot<A>> {
4445
* @return the event that has been added.
4546
* @see #andEvent(Object)
4647
*/
47-
protected <T> T registerEvent(T event) {
48+
public <T> T registerEvent(T event) {
4849

4950
Assert.notNull(event, "Domain event must not be null");
5051

@@ -76,7 +77,7 @@ protected Collection<Object> domainEvents() {
7677
* @return the aggregate
7778
*/
7879
@SuppressWarnings("unchecked")
79-
protected final A andEventsFrom(A aggregate) {
80+
public final A andEventsFrom(A aggregate) {
8081

8182
Assert.notNull(aggregate, "Aggregate must not be null");
8283

@@ -95,7 +96,7 @@ protected final A andEventsFrom(A aggregate) {
9596
* @see #registerEvent(Object)
9697
*/
9798
@SuppressWarnings("unchecked")
98-
protected final A andEvent(Object event) {
99+
public final A andEvent(Object event) {
99100

100101
registerEvent(event);
101102

src/main/java/org/springframework/data/repository/core/support/EventPublishingRepositoryProxyPostProcessor.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -138,26 +138,28 @@ private static boolean isDeleteMethod(String methodName) {
138138
* Abstraction of a method on the aggregate root that exposes the events to publish.
139139
*
140140
* @author Oliver Gierke
141+
* @author Mikhail Polivakha
141142
* @since 1.13
142143
*/
143144
static class EventPublishingMethod {
144145

145146
private static Map<Class<?>, EventPublishingMethod> cache = new ConcurrentReferenceHashMap<>();
146147
private static @SuppressWarnings("null") EventPublishingMethod NONE = new EventPublishingMethod(Object.class, null,
147148
null);
148-
private static String ILLEGAL_MODIFCATION = "Aggregate's events were modified during event publication. "
149-
+ "Make sure event listeners obtain a fresh instance of the aggregate before adding further events. "
150-
+ "Additional events found: %s.";
149+
private static final String ILLEGAL_MODIFICATION = "Events of an aggregate '%s' were modified during event publication. "
150+
+ "Make sure event listeners obtain a fresh instance of the aggregate before adding further events. ";
151151

152152
private final Class<?> type;
153153
private final Method publishingMethod;
154154
private final @Nullable Method clearingMethod;
155+
private final IllegalStateException ILLEGAL_MODIFICATION_EXCEPTION;
155156

156157
EventPublishingMethod(Class<?> type, Method publishingMethod, @Nullable Method clearingMethod) {
157158

158159
this.type = type;
159160
this.publishingMethod = publishingMethod;
160161
this.clearingMethod = clearingMethod;
162+
this.ILLEGAL_MODIFICATION_EXCEPTION = new IllegalStateException(ILLEGAL_MODIFICATION.formatted(type.getName()));
161163
}
162164

163165
/**
@@ -216,7 +218,7 @@ public void publishEventsFrom(@Nullable Iterable<?> aggregates, ApplicationEvent
216218

217219
postPublication.removeAll(events);
218220

219-
throw new IllegalStateException(ILLEGAL_MODIFCATION.formatted(postPublication));
221+
throw ILLEGAL_MODIFICATION_EXCEPTION;
220222
}
221223

222224
if (clearingMethod != null) {

src/main/java/org/springframework/data/repository/query/SpelQueryContext.java

-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ public int size() {
285285
Map<String, String> getParameterMap() {
286286
return expressions;
287287
}
288-
289288
}
290289

291290
/**

src/main/java/org/springframework/data/spel/ExpressionDependencies.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static ExpressionDependencies merged(Iterable<ExpressionDependencies> dep
102102
* @return a set of {@link ExpressionDependencies}.
103103
*/
104104
public static ExpressionDependencies discover(Expression expression) {
105-
return expression instanceof SpelExpression ? discover(((SpelExpression) expression).getAST(), true) : none();
105+
return expression instanceof SpelExpression spel ? discover(spel.getAST(), true) : none();
106106
}
107107

108108
/**

0 commit comments

Comments
 (0)