Clean up Command container iteration code (#73)

This commit is contained in:
Tyler Veness
2018-06-23 19:41:45 -05:00
committed by Peter Johnson
parent ea7d11b1db
commit b7807bf9d2
9 changed files with 198 additions and 226 deletions

View File

@@ -7,7 +7,7 @@
package edu.wpi.first.wpilibj.command;
import java.util.Enumeration;
import java.util.Collections;
import edu.wpi.first.wpilibj.Sendable;
import edu.wpi.first.wpilibj.SendableBase;
@@ -93,17 +93,7 @@ public abstract class Subsystem extends SendableBase {
if (command == null) {
m_defaultCommand = null;
} else {
boolean found = false;
Enumeration requirements = command.getRequirements();
while (requirements.hasMoreElements()) {
if (requirements.nextElement().equals(this)) {
found = true;
// } else {
// throw new
// IllegalUseOfCommandException("A default command cannot require multiple subsystems");
}
}
if (!found) {
if (!Collections.list(command.getRequirements()).contains(this)) {
throw new IllegalUseOfCommandException("A default command must require the subsystem");
}
m_defaultCommand = command;