Doc: add documentation and change the message

This commit is contained in:
Namu
2025-10-06 10:55:12 +02:00
parent 160e5d2740
commit 48136c1b7d
2 changed files with 14 additions and 6 deletions

View File

@@ -28,7 +28,7 @@ public abstract class Notification {
/** /**
* Adds a decoration to the notification. Please use a decorator for that * Adds a decoration to the notification. Please use a decorator for that
* @param decoration * @param decoration The decoration you want to add
*/ */
public void addDecoration(NotificationDecoration decoration) { public void addDecoration(NotificationDecoration decoration) {
decorations.add(decoration); decorations.add(decoration);
@@ -39,14 +39,18 @@ public abstract class Notification {
} }
/** /**
* Transition d'état spéciale pour indiquer que l'envoie de notification est en échec * Set KO state on notification
*/ */
public void setKoState() { public void setKoState() {
state = NotificationState.KO; state = NotificationState.KO;
} }
/** /**
* Fait la transition des états * Make state transition
* PENDING -> SENT
* SENT -> READ
*
*
*/ */
public void transitionState() { public void transitionState() {
switch (state) { switch (state) {
@@ -55,14 +59,18 @@ public abstract class Notification {
} }
} }
/**
* Generates the content of the notification dynamically with the decoration (if some)
* @return
*/
public String getContent() { public String getContent() {
if (isSendable() && content != "") { if (isSendable() && !content.equals("")) {
transitionState(); transitionState();
for (final NotificationDecoration decoration : decorations) for (final NotificationDecoration decoration : decorations)
content = decoration.transformContent(content); content = decoration.transformContent(content);
return content; return strategy.makeContent(content);
} }
setKoState(); setKoState();
return ""; return "";

View File

@@ -24,6 +24,6 @@ public class SendNotificationFacade {
notificationManager.getObservable().addSubscribers(thomas); notificationManager.getObservable().addSubscribers(thomas);
notificationManager.getObservable().addSubscribers(alexandre); notificationManager.getObservable().addSubscribers(alexandre);
notificationManager.getObservable().sendNotifications("C# > Java (mais Rust c'est le goat)"); notificationManager.getObservable().sendNotifications("Je préfère C#");
} }
} }