RoboticsTeam4904 / standard

Command Based Git Submodule
BSD 3-Clause "New" or "Revised" License
11 stars 3 forks source link

Update the Run<x> suite of commands #249

Closed b-cho closed 4 years ago

b-cho commented 4 years ago

Change the Run commands to work with the new system, and updated Noop() to be usable with the new versions. I still need to verify the following things, however:

b-cho commented 4 years ago

Note that we can convert Set<Subsystem> this.command.getRequirements() to Subsystem[] using the following line of code:

(Subsystem[]) this.command.getRequirements().toArray().

This can be passed into functions like addRequirements(), which require a Subsystem[] input instead of a Set.


Furthermore, the names of commands can be concatenated into one string with separator " " by using the following line of code (where commands is of type Command[]):

Arrays.stream(commands).map((Command command) -> command.getName()).collect(Collectors.joining(" ")). (returns type String).

This maps commands to type Stream<Command>, then uses a lambda function via Stream.map to extract the names of each command (making the new type a Stream<String>). We then use Stream.collect to concatenate the strings in the stream using Collectors.joining(" "), combining them with a space delimiter. In other words, the commands array goes through the following types:

Command[] -> Stream<Command> -> Stream<String> -> String