Feat: Decorator and facade implemented
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 19s

This commit is contained in:
Namu
2025-10-06 09:50:55 +02:00
parent d868ec63c9
commit 381e3cc9ac
11 changed files with 140 additions and 42 deletions

View File

@@ -1,11 +1,17 @@
package entities;
import notificationsDecorations.NotificationDecoration;
import utils.NotificationState;
import utils.SendNotificationStrategy;
import java.util.ArrayList;
import java.util.List;
public abstract class Notification {
protected String content;
protected User user;
protected List<NotificationDecoration> decorations;
/**
* Pas de change state car chemin multiple. On reste sur des enum !
*/
@@ -17,6 +23,15 @@ public abstract class Notification {
this.user = user;
this.state = NotificationState.PENDING;
this.strategy = strategy;
this.decorations = new ArrayList<>();
}
/**
* Adds a decoration to the notification. Please use a decorator for that
* @param decoration
*/
public void addDecoration(NotificationDecoration decoration) {
decorations.add(decoration);
}
protected boolean isSendable() {
@@ -41,9 +56,19 @@ public abstract class Notification {
}
public String getContent() {
if (isSendable()) {
if (isSendable() && content != "") {
transitionState();
return strategy.makeContent(user.id() + " Push: " + user.name() + " " + content);
StringBuilder builder = new StringBuilder();
if (decorations.isEmpty())
return content;
builder.append(content);
for (final NotificationDecoration decoration : decorations)
builder.append(decoration.transformContent());
return builder.toString();
}
setKoState();
return "";