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:
Gold856
2024-06-05 00:09:10 -04:00
committed by GitHub
parent d6b66bfa55
commit b99d9c1710
95 changed files with 957 additions and 1594 deletions

View File

@@ -156,8 +156,8 @@ public abstract class MotorEncoderFixture<T extends MotorController> implements
public void teardown() {
if (!m_tornDown) {
if (m_motor != null) {
if (m_motor instanceof PWM) {
((PWM) m_motor).close();
if (m_motor instanceof PWM motor) {
motor.close();
}
m_motor = null;
}

View File

@@ -106,7 +106,7 @@ public abstract class AbstractComsSetup {
protected void failed(Throwable throwable, Description description, String status) {
TestBench.out().println();
// Instance of is the best way I know to retrieve this data.
if (throwable instanceof MultipleFailureException) {
if (throwable instanceof MultipleFailureException mfe) {
/*
* MultipleFailureExceptions hold multiple exceptions in one exception.
* In order to properly display these stack traces we have to cast the
@@ -114,8 +114,8 @@ public abstract class AbstractComsSetup {
* it.
*/
int exceptionCount = 1; // Running exception count
int failureCount = ((MultipleFailureException) throwable).getFailures().size();
for (Throwable singleThrown : ((MultipleFailureException) throwable).getFailures()) {
int failureCount = mfe.getFailures().size();
for (Throwable singleThrown : mfe.getFailures()) {
getClassLogger()
.logp(
Level.SEVERE,