1 | package com.reallifedeveloper.common.domain.event; | |
2 | ||
3 | import java.util.ArrayList; | |
4 | import java.util.Collections; | |
5 | import java.util.List; | |
6 | ||
7 | /** | |
8 | * A {@link DomainEventSubscriber} that saves all events in memory. | |
9 | * | |
10 | * @author RealLifeDeveloper | |
11 | */ | |
12 | public class EventSavingSubscriber implements DomainEventSubscriber<DomainEvent> { | |
13 | ||
14 | private final List<DomainEvent> events = new ArrayList<>(); | |
15 | ||
16 | @Override | |
17 | public void handleEvent(DomainEvent event) { | |
18 | events.add(event); | |
19 | ||
20 | } | |
21 | ||
22 | @Override | |
23 | public Class<? extends DomainEvent> eventType() { | |
24 |
1
1. eventType : replaced return value with null for com/reallifedeveloper/common/domain/event/EventSavingSubscriber::eventType → KILLED |
return DomainEvent.class; |
25 | } | |
26 | ||
27 | /** | |
28 | * Gives an unmodifiable list of the events that have been handled so far. | |
29 | * | |
30 | * @return a list of the events that have been handled. | |
31 | */ | |
32 | public List<DomainEvent> events() { | |
33 |
1
1. events : replaced return value with Collections.emptyList for com/reallifedeveloper/common/domain/event/EventSavingSubscriber::events → KILLED |
return Collections.unmodifiableList(events); |
34 | } | |
35 | ||
36 | /** | |
37 | * Removes all handled events. | |
38 | */ | |
39 | public void clear() { | |
40 |
1
1. clear : removed call to java/util/List::clear → KILLED |
events.clear(); |
41 | } | |
42 | ||
43 | } | |
Mutations | ||
24 |
1.1 |
|
33 |
1.1 |
|
40 |
1.1 |