nyla.solutions.commas.CommandThread Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nyla.solutions.commas Show documentation
Show all versions of nyla.solutions.commas Show documentation
Command pattern implementation for building services.
The newest version!
/**
*
*/
package nyla.solutions.commas;
import nyla.solutions.core.exception.RequiredException;
/**
* @author Gregory Green
*
*/
public class CommandThread extends Thread implements Runnable, Command
{
public CommandThread()
{
}// ------------------------------------------------
public CommandThread(Command cmd, InputType argument)
{
this.command = cmd;
this.argument = argument;
}// ------------------------------------------------
/* (non-Javadoc)
* @see solutions.global.patterns.command.Command#execute(java.lang.Object)
*/
public ReturnType execute(InputType source)
{
if (this.command == null)
throw new RequiredException("this.command");
return this.command.execute(this.argument);
}// ------------------------------------------------
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run()
{
if(this.command == null)
throw new RequiredException("this.command");
results = this.command.execute(argument);
}// ------------------------------------------------
/**
* @return the results
*/
public Object getResults()
{
return results;
}
/**
* @param results the results to set
*/
public void setResults(ReturnType results)
{
this.results = results;
}
/**
* @return the argument
*/
public Object getArgument()
{
return argument;
}
/**
* @param argument the argument to set
*/
public void setArgument(InputType argument)
{
this.argument = argument;
}
/**
* @return the command
*/
public Command getCommand()
{
return command;
}
/**
* @param command the command to set
*/
public void setCommand(Command command)
{
this.command = command;
}
private ReturnType results = null;
private InputType argument = null;
private Command command = null;
}