Package org.puremvc.java.interfaces
Interface IController
- All Known Implementing Classes:
Controller
public interface IController
The interface definition for a PureMVC Controller.
In PureMVC, an IController implementor
follows the 'Command and Controller' strategy, and
assumes these responsibilities:
- Remembering which
ICommands are intended to handle whichINotifications. - Registering itself as an
IObserverwith theViewfor eachINotificationthat it has anICommandmapping for. - Creating a new instance of the proper
ICommandto handle a givenINotificationwhen notified by theView. - Calling the
ICommand'sexecutemethod, passing in theINotification.
- See Also:
INotification,ICommand
-
Method Summary
Modifier and Type Method Description voidexecuteCommand(INotification notification)Execute theICommandpreviously registered as the handler forINotifications with the given notification name.booleanhasCommand(java.lang.String notificationName)Check if a Command is registered for a given NotificationvoidregisterCommand(java.lang.String notificationName, java.util.function.Supplier<ICommand> commandSupplier)Register a particularICommandclass as the handler for a particularINotification.voidremoveCommand(java.lang.String notificationName)Remove a previously registeredICommandtoINotificationmapping.
-
Method Details
-
registerCommand
void registerCommand(java.lang.String notificationName, java.util.function.Supplier<ICommand> commandSupplier)Register a particular
ICommandclass as the handler for a particularINotification.- Parameters:
notificationName- the name of theINotificationcommandSupplier- the Supplier Function of theICommand
-
executeCommand
Execute the
ICommandpreviously registered as the handler forINotifications with the given notification name.- Parameters:
notification- theINotificationto execute the associatedICommandfor
-
removeCommand
void removeCommand(java.lang.String notificationName)Remove a previously registered
ICommandtoINotificationmapping.- Parameters:
notificationName- the name of theINotificationto remove theICommandmapping for
-
hasCommand
boolean hasCommand(java.lang.String notificationName)Check if a Command is registered for a given Notification
- Parameters:
notificationName- notification name- Returns:
- whether a Command is currently registered for the given
notificationName.
-