1 | package com.reallifedeveloper.common.application.notification; | |
2 | ||
3 | import jakarta.persistence.Column; | |
4 | import jakarta.persistence.Entity; | |
5 | import jakarta.persistence.Table; | |
6 | ||
7 | import com.reallifedeveloper.common.domain.ErrorHandling; | |
8 | import com.reallifedeveloper.common.infrastructure.persistence.BaseJpaEntity; | |
9 | ||
10 | /** | |
11 | * Keeps track of the most recently published message on a certain publication channel. | |
12 | * <p> | |
13 | * The publication channel can, for example, be an exchange in a messaging system. | |
14 | * | |
15 | * @author RealLifeDeveloper | |
16 | */ | |
17 | @Entity | |
18 | @Table(name = "message_tracker") | |
19 | public class PublishedMessageTracker extends BaseJpaEntity<Long> { | |
20 | ||
21 | @Column(name = "last_published_message_id", nullable = false, unique = false) | |
22 | private Long lastPublishedMessageId; | |
23 | ||
24 | @Column(name = "publication_channel", nullable = false, unique = true) | |
25 | private String publicationChannel; | |
26 | ||
27 | /** | |
28 | * Creates a new {@code PublishedMessageTracker} with the id of the most recently published message on the given publication channel. | |
29 | * | |
30 | * @param lastPublishedMessageId the id of the most recently published message on the publication channel | |
31 | * @param publicationChannel the name of the publication channel, e.g., the name of an exchange in a messaging system | |
32 | */ | |
33 | public PublishedMessageTracker(long lastPublishedMessageId, String publicationChannel) { | |
34 |
1
1. <init> : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → SURVIVED |
ErrorHandling.checkNull("publicationChannel must not be null", publicationChannel); |
35 | this.lastPublishedMessageId = lastPublishedMessageId; | |
36 | this.publicationChannel = publicationChannel; | |
37 | } | |
38 | ||
39 | /** | |
40 | * Required by JPA. | |
41 | */ | |
42 | /* package-private */ PublishedMessageTracker() { | |
43 | super(); | |
44 | } | |
45 | ||
46 | /** | |
47 | * Gives the id of the most recently published message on the publication channel associated with this {@code PublishedMessageTracker}. | |
48 | * | |
49 | * @return the id of the most recently published message | |
50 | */ | |
51 | public Long lastPublishedMessageId() { | |
52 |
1
1. lastPublishedMessageId : replaced Long return value with 0L for com/reallifedeveloper/common/application/notification/PublishedMessageTracker::lastPublishedMessageId → KILLED |
return lastPublishedMessageId; |
53 | } | |
54 | ||
55 | /** | |
56 | * Sets the id of the most recently published message on the publication channel associated with this {@code PublishedMessageTracker}. | |
57 | * | |
58 | * @param newLastPublishedMessageId the new id of the most recently published message | |
59 | */ | |
60 | public void setLastPublishedMessageid(long newLastPublishedMessageId) { | |
61 | this.lastPublishedMessageId = newLastPublishedMessageId; | |
62 | } | |
63 | ||
64 | /** | |
65 | * Gives the name of the publication channel for this {@code PublishedMessageTracker}. | |
66 | * | |
67 | * @return the name of the publication channel | |
68 | */ | |
69 | public String publicationChannel() { | |
70 |
1
1. publicationChannel : replaced return value with "" for com/reallifedeveloper/common/application/notification/PublishedMessageTracker::publicationChannel → KILLED |
return publicationChannel; |
71 | } | |
72 | ||
73 | } | |
Mutations | ||
34 |
1.1 |
|
52 |
1.1 |
|
70 |
1.1 |