Created
May 22, 2016 15:56
-
-
Save HDBandit/e0e461624cf77cb0647bde8df55b4454 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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