22 package com.realtime.crossfire.jxclient.gui.commandlist;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import org.jetbrains.annotations.NotNull;
44 private final Collection<GUICommand>
commandList =
new ArrayList<>();
59 commandList.add(guiCommand);
67 switch (commandListType) {
70 if (!command.canExecute()) {
79 if (command.canExecute()) {
111 final StringBuilder sb =
new StringBuilder();
112 boolean firstCommand =
true;
113 for (
final GUICommand guiCommand : commandList) {
115 throw new AssertionError(
"Cannot encode command of type "+guiCommand.getClass().getName());
117 final String commandString = ((GUICommand2)guiCommand).getCommandString();
119 firstCommand =
false;
123 sb.append(commandString);
125 return sb.toString();
CommandList(@NotNull final CommandListType commandListType)
Creates a new instance as an empty command list.
boolean canExecute()
Returns whether execution is possible.
A GUICommand that has a string representation.
final CommandListType commandListType
The command list type.
void add(@NotNull final GUICommand guiCommand)
Adds a command to the end of this command list.
String getCommandString()
Returns the commands as a string.
void execute()
Executes the command.
final Collection< GUICommand > commandList
The list of GUICommands in execution order.
A list of GUICommand instances.
void execute()
Execute the command list by calling GUICommand#execute() for each command in order.