org.perfectjpattern.core.behavioral.command
Class Command<P,R>

java.lang.Object
  extended by org.perfectjpattern.core.behavioral.command.Command<P,R>
Type Parameters:
P - Command Parameter context-specific.
R - Command Result context-specific.
All Implemented Interfaces:
ICommand<P,R>
Direct Known Subclasses:
ParameterlessCommand

public class Command<P,R>
extends Object
implements ICommand<P,R>

Base core implementation of ICommand interface.

Version:
$Revision: 1.0 $ $Date: Jun 23, 2007 3:00:54 AM $
Author:
Giovanni Azua
See Also:
ICommand
 

Constructor Summary
Command()
           
Command(IReceiver<P,R> aReceiver)
           
 
Method Summary
 void execute()
          Executes the ICommand.
 R getResult()
          Returns the result of this ICommand execution.
 void setParameter(P aParameter)
          Sets the parameter required for the execution of the target IReceiver.
 void setReceiver(IReceiver<P,R> aReceiver)
          Sets the IReceiver associated to this ICommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Command

public Command()

Command

public Command(IReceiver<P,R> aReceiver)
Method Detail

getResult

public R getResult()
            throws IllegalStateException
Returns the result of this ICommand execution.

Specified by:
getResult in interface ICommand<P,R>
Returns:
Result of this ICommand execution.
Throws:
IllegalStateException - IReceiver was not set.

setParameter

public void setParameter(P aParameter)
                  throws IllegalArgumentException
Sets the parameter required for the execution of the target IReceiver.

Specified by:
setParameter in interface ICommand<P,R>
Parameters:
aParameter - Parameter required for the execution of the target IReceiver.
Throws:
IllegalArgumentException - 'aParameter' must not be null.

setReceiver

public void setReceiver(IReceiver<P,R> aReceiver)
                 throws IllegalArgumentException
Sets the IReceiver associated to this ICommand

Specified by:
setReceiver in interface ICommand<P,R>
Parameters:
aReceiver - to set
Throws:
IllegalArgumentException - 'aReceiver' must not be null.

execute

public void execute()
             throws IllegalStateException
Executes the ICommand.

Specified by:
execute in interface ICommand<P,R>
Throws:
IllegalStateException - IReceiver was not set.


Copyright © 2007-2009. All Rights Reserved.