mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Clean up Java style (#5990)
Also make equivalent changes in C++ where applicable. Co-authored-by: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com>
This commit is contained in:
@@ -574,7 +574,7 @@ public final class NetworkTable {
|
||||
return m_inst.addListener(
|
||||
new String[] {m_pathWithSep},
|
||||
EnumSet.of(NetworkTableEvent.Kind.kPublish, NetworkTableEvent.Kind.kImmediate),
|
||||
new Consumer<NetworkTableEvent>() {
|
||||
new Consumer<>() {
|
||||
final Set<String> m_notifiedTables = new HashSet<>();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -190,14 +190,14 @@ final class ProtobufEntryImpl<T> extends EntryBase implements ProtobufEntry<T> {
|
||||
|
||||
private TimestampedObject<T> fromRaw(TimestampedRaw raw, T defaultValue) {
|
||||
if (raw.value.length == 0) {
|
||||
return new TimestampedObject<T>(0, 0, defaultValue);
|
||||
return new TimestampedObject<>(0, 0, defaultValue);
|
||||
}
|
||||
try {
|
||||
synchronized (m_buf) {
|
||||
return new TimestampedObject<T>(raw.timestamp, raw.serverTime, m_buf.read(raw.value));
|
||||
return new TimestampedObject<>(raw.timestamp, raw.serverTime, m_buf.read(raw.value));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return new TimestampedObject<T>(0, 0, defaultValue);
|
||||
return new TimestampedObject<>(0, 0, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public final class ProtobufTopic<T> extends Topic {
|
||||
* @return ProtobufTopic for value class
|
||||
*/
|
||||
public static <T> ProtobufTopic<T> wrap(Topic topic, Protobuf<T, ?> proto) {
|
||||
return new ProtobufTopic<T>(topic, proto);
|
||||
return new ProtobufTopic<>(topic, proto);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ public final class ProtobufTopic<T> extends Topic {
|
||||
*/
|
||||
public static <T> ProtobufTopic<T> wrap(
|
||||
NetworkTableInstance inst, int handle, Protobuf<T, ?> proto) {
|
||||
return new ProtobufTopic<T>(inst, handle, proto);
|
||||
return new ProtobufTopic<>(inst, handle, proto);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public final class ProtobufTopic<T> extends Topic {
|
||||
* @return subscriber
|
||||
*/
|
||||
public ProtobufSubscriber<T> subscribe(T defaultValue, PubSubOption... options) {
|
||||
return new ProtobufEntryImpl<T>(
|
||||
return new ProtobufEntryImpl<>(
|
||||
this,
|
||||
ProtobufBuffer.create(m_proto),
|
||||
NetworkTablesJNI.subscribe(
|
||||
@@ -87,7 +87,7 @@ public final class ProtobufTopic<T> extends Topic {
|
||||
*/
|
||||
public ProtobufPublisher<T> publish(PubSubOption... options) {
|
||||
m_inst.addSchema(m_proto);
|
||||
return new ProtobufEntryImpl<T>(
|
||||
return new ProtobufEntryImpl<>(
|
||||
this,
|
||||
ProtobufBuffer.create(m_proto),
|
||||
NetworkTablesJNI.publish(
|
||||
@@ -113,7 +113,7 @@ public final class ProtobufTopic<T> extends Topic {
|
||||
*/
|
||||
public ProtobufPublisher<T> publishEx(String properties, PubSubOption... options) {
|
||||
m_inst.addSchema(m_proto);
|
||||
return new ProtobufEntryImpl<T>(
|
||||
return new ProtobufEntryImpl<>(
|
||||
this,
|
||||
ProtobufBuffer.create(m_proto),
|
||||
NetworkTablesJNI.publishEx(
|
||||
@@ -144,7 +144,7 @@ public final class ProtobufTopic<T> extends Topic {
|
||||
* @return entry
|
||||
*/
|
||||
public ProtobufEntry<T> getEntry(T defaultValue, PubSubOption... options) {
|
||||
return new ProtobufEntryImpl<T>(
|
||||
return new ProtobufEntryImpl<>(
|
||||
this,
|
||||
ProtobufBuffer.create(m_proto),
|
||||
NetworkTablesJNI.getEntry(
|
||||
|
||||
@@ -177,15 +177,14 @@ final class StructArrayEntryImpl<T> extends EntryBase implements StructArrayEntr
|
||||
@SuppressWarnings("PMD.AvoidCatchingGenericException")
|
||||
private TimestampedObject<T[]> fromRaw(TimestampedRaw raw, T[] defaultValue) {
|
||||
if (raw.value.length == 0) {
|
||||
return new TimestampedObject<T[]>(0, 0, defaultValue);
|
||||
return new TimestampedObject<>(0, 0, defaultValue);
|
||||
}
|
||||
try {
|
||||
synchronized (m_buf) {
|
||||
return new TimestampedObject<T[]>(
|
||||
raw.timestamp, raw.serverTime, m_buf.readArray(raw.value));
|
||||
return new TimestampedObject<>(raw.timestamp, raw.serverTime, m_buf.readArray(raw.value));
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
return new TimestampedObject<T[]>(0, 0, defaultValue);
|
||||
return new TimestampedObject<>(0, 0, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public final class StructArrayTopic<T> extends Topic {
|
||||
* @return StructArrayTopic for value class
|
||||
*/
|
||||
public static <T> StructArrayTopic<T> wrap(Topic topic, Struct<T> struct) {
|
||||
return new StructArrayTopic<T>(topic, struct);
|
||||
return new StructArrayTopic<>(topic, struct);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ public final class StructArrayTopic<T> extends Topic {
|
||||
*/
|
||||
public static <T> StructArrayTopic<T> wrap(
|
||||
NetworkTableInstance inst, int handle, Struct<T> struct) {
|
||||
return new StructArrayTopic<T>(inst, handle, struct);
|
||||
return new StructArrayTopic<>(inst, handle, struct);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public final class StructArrayTopic<T> extends Topic {
|
||||
* @return subscriber
|
||||
*/
|
||||
public StructArraySubscriber<T> subscribe(T[] defaultValue, PubSubOption... options) {
|
||||
return new StructArrayEntryImpl<T>(
|
||||
return new StructArrayEntryImpl<>(
|
||||
this,
|
||||
StructBuffer.create(m_struct),
|
||||
NetworkTablesJNI.subscribe(
|
||||
@@ -87,7 +87,7 @@ public final class StructArrayTopic<T> extends Topic {
|
||||
*/
|
||||
public StructArrayPublisher<T> publish(PubSubOption... options) {
|
||||
m_inst.addSchema(m_struct);
|
||||
return new StructArrayEntryImpl<T>(
|
||||
return new StructArrayEntryImpl<>(
|
||||
this,
|
||||
StructBuffer.create(m_struct),
|
||||
NetworkTablesJNI.publish(
|
||||
@@ -113,7 +113,7 @@ public final class StructArrayTopic<T> extends Topic {
|
||||
*/
|
||||
public StructArrayPublisher<T> publishEx(String properties, PubSubOption... options) {
|
||||
m_inst.addSchema(m_struct);
|
||||
return new StructArrayEntryImpl<T>(
|
||||
return new StructArrayEntryImpl<>(
|
||||
this,
|
||||
StructBuffer.create(m_struct),
|
||||
NetworkTablesJNI.publishEx(
|
||||
@@ -144,7 +144,7 @@ public final class StructArrayTopic<T> extends Topic {
|
||||
* @return entry
|
||||
*/
|
||||
public StructArrayEntry<T> getEntry(T[] defaultValue, PubSubOption... options) {
|
||||
return new StructArrayEntryImpl<T>(
|
||||
return new StructArrayEntryImpl<>(
|
||||
this,
|
||||
StructBuffer.create(m_struct),
|
||||
NetworkTablesJNI.getEntry(
|
||||
|
||||
@@ -188,14 +188,14 @@ final class StructEntryImpl<T> extends EntryBase implements StructEntry<T> {
|
||||
@SuppressWarnings("PMD.AvoidCatchingGenericException")
|
||||
private TimestampedObject<T> fromRaw(TimestampedRaw raw, T defaultValue) {
|
||||
if (raw.value.length == 0) {
|
||||
return new TimestampedObject<T>(0, 0, defaultValue);
|
||||
return new TimestampedObject<>(0, 0, defaultValue);
|
||||
}
|
||||
try {
|
||||
synchronized (m_buf) {
|
||||
return new TimestampedObject<T>(raw.timestamp, raw.serverTime, m_buf.read(raw.value));
|
||||
return new TimestampedObject<>(raw.timestamp, raw.serverTime, m_buf.read(raw.value));
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
return new TimestampedObject<T>(0, 0, defaultValue);
|
||||
return new TimestampedObject<>(0, 0, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public final class StructTopic<T> extends Topic {
|
||||
* @return StructTopic for value class
|
||||
*/
|
||||
public static <T> StructTopic<T> wrap(Topic topic, Struct<T> struct) {
|
||||
return new StructTopic<T>(topic, struct);
|
||||
return new StructTopic<>(topic, struct);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,7 @@ public final class StructTopic<T> extends Topic {
|
||||
* @return StructTopic for value class
|
||||
*/
|
||||
public static <T> StructTopic<T> wrap(NetworkTableInstance inst, int handle, Struct<T> struct) {
|
||||
return new StructTopic<T>(inst, handle, struct);
|
||||
return new StructTopic<>(inst, handle, struct);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ public final class StructTopic<T> extends Topic {
|
||||
* @return subscriber
|
||||
*/
|
||||
public StructSubscriber<T> subscribe(T defaultValue, PubSubOption... options) {
|
||||
return new StructEntryImpl<T>(
|
||||
return new StructEntryImpl<>(
|
||||
this,
|
||||
StructBuffer.create(m_struct),
|
||||
NetworkTablesJNI.subscribe(
|
||||
@@ -86,7 +86,7 @@ public final class StructTopic<T> extends Topic {
|
||||
*/
|
||||
public StructPublisher<T> publish(PubSubOption... options) {
|
||||
m_inst.addSchema(m_struct);
|
||||
return new StructEntryImpl<T>(
|
||||
return new StructEntryImpl<>(
|
||||
this,
|
||||
StructBuffer.create(m_struct),
|
||||
NetworkTablesJNI.publish(
|
||||
@@ -112,7 +112,7 @@ public final class StructTopic<T> extends Topic {
|
||||
*/
|
||||
public StructPublisher<T> publishEx(String properties, PubSubOption... options) {
|
||||
m_inst.addSchema(m_struct);
|
||||
return new StructEntryImpl<T>(
|
||||
return new StructEntryImpl<>(
|
||||
this,
|
||||
StructBuffer.create(m_struct),
|
||||
NetworkTablesJNI.publishEx(
|
||||
@@ -143,7 +143,7 @@ public final class StructTopic<T> extends Topic {
|
||||
* @return entry
|
||||
*/
|
||||
public StructEntry<T> getEntry(T defaultValue, PubSubOption... options) {
|
||||
return new StructEntryImpl<T>(
|
||||
return new StructEntryImpl<>(
|
||||
this,
|
||||
StructBuffer.create(m_struct),
|
||||
NetworkTablesJNI.getEntry(
|
||||
|
||||
Reference in New Issue
Block a user