org.puremvc.java.interfaces.IController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of PureMVC Show documentation
Show all versions of PureMVC Show documentation
PureMVC is a lightweight framework for creating applications
based upon the classic Model-View-Controller design
meta-pattern. This is the specific implementation for the Java
language. It does not support modular programming since it
uses Singletons as Core actors rather than the Multiton used in
the MultiCore Version.
The newest version!
//
// PureMVC Java Standard
//
// Copyright(c) 2019 Saad Shams
// Your reuse is governed by the Creative Commons Attribution 3.0 License
//
package org.puremvc.java.interfaces;
import java.util.function.Supplier;
/**
* The interface definition for a PureMVC Controller.
*
* In PureMVC, an IController
implementor
* follows the 'Command and Controller' strategy, and
* assumes these responsibilities:
*
*
* - Remembering which
ICommand
s
* are intended to handle which INotifications
.
* - Registering itself as an
IObserver
with
* the View
for each INotification
* that it has an ICommand
mapping for.
* - Creating a new instance of the proper
ICommand
* to handle a given INotification
when notified by the View
.
* - Calling the
ICommand
's execute
* method, passing in the INotification
.
*
*
* @see org.puremvc.java.interfaces INotification
* @see org.puremvc.java.interfaces ICommand
*/
public interface IController {
/**
* Register a particular ICommand
class as the handler
* for a particular INotification
.
*
* @param notificationName the name of the INotification
* @param commandSupplier the Supplier Function of the ICommand
*/
void registerCommand(String notificationName, Supplier commandSupplier);
/**
* Execute the ICommand
previously registered as the
* handler for INotification
s with the given notification name.
*
* @param notification the INotification
to execute the associated ICommand
for
*/
void executeCommand(INotification notification);
/**
* Remove a previously registered ICommand
to INotification
mapping.
*
* @param notificationName the name of the INotification
to remove the ICommand
mapping for
*/
void removeCommand(String notificationName);
/**
* Check if a Command is registered for a given Notification
*
* @param notificationName notification name
* @return whether a Command is currently registered for the given notificationName
.
*/
boolean hasCommand(String notificationName);
}