Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
* @author Oliver Gierke
* @author Christoph Strobl
* @author Mikhail Polivakha
* @since 1.13
*/
public class AbstractAggregateRoot<A extends AbstractAggregateRoot<A>> {
Expand All @@ -44,7 +45,7 @@ public class AbstractAggregateRoot<A extends AbstractAggregateRoot<A>> {
* @return the event that has been added.
* @see #andEvent(Object)
*/
protected <T> T registerEvent(T event) {
public <T> T registerEvent(T event) {

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

Expand Down Expand Up @@ -76,7 +77,7 @@ protected Collection<Object> domainEvents() {
* @return the aggregate
*/
@SuppressWarnings("unchecked")
protected final A andEventsFrom(A aggregate) {
public final A andEventsFrom(A aggregate) {

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

Expand All @@ -95,7 +96,7 @@ protected final A andEventsFrom(A aggregate) {
* @see #registerEvent(Object)
*/
@SuppressWarnings("unchecked")
protected final A andEvent(Object event) {
public final A andEvent(Object event) {

registerEvent(event);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,28 @@ private static boolean isDeleteMethod(String methodName) {
* Abstraction of a method on the aggregate root that exposes the events to publish.
*
* @author Oliver Gierke
* @author Mikhail Polivakha
* @since 1.13
*/
static class EventPublishingMethod {

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

private final Class<?> type;
private final Method publishingMethod;
private final @Nullable Method clearingMethod;
private final IllegalStateException ILLEGAL_MODIFICATION_EXCEPTION;

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

this.type = type;
this.publishingMethod = publishingMethod;
this.clearingMethod = clearingMethod;
this.ILLEGAL_MODIFICATION_EXCEPTION = new IllegalStateException(ILLEGAL_MODIFICATION.formatted(type.getName()));
}

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

postPublication.removeAll(events);

throw new IllegalStateException(ILLEGAL_MODIFCATION.formatted(postPublication));
throw ILLEGAL_MODIFICATION_EXCEPTION;
}

if (clearingMethod != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ public int size() {
Map<String, String> getParameterMap() {
return expressions;
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static ExpressionDependencies merged(Iterable<ExpressionDependencies> dep
* @return a set of {@link ExpressionDependencies}.
*/
public static ExpressionDependencies discover(Expression expression) {
return expression instanceof SpelExpression ? discover(((SpelExpression) expression).getAST(), true) : none();
return expression instanceof SpelExpression spel ? discover(spel.getAST(), true) : none();
}

/**
Expand Down