mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +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:
@@ -179,8 +179,8 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
*/
|
||||
public BooleanTopic getBooleanTopic(String name) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof BooleanTopic) {
|
||||
return (BooleanTopic) topic;
|
||||
if (topic instanceof BooleanTopic t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
int handle;
|
||||
@@ -207,8 +207,8 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
*/
|
||||
public IntegerTopic getIntegerTopic(String name) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof IntegerTopic) {
|
||||
return (IntegerTopic) topic;
|
||||
if (topic instanceof IntegerTopic t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
int handle;
|
||||
@@ -235,8 +235,8 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
*/
|
||||
public FloatTopic getFloatTopic(String name) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof FloatTopic) {
|
||||
return (FloatTopic) topic;
|
||||
if (topic instanceof FloatTopic t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
int handle;
|
||||
@@ -263,8 +263,8 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
*/
|
||||
public DoubleTopic getDoubleTopic(String name) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof DoubleTopic) {
|
||||
return (DoubleTopic) topic;
|
||||
if (topic instanceof DoubleTopic t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
int handle;
|
||||
@@ -291,8 +291,8 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
*/
|
||||
public StringTopic getStringTopic(String name) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof StringTopic) {
|
||||
return (StringTopic) topic;
|
||||
if (topic instanceof StringTopic t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
int handle;
|
||||
@@ -319,8 +319,8 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
*/
|
||||
public RawTopic getRawTopic(String name) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof RawTopic) {
|
||||
return (RawTopic) topic;
|
||||
if (topic instanceof RawTopic t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
int handle;
|
||||
@@ -347,8 +347,8 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
*/
|
||||
public BooleanArrayTopic getBooleanArrayTopic(String name) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof BooleanArrayTopic) {
|
||||
return (BooleanArrayTopic) topic;
|
||||
if (topic instanceof BooleanArrayTopic t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
int handle;
|
||||
@@ -375,8 +375,8 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
*/
|
||||
public IntegerArrayTopic getIntegerArrayTopic(String name) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof IntegerArrayTopic) {
|
||||
return (IntegerArrayTopic) topic;
|
||||
if (topic instanceof IntegerArrayTopic t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
int handle;
|
||||
@@ -403,8 +403,8 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
*/
|
||||
public FloatArrayTopic getFloatArrayTopic(String name) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof FloatArrayTopic) {
|
||||
return (FloatArrayTopic) topic;
|
||||
if (topic instanceof FloatArrayTopic t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
int handle;
|
||||
@@ -431,8 +431,8 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
*/
|
||||
public DoubleArrayTopic getDoubleArrayTopic(String name) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof DoubleArrayTopic) {
|
||||
return (DoubleArrayTopic) topic;
|
||||
if (topic instanceof DoubleArrayTopic t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
int handle;
|
||||
@@ -459,8 +459,8 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
*/
|
||||
public StringArrayTopic getStringArrayTopic(String name) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof StringArrayTopic) {
|
||||
return (StringArrayTopic) topic;
|
||||
if (topic instanceof StringArrayTopic t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
int handle;
|
||||
@@ -492,8 +492,7 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
public <T, MessageType extends ProtoMessage<?>>
|
||||
ProtobufTopic<T> getProtobufTopic(String name, Protobuf<T, MessageType> proto) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof ProtobufTopic<?>
|
||||
&& ((ProtobufTopic<?>) topic).getProto().equals(proto)) {
|
||||
if (topic instanceof ProtobufTopic<?> t && t.getProto().equals(proto)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ProtobufTopic<T> wrapTopic = (ProtobufTopic<T>) topic;
|
||||
return wrapTopic;
|
||||
@@ -526,8 +525,7 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
public <T>
|
||||
StructTopic<T> getStructTopic(String name, Struct<T> struct) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof StructTopic<?>
|
||||
&& ((StructTopic<?>) topic).getStruct().equals(struct)) {
|
||||
if (topic instanceof StructTopic<?> t && t.getStruct().equals(struct)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
StructTopic<T> wrapTopic = (StructTopic<T>) topic;
|
||||
return wrapTopic;
|
||||
@@ -560,8 +558,7 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
public <T>
|
||||
StructArrayTopic<T> getStructArrayTopic(String name, Struct<T> struct) {
|
||||
Topic topic = m_topics.get(name);
|
||||
if (topic instanceof StructArrayTopic<?>
|
||||
&& ((StructArrayTopic<?>) topic).getStruct().equals(struct)) {
|
||||
if (topic instanceof StructArrayTopic<?> t && t.getStruct().equals(struct)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
StructArrayTopic<T> wrapTopic = (StructArrayTopic<T>) topic;
|
||||
return wrapTopic;
|
||||
@@ -1525,11 +1522,7 @@ public final class NetworkTableInstance implements AutoCloseable {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof NetworkTableInstance)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_handle == ((NetworkTableInstance) other).m_handle;
|
||||
return other instanceof NetworkTableInstance inst && m_handle == inst.m_handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -649,11 +649,9 @@ public final class NetworkTableValue {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof NetworkTableValue)) {
|
||||
return false;
|
||||
}
|
||||
NetworkTableValue ntOther = (NetworkTableValue) other;
|
||||
return m_type == ntOther.m_type && m_value.equals(ntOther.m_value);
|
||||
return other instanceof NetworkTableValue ntOther
|
||||
&& m_type == ntOther.m_type
|
||||
&& m_value.equals(ntOther.m_value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user