1 | package com.reallifedeveloper.common.resource.notification; | |
2 | ||
3 | import java.util.ArrayList; | |
4 | import java.util.Collections; | |
5 | import java.util.List; | |
6 | ||
7 | import org.checkerframework.checker.nullness.qual.Nullable; | |
8 | ||
9 | import jakarta.xml.bind.annotation.XmlAccessType; | |
10 | import jakarta.xml.bind.annotation.XmlAccessorType; | |
11 | import jakarta.xml.bind.annotation.XmlElement; | |
12 | import jakarta.xml.bind.annotation.XmlElementWrapper; | |
13 | import jakarta.xml.bind.annotation.XmlRootElement; | |
14 | ||
15 | import com.reallifedeveloper.common.application.notification.Notification; | |
16 | import com.reallifedeveloper.common.application.notification.NotificationLog; | |
17 | import com.reallifedeveloper.common.domain.ErrorHandling; | |
18 | import com.reallifedeveloper.common.domain.ObjectSerializer; | |
19 | ||
20 | /** | |
21 | * A REST-ful representation of a {@link NotificationLog}, containing links to resources to get related representations. | |
22 | * | |
23 | * @author RealLifeDeveloper | |
24 | */ | |
25 | @XmlRootElement(name = "NotificationLog") | |
26 | @XmlAccessorType(XmlAccessType.FIELD) | |
27 | public final class NotificationLogRepresentation { | |
28 | ||
29 | @XmlElement(name = "next") | |
30 | private @Nullable String next; | |
31 | ||
32 | @XmlElement(name = "self") | |
33 | private @Nullable String self; | |
34 | ||
35 | @XmlElement(name = "previous") | |
36 | private @Nullable String previous; | |
37 | ||
38 | @XmlElement(name = "isArchived") | |
39 | private boolean isArchived; | |
40 | ||
41 | @XmlElementWrapper(name = "notifications") | |
42 | @XmlElement(name = "notification") | |
43 | private final List<NotificationRepresentation> notifications = new ArrayList<>(); | |
44 | ||
45 | /** | |
46 | * Creates a new {@code NotificationLogRepresentation} representing the given {@link NotificationLog}, and using the given | |
47 | * {@link ObjectSerializer} to serialize the domain events. | |
48 | * | |
49 | * @param notificationLog the notification log to represent | |
50 | * @param objectSerializer the object serializer to use to serialize domain events | |
51 | */ | |
52 | public NotificationLogRepresentation(NotificationLog notificationLog, ObjectSerializer<String> objectSerializer) { | |
53 |
1
1. <init> : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED |
ErrorHandling.checkNull("Arguments must not be null: notificationLog=%s, objectSerializer=%s", notificationLog, objectSerializer); |
54 | for (Notification notification : notificationLog.notifications()) { | |
55 | notifications.add(new NotificationRepresentation(notification, objectSerializer)); | |
56 | } | |
57 | this.isArchived = notificationLog.isArchived(); | |
58 | } | |
59 | ||
60 | /** | |
61 | * Required by JAXB. | |
62 | */ | |
63 | /* package-private */ NotificationLogRepresentation() { | |
64 | super(); | |
65 | } | |
66 | ||
67 | /** | |
68 | * Gives a canonical link to the current set of notifications. | |
69 | * | |
70 | * @return a canonical link to the current set of notifications | |
71 | */ | |
72 | public @Nullable String getSelf() { | |
73 |
1
1. getSelf : replaced return value with "" for com/reallifedeveloper/common/resource/notification/NotificationLogRepresentation::getSelf → KILLED |
return self; |
74 | } | |
75 | ||
76 | /** | |
77 | * Sets the canonical link to the current set of notifications. | |
78 | * | |
79 | * @param self a canonical link to the current set of notifications | |
80 | */ | |
81 | public void setSelf(String self) { | |
82 | this.self = self; | |
83 | } | |
84 | ||
85 | /** | |
86 | * Gives a canonical link to the next set of notifications. | |
87 | * | |
88 | * @return a canonical link to the next set of notifications | |
89 | */ | |
90 | public @Nullable String getNext() { | |
91 |
1
1. getNext : replaced return value with "" for com/reallifedeveloper/common/resource/notification/NotificationLogRepresentation::getNext → KILLED |
return next; |
92 | } | |
93 | ||
94 | /** | |
95 | * Sets the canonical link to the next set of notifications. | |
96 | * | |
97 | * @param next a canonical link to the next set of notifications | |
98 | */ | |
99 | public void setNext(String next) { | |
100 | this.next = next; | |
101 | } | |
102 | ||
103 | /** | |
104 | * Gives a canonical link to the previous set of notifications. | |
105 | * | |
106 | * @return a canonical link to the previous set of notifications | |
107 | */ | |
108 | public @Nullable String getPrevious() { | |
109 |
1
1. getPrevious : replaced return value with "" for com/reallifedeveloper/common/resource/notification/NotificationLogRepresentation::getPrevious → KILLED |
return previous; |
110 | } | |
111 | ||
112 | /** | |
113 | * Sets the canonical link to the previous set of notifications. | |
114 | * | |
115 | * @param previous a canonical link to the previous set of notifications | |
116 | */ | |
117 | public void setPrevious(String previous) { | |
118 | this.previous = previous; | |
119 | } | |
120 | ||
121 | /** | |
122 | * Gives the notifications represented. | |
123 | * | |
124 | * @return the notifications represented | |
125 | */ | |
126 | public List<NotificationRepresentation> notifications() { | |
127 |
1
1. notifications : replaced return value with Collections.emptyList for com/reallifedeveloper/common/resource/notification/NotificationLogRepresentation::notifications → KILLED |
return Collections.unmodifiableList(notifications); |
128 | } | |
129 | ||
130 | /** | |
131 | * Shows if this represents an archived notification log or not. | |
132 | * | |
133 | * @return {@code true} if this represents an archived notification log, {@code false} otherwise | |
134 | */ | |
135 | public boolean isArchived() { | |
136 |
2
1. isArchived : replaced boolean return with false for com/reallifedeveloper/common/resource/notification/NotificationLogRepresentation::isArchived → KILLED 2. isArchived : replaced boolean return with true for com/reallifedeveloper/common/resource/notification/NotificationLogRepresentation::isArchived → KILLED |
return isArchived; |
137 | } | |
138 | ||
139 | } | |
Mutations | ||
53 |
1.1 |
|
73 |
1.1 |
|
91 |
1.1 |
|
109 |
1.1 |
|
127 |
1.1 |
|
136 |
1.1 2.2 |