1 | package com.reallifedeveloper.common.application.notification; | |
2 | ||
3 | import java.util.List; | |
4 | import java.util.Optional; | |
5 | ||
6 | import org.checkerframework.checker.nullness.qual.Nullable; | |
7 | ||
8 | import com.reallifedeveloper.common.domain.ErrorHandling; | |
9 | ||
10 | /** | |
11 | * A notification log holds a list of {@link Notification Notifications}, i.e., information about domain events that have occurred and have | |
12 | * been stored in an {@link com.reallifedeveloper.common.application.eventstore.EventStore}. | |
13 | * <p> | |
14 | * A notification log may be <i>archived</i>, which means that it will never change. If a log is archived, it means that the ID of the log | |
15 | * will always refer to the current list of {@link Notification Notifications}. If it is not archived, the only change that may occur is | |
16 | * that more notifications are added to it; the notifications themselves represent historical events that have already occurred, so they are | |
17 | * immutable. | |
18 | * | |
19 | * @param current the ID of the current notification log, must not be {@code null} | |
20 | * @param nullableNext the ID of the next notification log, may be {@code null} | |
21 | * @param nullablePrevious the ID of the previous notification log, may be {@code null} | |
22 | * @param notifications the list of notifications in this notification log, must not be {@code null} | |
23 | * @param isArchived if {@code true}, this notification log is archived, i.e., it will never change | |
24 | * | |
25 | * @author RealLifeDeveloper | |
26 | */ | |
27 | public record NotificationLog(NotificationLogId current, @Nullable NotificationLogId nullableNext, | |
28 | @Nullable NotificationLogId nullablePrevious, List<Notification> notifications, boolean isArchived) { | |
29 | ||
30 | /** | |
31 | * Creates a new {@code NotificationLog}. | |
32 | */ | |
33 | public NotificationLog { | |
34 | ErrorHandling.checkNull("Arguments must not be null: current=%s, notifications=%s", current, notifications); | |
35 | notifications = List.copyOf(notifications); | |
36 | } | |
37 | ||
38 | /** | |
39 | * Gives the ID of the next notification log as a {@code java.util.Optional}. | |
40 | * | |
41 | * @return the ID of the next notification log | |
42 | */ | |
43 | public Optional<NotificationLogId> next() { | |
44 |
1
1. next : replaced return value with Optional.empty for com/reallifedeveloper/common/application/notification/NotificationLog::next → KILLED |
return Optional.ofNullable(nullableNext); |
45 | } | |
46 | ||
47 | /** | |
48 | * Gives the ID of the previous notification log as a {@code java.util.Optional}. | |
49 | * | |
50 | * @return the ID of the previous notification log | |
51 | */ | |
52 | public Optional<NotificationLogId> previous() { | |
53 |
1
1. previous : replaced return value with Optional.empty for com/reallifedeveloper/common/application/notification/NotificationLog::previous → RUN_ERROR |
return Optional.ofNullable(nullablePrevious); |
54 | } | |
55 | } | |
Mutations | ||
44 |
1.1 |
|
53 |
1.1 |