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:
Tyler Veness
2023-12-03 16:21:32 -08:00
committed by GitHub
parent 66172ab288
commit 2bb1409b82
113 changed files with 426 additions and 617 deletions

View File

@@ -59,8 +59,7 @@ public final class CombinedRuntimeLoader {
@SuppressWarnings("unchecked")
public static <T> List<String> extractLibraries(Class<T> clazz, String resourceName)
throws IOException {
TypeReference<HashMap<String, Object>> typeRef =
new TypeReference<HashMap<String, Object>>() {};
TypeReference<HashMap<String, Object>> typeRef = new TypeReference<>() {};
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map;
try (var stream = clazz.getResourceAsStream(resourceName)) {

View File

@@ -14,7 +14,7 @@ import java.util.Deque;
public class CleanupPool implements AutoCloseable {
// Use a Deque instead of a Stack, as Stack's iterators go the wrong way, and docs
// state ArrayDeque is faster anyway.
private final Deque<AutoCloseable> m_closers = new ArrayDeque<AutoCloseable>();
private final Deque<AutoCloseable> m_closers = new ArrayDeque<>();
/**
* Registers an object in the object stack for cleanup.

View File

@@ -37,7 +37,7 @@ public final class ProtobufLogEntry<T> extends DataLogEntry {
*/
public static <T, MessageType extends ProtoMessage<?>> ProtobufLogEntry<T> create(
DataLog log, String name, Protobuf<T, MessageType> proto, String metadata, long timestamp) {
return new ProtobufLogEntry<T>(log, name, proto, metadata, timestamp);
return new ProtobufLogEntry<>(log, name, proto, metadata, timestamp);
}
/**

View File

@@ -35,7 +35,7 @@ public final class StructArrayLogEntry<T> extends DataLogEntry {
*/
public static <T> StructArrayLogEntry<T> create(
DataLog log, String name, Struct<T> struct, String metadata, long timestamp) {
return new StructArrayLogEntry<T>(log, name, struct, metadata, timestamp);
return new StructArrayLogEntry<>(log, name, struct, metadata, timestamp);
}
/**

View File

@@ -34,7 +34,7 @@ public final class StructLogEntry<T> extends DataLogEntry {
*/
public static <T> StructLogEntry<T> create(
DataLog log, String name, Struct<T> struct, String metadata, long timestamp) {
return new StructLogEntry<T>(log, name, struct, metadata, timestamp);
return new StructLogEntry<>(log, name, struct, metadata, timestamp);
}
/**

View File

@@ -28,7 +28,7 @@ public final class ProtobufBuffer<T, MessageType extends ProtoMessage<?>> {
public static <T, MessageType extends ProtoMessage<?>> ProtobufBuffer<T, MessageType> create(
Protobuf<T, MessageType> proto) {
return new ProtobufBuffer<T, MessageType>(proto);
return new ProtobufBuffer<>(proto);
}
/**

View File

@@ -22,7 +22,7 @@ public final class StructBuffer<T> {
}
public static <T> StructBuffer<T> create(Struct<T> struct) {
return new StructBuffer<T>(struct);
return new StructBuffer<>(struct);
}
/**

View File

@@ -33,7 +33,7 @@ public class StructDescriptorDatabase {
}
// turn parsed schema into descriptors
StructDescriptor theStruct = m_structs.computeIfAbsent(name, k -> new StructDescriptor(k));
StructDescriptor theStruct = m_structs.computeIfAbsent(name, StructDescriptor::new);
theStruct.m_schema = schema;
theStruct.m_fields.clear();
boolean isValid = true;
@@ -76,7 +76,7 @@ public class StructDescriptorDatabase {
// cross-reference struct, creating a placeholder if necessary
StructDescriptor aStruct =
m_structs.computeIfAbsent(decl.typeString, k -> new StructDescriptor(k));
m_structs.computeIfAbsent(decl.typeString, StructDescriptor::new);
// if the struct isn't valid, we can't be valid either
if (aStruct.isValid()) {