mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[commands] Mark command group lifecycle methods as final (#4385)
This prevents accidental footguns due to overriding of command group lifecycle methods.
This commit is contained in:
@@ -54,7 +54,7 @@ public class ParallelCommandGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
public final void initialize() {
|
||||
for (Map.Entry<Command, Boolean> commandRunning : m_commands.entrySet()) {
|
||||
commandRunning.getKey().initialize();
|
||||
commandRunning.setValue(true);
|
||||
@@ -62,7 +62,7 @@ public class ParallelCommandGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
public final void execute() {
|
||||
for (Map.Entry<Command, Boolean> commandRunning : m_commands.entrySet()) {
|
||||
if (!commandRunning.getValue()) {
|
||||
continue;
|
||||
@@ -76,7 +76,7 @@ public class ParallelCommandGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
public final void end(boolean interrupted) {
|
||||
if (interrupted) {
|
||||
for (Map.Entry<Command, Boolean> commandRunning : m_commands.entrySet()) {
|
||||
if (commandRunning.getValue()) {
|
||||
@@ -87,7 +87,7 @@ public class ParallelCommandGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
public final boolean isFinished() {
|
||||
return !m_commands.containsValue(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ParallelDeadlineGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
public final void initialize() {
|
||||
for (Map.Entry<Command, Boolean> commandRunning : m_commands.entrySet()) {
|
||||
commandRunning.getKey().initialize();
|
||||
commandRunning.setValue(true);
|
||||
@@ -85,7 +85,7 @@ public class ParallelDeadlineGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
public final void execute() {
|
||||
for (Map.Entry<Command, Boolean> commandRunning : m_commands.entrySet()) {
|
||||
if (!commandRunning.getValue()) {
|
||||
continue;
|
||||
@@ -102,7 +102,7 @@ public class ParallelDeadlineGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
public final void end(boolean interrupted) {
|
||||
for (Map.Entry<Command, Boolean> commandRunning : m_commands.entrySet()) {
|
||||
if (commandRunning.getValue()) {
|
||||
commandRunning.getKey().end(true);
|
||||
@@ -111,7 +111,7 @@ public class ParallelDeadlineGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
public final boolean isFinished() {
|
||||
return m_finished;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ParallelRaceGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
public final void initialize() {
|
||||
m_finished = false;
|
||||
for (Command command : m_commands) {
|
||||
command.initialize();
|
||||
@@ -63,7 +63,7 @@ public class ParallelRaceGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
public final void execute() {
|
||||
for (Command command : m_commands) {
|
||||
command.execute();
|
||||
if (command.isFinished()) {
|
||||
@@ -73,14 +73,14 @@ public class ParallelRaceGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
public final void end(boolean interrupted) {
|
||||
for (Command command : m_commands) {
|
||||
command.end(!command.isFinished());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
public final boolean isFinished() {
|
||||
return m_finished;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SequentialCommandGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
public final void initialize() {
|
||||
m_currentCommandIndex = 0;
|
||||
|
||||
if (!m_commands.isEmpty()) {
|
||||
@@ -57,7 +57,7 @@ public class SequentialCommandGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
public final void execute() {
|
||||
if (m_commands.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class SequentialCommandGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
public final void end(boolean interrupted) {
|
||||
if (interrupted
|
||||
&& !m_commands.isEmpty()
|
||||
&& m_currentCommandIndex > -1
|
||||
@@ -86,7 +86,7 @@ public class SequentialCommandGroup extends CommandGroupBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
public final boolean isFinished() {
|
||||
return m_currentCommandIndex == m_commands.size();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user