mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Use Java 17 features (#6691)
Uses enhanced instanceof (and simplify equals methods) Uses switch expressions and arrow labels Seal and finalize some Shuffleboard classes Co-authored-by: Sam Carlberg <sam@slfc.dev>
This commit is contained in:
@@ -394,14 +394,8 @@ public class ChassisSpeeds implements ProtobufSerializable, StructSerializable {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof ChassisSpeeds)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ChassisSpeeds c = (ChassisSpeeds) o;
|
||||
|
||||
return vxMetersPerSecond == c.vxMetersPerSecond
|
||||
return o instanceof ChassisSpeeds c
|
||||
&& vxMetersPerSecond == c.vxMetersPerSecond
|
||||
&& vyMetersPerSecond == c.vyMetersPerSecond
|
||||
&& omegaRadiansPerSecond == c.omegaRadiansPerSecond;
|
||||
}
|
||||
|
||||
@@ -53,12 +53,9 @@ public class DifferentialDriveWheelPositions
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof DifferentialDriveWheelPositions) {
|
||||
DifferentialDriveWheelPositions other = (DifferentialDriveWheelPositions) obj;
|
||||
return Math.abs(other.leftMeters - leftMeters) < 1E-9
|
||||
&& Math.abs(other.rightMeters - rightMeters) < 1E-9;
|
||||
}
|
||||
return false;
|
||||
return obj instanceof DifferentialDriveWheelPositions other
|
||||
&& Math.abs(other.leftMeters - leftMeters) < 1E-9
|
||||
&& Math.abs(other.rightMeters - rightMeters) < 1E-9;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,14 +79,11 @@ public class MecanumDriveWheelPositions
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof MecanumDriveWheelPositions) {
|
||||
MecanumDriveWheelPositions other = (MecanumDriveWheelPositions) obj;
|
||||
return Math.abs(other.frontLeftMeters - frontLeftMeters) < 1E-9
|
||||
&& Math.abs(other.frontRightMeters - frontRightMeters) < 1E-9
|
||||
&& Math.abs(other.rearLeftMeters - rearLeftMeters) < 1E-9
|
||||
&& Math.abs(other.rearRightMeters - rearRightMeters) < 1E-9;
|
||||
}
|
||||
return false;
|
||||
return obj instanceof MecanumDriveWheelPositions other
|
||||
&& Math.abs(other.frontLeftMeters - frontLeftMeters) < 1E-9
|
||||
&& Math.abs(other.frontRightMeters - frontRightMeters) < 1E-9
|
||||
&& Math.abs(other.rearLeftMeters - rearLeftMeters) < 1E-9
|
||||
&& Math.abs(other.rearRightMeters - rearRightMeters) < 1E-9;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,11 +61,9 @@ public class SwerveModulePosition
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof SwerveModulePosition) {
|
||||
SwerveModulePosition other = (SwerveModulePosition) obj;
|
||||
return Math.abs(other.distanceMeters - distanceMeters) < 1E-9 && angle.equals(other.angle);
|
||||
}
|
||||
return false;
|
||||
return obj instanceof SwerveModulePosition other
|
||||
&& Math.abs(other.distanceMeters - distanceMeters) < 1E-9
|
||||
&& angle.equals(other.angle);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,12 +57,9 @@ public class SwerveModuleState
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof SwerveModuleState) {
|
||||
SwerveModuleState other = (SwerveModuleState) obj;
|
||||
return Math.abs(other.speedMetersPerSecond - speedMetersPerSecond) < 1E-9
|
||||
&& angle.equals(other.angle);
|
||||
}
|
||||
return false;
|
||||
return obj instanceof SwerveModuleState other
|
||||
&& Math.abs(other.speedMetersPerSecond - speedMetersPerSecond) < 1E-9
|
||||
&& angle.equals(other.angle);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user