- java.lang.Object
-
- io.github.interacto.command.CommandImpl
-
- io.github.interacto.command.library.AnonymousCommand
-
- All Implemented Interfaces:
Command
public class AnonymousCommand extends CommandImpl
An anonymous class that permits to create a command without defining a specific ActionImpl class. A runnable, corresponding to the body of the command has to be provided to the cmd.- Author:
- Arnaud Blouin
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.github.interacto.command.Command
Command.CmdStatus, Command.RegistrationPolicy
-
-
Field Summary
Fields Modifier and Type Field Description protected RunnablecmdBodyThe runnable executed when the command is executed.-
Fields inherited from class io.github.interacto.command.CommandImpl
status
-
-
Constructor Summary
Constructors Constructor Description AnonymousCommand()Create the command.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanDo()Checks whether the command can be executed.protected voiddoCmdBody()This method contains the statements to execute the command.RunnablegetCmdBody()voidsetCmdBody(Runnable body)Sets the runnable of the command.-
Methods inherited from class io.github.interacto.command.CommandImpl
cancel, createMemento, doIt, done, flush, getRegistrationPolicy, getStatus, hadEffect, isDone, toString, unregisteredBy
-
-
-
-
Field Detail
-
cmdBody
protected Runnable cmdBody
The runnable executed when the command is executed.
-
-
Method Detail
-
doCmdBody
protected void doCmdBody()
Description copied from class:CommandImplThis method contains the statements to execute the command. This method is automatically called by DoIt and must not be called explicitly.- Specified by:
doCmdBodyin classCommandImpl
-
canDo
public boolean canDo()
Description copied from interface:CommandChecks whether the command can be executed.- Specified by:
canDoin interfaceCommand- Overrides:
canDoin classCommandImpl- Returns:
- True if the command can be executed.
-
setCmdBody
public void setCmdBody(Runnable body)
Sets the runnable of the command.- Parameters:
body- The runnable executed when the command is executed.
-
getCmdBody
public Runnable getCmdBody()
- Returns:
- The runnable of the command.
-
-