org.puremvc.java.patterns.observer.Notifier Maven / Gradle / Ivy
Show all versions of PureMVC Show documentation
//
// PureMVC Java Standard
//
// Copyright(c) 2019 Saad Shams
// Your reuse is governed by the Creative Commons Attribution 3.0 License
//
package org.puremvc.java.patterns.observer;
import org.puremvc.java.interfaces.IFacade;
import org.puremvc.java.interfaces.INotifier;
import org.puremvc.java.patterns.facade.Facade;
/**
* A Base INotifier
implementation.
*
* MacroCommand, Command, Mediator
and Proxy
all
* have a need to send Notifications
.
*
* The INotifier
interface provides a common method called
* sendNotification
that relieves implementation code of the
* necessity to actually construct Notifications
.
*
* The Notifier
class, which all of the above mentioned classes
* extend, provides an initialized reference to the Facade
* Singleton, which is required for the convienience method for sending
* Notifications
, but also eases implementation as these classes
* have frequent Facade
interactions and usually require access
* to the facade anyway.
*
* @see Facade Facade
* @see org.puremvc.java.patterns.mediator.Mediator Mediator
* @see org.puremvc.java.patterns.proxy.Proxy Proxy
* @see org.puremvc.java.patterns.command.SimpleCommand SimpleCommand
* @see org.puremvc.java.patterns.command.MacroCommand MacroCommand
*/
public class Notifier implements INotifier {
/**
* Local reference to the Facade Singleton
*/
protected IFacade facade = Facade.getInstance(()-> new Facade());
/**
* Send an INotification
s.
*
* Keeps us from having to construct new notification instances in our
* implementation code.
*
* @param notificationName the name of the notiification to send
* @param body the body of the notification
* @param type the type of the notification
*/
public void sendNotification(String notificationName, Object body, String type) {
facade.sendNotification(notificationName, body, type);
}
/**
* Send an INotification
s.
*
* Keeps us from having to construct new notification instances in our
* implementation code.
*
* @param notificationName the name of the notiification to send
* @param body the body of the notification
*/
public void sendNotification(String notificationName, Object body) {
facade.sendNotification(notificationName, body);
}
/**
* Send an INotification
s.
*
* Keeps us from having to construct new notification instances in our
* implementation code.
*
* @param notificationName the name of the notiification to send
*/
public void sendNotification(String notificationName) {
facade.sendNotification(notificationName);
}
}