| 1 | package com.reallifedeveloper.common.application.notification; | |
| 2 | ||
| 3 | import java.util.List; | |
| 4 | ||
| 5 | import com.reallifedeveloper.common.application.eventstore.EventStore; | |
| 6 | import com.reallifedeveloper.common.application.eventstore.StoredEvent; | |
| 7 | import com.reallifedeveloper.common.domain.ErrorHandling; | |
| 8 | import com.reallifedeveloper.common.domain.event.DomainEvent; | |
| 9 | ||
| 10 | /** | |
| 11 | * A factory for {@link Notification Notifications}. | |
| 12 | * | |
| 13 | * @author RealLifeDeveloper | |
| 14 | */ | |
| 15 | public final class NotificationFactory { | |
| 16 | ||
| 17 | private final EventStore eventStore; | |
| 18 | ||
| 19 | private NotificationFactory(EventStore eventStore) { | |
| 20 |
1
1. <init> : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED |
ErrorHandling.checkNull("eventStore must not be null", eventStore); |
| 21 | this.eventStore = eventStore; | |
| 22 | } | |
| 23 | ||
| 24 | /** | |
| 25 | * Gives an instance of the factory that uses the given {@link EventStore} to create {@link Notification Notifications}. | |
| 26 | * | |
| 27 | * @param eventStore the {@code EventStore} to use | |
| 28 | * | |
| 29 | * @return a {@code NotificationFactory} instance | |
| 30 | */ | |
| 31 | public static NotificationFactory instance(EventStore eventStore) { | |
| 32 |
1
1. instance : replaced return value with null for com/reallifedeveloper/common/application/notification/NotificationFactory::instance → KILLED |
return new NotificationFactory(eventStore); |
| 33 | } | |
| 34 | ||
| 35 | /** | |
| 36 | * Creates a new {@link Notification} for the given {@link StoredEvent}. | |
| 37 | * | |
| 38 | * @param storedEvent the stored event for which to create a {@code Notification} | |
| 39 | * | |
| 40 | * @return a new {@code Notification} for the stored event | |
| 41 | */ | |
| 42 | public Notification fromStoredEvent(StoredEvent storedEvent) { | |
| 43 |
1
1. fromStoredEvent : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED |
ErrorHandling.checkNull("storedEvent must not be null", storedEvent); |
| 44 |
1
1. fromStoredEvent : negated conditional → KILLED |
if (storedEvent.id() == null) { |
| 45 | throw new IllegalArgumentException("storedEvent has null ID -- has it not yet been saved? storedEvent=" + storedEvent); | |
| 46 | } | |
| 47 | DomainEvent domainEvent = eventStore.toDomainEvent(storedEvent); | |
| 48 |
1
1. fromStoredEvent : replaced return value with null for com/reallifedeveloper/common/application/notification/NotificationFactory::fromStoredEvent → KILLED |
return Notification.create(domainEvent, storedEvent.id()); |
| 49 | } | |
| 50 | ||
| 51 | /** | |
| 52 | * Creates new {@link Notification Notifications} for the given {@link StoredEvent StoredEvents}. | |
| 53 | * | |
| 54 | * @param storedEvents a list with the stored events for which to create {@code Notifications} | |
| 55 | * | |
| 56 | * @return a list of {@code Notifications} for the stored events | |
| 57 | */ | |
| 58 | public List<Notification> fromStoredEvents(List<StoredEvent> storedEvents) { | |
| 59 |
1
1. fromStoredEvents : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED |
ErrorHandling.checkNull("storedEvents must not be null", storedEvents); |
| 60 |
1
1. fromStoredEvents : replaced return value with Collections.emptyList for com/reallifedeveloper/common/application/notification/NotificationFactory::fromStoredEvents → KILLED |
return storedEvents.stream().map(this::fromStoredEvent).toList(); |
| 61 | } | |
| 62 | } | |
Mutations | ||
| 20 |
1.1 |
|
| 32 |
1.1 |
|
| 43 |
1.1 |
|
| 44 |
1.1 |
|
| 48 |
1.1 |
|
| 59 |
1.1 |
|
| 60 |
1.1 |