Refactor: move strategies in a package, other minor modification

This commit is contained in:
Namu
2025-10-06 11:02:38 +02:00
parent 48136c1b7d
commit 9e3b3cdf58
11 changed files with 15 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
package entities; package entities;
import utils.SendNotificationStrategy; import notificationSendingStrategies.SendNotificationStrategy;
public class MailNotification extends Notification { public class MailNotification extends Notification {
public MailNotification(String content, User user, SendNotificationStrategy strategy) { public MailNotification(String content, User user, SendNotificationStrategy strategy) {

View File

@@ -2,7 +2,7 @@ package entities;
import notificationsDecorations.NotificationDecoration; import notificationsDecorations.NotificationDecoration;
import utils.NotificationState; import utils.NotificationState;
import utils.SendNotificationStrategy; import notificationSendingStrategies.SendNotificationStrategy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -50,7 +50,6 @@ public abstract class Notification {
* PENDING -> SENT * PENDING -> SENT
* SENT -> READ * SENT -> READ
* *
*
*/ */
public void transitionState() { public void transitionState() {
switch (state) { switch (state) {
@@ -61,10 +60,10 @@ public abstract class Notification {
/** /**
* Generates the content of the notification dynamically with the decoration (if some) * Generates the content of the notification dynamically with the decoration (if some)
* @return * @return content of the notification
*/ */
public String getContent() { public String getContent() {
if (isSendable() && !content.equals("")) { if (isSendable() && !content.isEmpty()) {
transitionState(); transitionState();
for (final NotificationDecoration decoration : decorations) for (final NotificationDecoration decoration : decorations)

View File

@@ -1,6 +1,6 @@
package entities; package entities;
import utils.SendNotificationStrategy; import notificationSendingStrategies.SendNotificationStrategy;
public class PushNotification extends Notification { public class PushNotification extends Notification {
public PushNotification(String content, User user, SendNotificationStrategy strategy) { public PushNotification(String content, User user, SendNotificationStrategy strategy) {

View File

@@ -1,6 +1,6 @@
package entities; package entities;
import utils.SendNotificationStrategy; import notificationSendingStrategies.SendNotificationStrategy;
public class SmsNotification extends Notification { public class SmsNotification extends Notification {

View File

@@ -1,7 +1,7 @@
package entities; package entities;
import utils.NotificationType; import utils.NotificationType;
import utils.SendNotificationStrategy; import notificationSendingStrategies.SendNotificationStrategy;
import java.util.List; import java.util.List;

View File

@@ -1,4 +1,4 @@
package utils; package notificationSendingStrategies;
public class DifferedSendNotificationStrategy implements SendNotificationStrategy { public class DifferedSendNotificationStrategy implements SendNotificationStrategy {
private int delay; private int delay;

View File

@@ -1,4 +1,4 @@
package utils; package notificationSendingStrategies;
public class FastSendNotificationStrategy implements SendNotificationStrategy { public class FastSendNotificationStrategy implements SendNotificationStrategy {
@Override @Override

View File

@@ -1,4 +1,4 @@
package utils; package notificationSendingStrategies;
public class SecureSendNotificationStrategy implements SendNotificationStrategy { public class SecureSendNotificationStrategy implements SendNotificationStrategy {
private int key; private int key;

View File

@@ -1,4 +1,4 @@
package utils; package notificationSendingStrategies;
public interface SendNotificationStrategy { public interface SendNotificationStrategy {
String makeContent(String message); String makeContent(String message);

View File

@@ -1,6 +1,7 @@
package utils; package utils;
import entities.*; import entities.*;
import notificationSendingStrategies.SendNotificationStrategy;
public class NotificationFactory { public class NotificationFactory {
public Notification createNotification(NotificationType type, String content, User user, SendNotificationStrategy strategy) { public Notification createNotification(NotificationType type, String content, User user, SendNotificationStrategy strategy) {

View File

@@ -1,6 +1,9 @@
package utils; package utils;
import entities.User; import entities.User;
import notificationSendingStrategies.DifferedSendNotificationStrategy;
import notificationSendingStrategies.SecureSendNotificationStrategy;
import notificationSendingStrategies.SendNotificationStrategy;
import java.util.Arrays; import java.util.Arrays;