Skip to content

Instantly share code, notes, and snippets.

@HDBandit
Created May 22, 2016 15:56
Show Gist options
  • Save HDBandit/e0e461624cf77cb0647bde8df55b4454 to your computer and use it in GitHub Desktop.
Save HDBandit/e0e461624cf77cb0647bde8df55b4454 to your computer and use it in GitHub Desktop.
public class RobotCommand {
private String command;
private ArrayList<String> arguments;
protected RobotCommand() {
this.arguments = new ArrayList<String>();
}
public RobotCommand cmd(String command) {
this.command = command;
return this;
}
public RobotCommand arg(String argument) {
this.arguments.add(argument);
return this;
}
public String getCommand() {
return command;
}
public List<String> getArguments() {
return arguments;
}
public static void execute(Consumer<RobotCommand> request) {
System.out.println("Establishing robot conection...");
System.out.println("Set robot on status READY");
RobotCommand robotCmd = new RobotCommand();
request.accept(robotCmd);
StringBuilder params = new StringBuilder();
robotCmd.getArguments().stream().forEach(arg -> params.append(arg + " "));
System.out.println(String.format("Execute robot command: %s %s", robotCmd.getCommand(), params));
System.out.println("Set robot on status IDLE");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment