Fix JDK 21 warnings (#6028)

This commit is contained in:
Tyler Veness
2023-12-09 21:45:02 -08:00
committed by GitHub
parent d40bdd70ba
commit 192a28af47
101 changed files with 164 additions and 57 deletions

View File

@@ -27,6 +27,7 @@ import java.util.function.BooleanSupplier;
public abstract class Command implements Sendable {
protected Set<Subsystem> m_requirements = new HashSet<>();
@SuppressWarnings("this-escape")
protected Command() {
String name = getClass().getName();
SendableRegistry.add(this, name.substring(name.lastIndexOf('.') + 1));

View File

@@ -37,6 +37,7 @@ public class DeferredCommand extends Command {
* omission of command requirements. Use {@link Set#of()} to easily construct a requirement
* set.
*/
@SuppressWarnings("this-escape")
public DeferredCommand(Supplier<Command> supplier, Set<Subsystem> requirements) {
m_supplier = requireNonNullParam(supplier, "supplier", "DeferredCommand");
addRequirements(requirements.toArray(new Subsystem[0]));

View File

@@ -32,6 +32,7 @@ public class FunctionalCommand extends Command {
* @param isFinished the function that determines whether the command has finished
* @param requirements the subsystems required by this command
*/
@SuppressWarnings("this-escape")
public FunctionalCommand(
Runnable onInit,
Runnable onExecute,

View File

@@ -86,6 +86,7 @@ public class MecanumControllerCommand extends Command {
* voltages.
* @param requirements The subsystems to require.
*/
@SuppressWarnings("this-escape")
public MecanumControllerCommand(
Trajectory trajectory,
Supplier<Pose2d> pose,
@@ -229,6 +230,7 @@ public class MecanumControllerCommand extends Command {
* @param outputWheelSpeeds A MecanumDriveWheelSpeeds object containing the output wheel speeds.
* @param requirements The subsystems to require.
*/
@SuppressWarnings("this-escape")
public MecanumControllerCommand(
Trajectory trajectory,
Supplier<Pose2d> pose,

View File

@@ -28,6 +28,7 @@ public class NotifierCommand extends Command {
* @param period the period at which the notifier should run, in seconds
* @param requirements the subsystems required by this command
*/
@SuppressWarnings("this-escape")
public NotifierCommand(Runnable toRun, double period, Subsystem... requirements) {
m_notifier = new Notifier(toRun);
m_period = period;

View File

@@ -24,6 +24,7 @@ public abstract class PIDSubsystem extends SubsystemBase {
* @param controller the PIDController to use
* @param initialPosition the initial setpoint of the subsystem
*/
@SuppressWarnings("this-escape")
public PIDSubsystem(PIDController controller, double initialPosition) {
m_controller = requireNonNullParam(controller, "controller", "PIDSubsystem");
setSetpoint(initialPosition);
@@ -55,7 +56,7 @@ public abstract class PIDSubsystem extends SubsystemBase {
*
* @param setpoint the setpoint for the subsystem
*/
public void setSetpoint(double setpoint) {
public final void setSetpoint(double setpoint) {
m_controller.setSetpoint(setpoint);
}

View File

@@ -56,7 +56,7 @@ public abstract class ProfiledPIDSubsystem extends SubsystemBase {
*
* @param goal The goal state for the subsystem's motion profile.
*/
public void setGoal(TrapezoidProfile.State goal) {
public final void setGoal(TrapezoidProfile.State goal) {
m_controller.setGoal(goal);
}
@@ -65,7 +65,7 @@ public abstract class ProfiledPIDSubsystem extends SubsystemBase {
*
* @param goal The goal position for the subsystem's motion profile.
*/
public void setGoal(double goal) {
public final void setGoal(double goal) {
setGoal(new TrapezoidProfile.State(goal, 0));
}

View File

@@ -35,6 +35,7 @@ public class ProxyCommand extends Command {
*
* @param command the command to run by proxy
*/
@SuppressWarnings("this-escape")
public ProxyCommand(Command command) {
this(() -> command);
setName("Proxy(" + command.getName() + ")");

View File

@@ -70,6 +70,7 @@ public class RamseteCommand extends Command {
* the robot drive.
* @param requirements The subsystems to require.
*/
@SuppressWarnings("this-escape")
public RamseteCommand(
Trajectory trajectory,
Supplier<Pose2d> pose,
@@ -109,6 +110,7 @@ public class RamseteCommand extends Command {
* @param outputMetersPerSecond A function that consumes the computed left and right wheel speeds.
* @param requirements The subsystems to require.
*/
@SuppressWarnings("this-escape")
public RamseteCommand(
Trajectory trajectory,
Supplier<Pose2d> pose,

View File

@@ -29,6 +29,7 @@ public class RepeatCommand extends Command {
*
* @param command the command to run repeatedly
*/
@SuppressWarnings("this-escape")
public RepeatCommand(Command command) {
m_command = requireNonNullParam(command, "command", "RepeatCommand");
CommandScheduler.getInstance().registerComposedCommands(command);

View File

@@ -16,6 +16,7 @@ import edu.wpi.first.util.sendable.SendableRegistry;
*/
public abstract class SubsystemBase implements Subsystem, Sendable {
/** Constructor. */
@SuppressWarnings("this-escape")
public SubsystemBase() {
String name = this.getClass().getSimpleName();
name = name.substring(name.lastIndexOf('.') + 1);

View File

@@ -186,6 +186,7 @@ public class SwerveControllerCommand extends Command {
* @param outputModuleStates The raw output module states from the position controllers.
* @param requirements The subsystems to require.
*/
@SuppressWarnings("this-escape")
public SwerveControllerCommand(
Trajectory trajectory,
Supplier<Pose2d> pose,

View File

@@ -35,6 +35,7 @@ public class TrapezoidProfileCommand extends Command {
* @param currentState The current state
* @param requirements The subsystems required by this command.
*/
@SuppressWarnings("this-escape")
public TrapezoidProfileCommand(
TrapezoidProfile profile,
Consumer<State> output,
@@ -60,6 +61,7 @@ public class TrapezoidProfileCommand extends Command {
* This allows you to change goals at runtime.
*/
@Deprecated(since = "2024", forRemoval = true)
@SuppressWarnings("this-escape")
public TrapezoidProfileCommand(
TrapezoidProfile profile, Consumer<State> output, Subsystem... requirements) {
m_profile = requireNonNullParam(profile, "profile", "TrapezoidProfileCommand");

View File

@@ -74,7 +74,7 @@ public abstract class TrapezoidProfileSubsystem extends SubsystemBase {
*
* @param goal The goal state for the subsystem's motion profile.
*/
public void setGoal(TrapezoidProfile.State goal) {
public final void setGoal(TrapezoidProfile.State goal) {
m_goal = goal;
}
@@ -83,7 +83,7 @@ public abstract class TrapezoidProfileSubsystem extends SubsystemBase {
*
* @param goal The goal position for the subsystem's motion profile.
*/
public void setGoal(double goal) {
public final void setGoal(double goal) {
setGoal(new TrapezoidProfile.State(goal, 0));
}

View File

@@ -22,6 +22,7 @@ public class WaitCommand extends Command {
*
* @param seconds the time to wait, in seconds
*/
@SuppressWarnings("this-escape")
public WaitCommand(double seconds) {
m_duration = seconds;
SendableRegistry.setName(this, getName() + ": " + seconds + " seconds");

View File

@@ -23,6 +23,7 @@ public abstract class WrapperCommand extends Command {
* @param command the command being wrapped. Trying to directly schedule this command or add it to
* a composition will throw an exception.
*/
@SuppressWarnings("this-escape")
protected WrapperCommand(Command command) {
CommandScheduler.getInstance().registerComposedCommands(command);
m_command = command;