mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Fix JDK 21 warnings (#6028)
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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]));
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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() + ")");
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user