Refactor: move strategies in a package, other minor modification
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package entities;
|
package entities;
|
||||||
|
|
||||||
import utils.SendNotificationStrategy;
|
import notificationSendingStrategies.SendNotificationStrategy;
|
||||||
|
|
||||||
public class SmsNotification extends Notification {
|
public class SmsNotification extends Notification {
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils;
|
package notificationSendingStrategies;
|
||||||
|
|
||||||
public class DifferedSendNotificationStrategy implements SendNotificationStrategy {
|
public class DifferedSendNotificationStrategy implements SendNotificationStrategy {
|
||||||
private int delay;
|
private int delay;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils;
|
package notificationSendingStrategies;
|
||||||
|
|
||||||
public class FastSendNotificationStrategy implements SendNotificationStrategy {
|
public class FastSendNotificationStrategy implements SendNotificationStrategy {
|
||||||
@Override
|
@Override
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils;
|
package notificationSendingStrategies;
|
||||||
|
|
||||||
public class SecureSendNotificationStrategy implements SendNotificationStrategy {
|
public class SecureSendNotificationStrategy implements SendNotificationStrategy {
|
||||||
private int key;
|
private int key;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package utils;
|
package notificationSendingStrategies;
|
||||||
|
|
||||||
public interface SendNotificationStrategy {
|
public interface SendNotificationStrategy {
|
||||||
String makeContent(String message);
|
String makeContent(String message);
|
||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user