Refactor: move strategies in a package, other minor modification
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package entities;
|
||||
|
||||
import utils.SendNotificationStrategy;
|
||||
import notificationSendingStrategies.SendNotificationStrategy;
|
||||
|
||||
public class MailNotification extends Notification {
|
||||
public MailNotification(String content, User user, SendNotificationStrategy strategy) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package entities;
|
||||
|
||||
import notificationsDecorations.NotificationDecoration;
|
||||
import utils.NotificationState;
|
||||
import utils.SendNotificationStrategy;
|
||||
import notificationSendingStrategies.SendNotificationStrategy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -50,7 +50,6 @@ public abstract class Notification {
|
||||
* PENDING -> SENT
|
||||
* SENT -> READ
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void transitionState() {
|
||||
switch (state) {
|
||||
@@ -61,10 +60,10 @@ public abstract class Notification {
|
||||
|
||||
/**
|
||||
* Generates the content of the notification dynamically with the decoration (if some)
|
||||
* @return
|
||||
* @return content of the notification
|
||||
*/
|
||||
public String getContent() {
|
||||
if (isSendable() && !content.equals("")) {
|
||||
if (isSendable() && !content.isEmpty()) {
|
||||
transitionState();
|
||||
|
||||
for (final NotificationDecoration decoration : decorations)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package entities;
|
||||
|
||||
import utils.SendNotificationStrategy;
|
||||
import notificationSendingStrategies.SendNotificationStrategy;
|
||||
|
||||
public class PushNotification extends Notification {
|
||||
public PushNotification(String content, User user, SendNotificationStrategy strategy) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package entities;
|
||||
|
||||
import utils.SendNotificationStrategy;
|
||||
import notificationSendingStrategies.SendNotificationStrategy;
|
||||
|
||||
public class SmsNotification extends Notification {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package entities;
|
||||
|
||||
import utils.NotificationType;
|
||||
import utils.SendNotificationStrategy;
|
||||
import notificationSendingStrategies.SendNotificationStrategy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package utils;
|
||||
package notificationSendingStrategies;
|
||||
|
||||
public class DifferedSendNotificationStrategy implements SendNotificationStrategy {
|
||||
private int delay;
|
||||
@@ -1,4 +1,4 @@
|
||||
package utils;
|
||||
package notificationSendingStrategies;
|
||||
|
||||
public class FastSendNotificationStrategy implements SendNotificationStrategy {
|
||||
@Override
|
||||
@@ -1,4 +1,4 @@
|
||||
package utils;
|
||||
package notificationSendingStrategies;
|
||||
|
||||
public class SecureSendNotificationStrategy implements SendNotificationStrategy {
|
||||
private int key;
|
||||
@@ -1,4 +1,4 @@
|
||||
package utils;
|
||||
package notificationSendingStrategies;
|
||||
|
||||
public interface SendNotificationStrategy {
|
||||
String makeContent(String message);
|
||||
@@ -1,6 +1,7 @@
|
||||
package utils;
|
||||
|
||||
import entities.*;
|
||||
import notificationSendingStrategies.SendNotificationStrategy;
|
||||
|
||||
public class NotificationFactory {
|
||||
public Notification createNotification(NotificationType type, String content, User user, SendNotificationStrategy strategy) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package utils;
|
||||
|
||||
import entities.User;
|
||||
import notificationSendingStrategies.DifferedSendNotificationStrategy;
|
||||
import notificationSendingStrategies.SecureSendNotificationStrategy;
|
||||
import notificationSendingStrategies.SendNotificationStrategy;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user