[commands] Make requirements private (#6769)

This commit is contained in:
Jade
2024-07-12 21:51:21 +08:00
committed by GitHub
parent 967105568c
commit 19c28c2a76
5 changed files with 5 additions and 4 deletions

View File

@@ -30,7 +30,7 @@ import java.util.function.BooleanSupplier;
*/
public abstract class Command implements Sendable {
/** Requirements set. */
protected Set<Subsystem> m_requirements = new HashSet<>();
private final Set<Subsystem> m_requirements = new HashSet<>();
/** Default constructor. */
@SuppressWarnings("this-escape")

View File

@@ -50,7 +50,7 @@ public class ParallelCommandGroup extends Command {
CommandScheduler.getInstance().registerComposedCommands(commands);
for (Command command : commands) {
if (!Collections.disjoint(command.getRequirements(), m_requirements)) {
if (!Collections.disjoint(command.getRequirements(), getRequirements())) {
throw new IllegalArgumentException(
"Multiple commands in a parallel composition cannot require the same subsystems");
}

View File

@@ -80,7 +80,7 @@ public class ParallelDeadlineGroup extends Command {
CommandScheduler.getInstance().registerComposedCommands(commands);
for (Command command : commands) {
if (!Collections.disjoint(command.getRequirements(), m_requirements)) {
if (!Collections.disjoint(command.getRequirements(), getRequirements())) {
throw new IllegalArgumentException(
"Multiple commands in a parallel group cannot require the same subsystems");
}

View File

@@ -51,7 +51,7 @@ public class ParallelRaceGroup extends Command {
CommandScheduler.getInstance().registerComposedCommands(commands);
for (Command command : commands) {
if (!Collections.disjoint(command.getRequirements(), m_requirements)) {
if (!Collections.disjoint(command.getRequirements(), getRequirements())) {
throw new IllegalArgumentException(
"Multiple commands in a parallel composition cannot require the same subsystems");
}

View File

@@ -484,6 +484,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
protected:
Command();
private:
/// Requirements set.
wpi::SmallSet<Subsystem*, 4> m_requirements;