You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
592 B
25 lines
592 B
package mock.model.commandFactory;
|
|
|
|
import java.util.Queue;
|
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
|
|
|
/**
|
|
* Wraps multiple commands into a composite to execute queued commands during a frame.
|
|
*/
|
|
public class CompositeCommand implements Command {
|
|
private Queue<Command> commands;
|
|
|
|
public CompositeCommand() {
|
|
this.commands = new ConcurrentLinkedDeque<>();
|
|
}
|
|
|
|
public void addCommand(Command command) {
|
|
commands.offer(command);
|
|
}
|
|
|
|
@Override
|
|
public void execute() {
|
|
while(commands.peek() != null) commands.poll().execute();
|
|
}
|
|
}
|