[docs] Add missing JavaDocs (#6146)

This commit is contained in:
Tyler Veness
2024-01-04 08:38:06 -08:00
committed by GitHub
parent 6e58db398d
commit f29a7d2e50
145 changed files with 1106 additions and 94 deletions

View File

@@ -16,11 +16,17 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
/** Loads dynamic libraries for all platforms. */
public final class CombinedRuntimeLoader {
private CombinedRuntimeLoader() {}
private static String extractionDirectory;
/**
* Returns library extraction directory.
*
* @return Library extraction directory.
*/
public static synchronized String getExtractionDirectory() {
return extractionDirectory;
}
@@ -29,6 +35,12 @@ public final class CombinedRuntimeLoader {
extractionDirectory = directory;
}
/**
* Sets DLL directory.
*
* @param directory Directory.
* @return DLL directory.
*/
public static native String setDllDirectory(String directory);
private static String getLoadErrorMessage(String libraryName, UnsatisfiedLinkError ule) {

View File

@@ -13,6 +13,9 @@ public class EventVector {
private final ReentrantLock m_lock = new ReentrantLock();
private final List<Integer> m_events = new ArrayList<>();
/** Default constructor. */
public EventVector() {}
/**
* Adds an event to the event vector.
*

View File

@@ -18,6 +18,9 @@ import java.util.TreeMap;
public class InterpolatingTreeMap<K extends Number, V extends Number> {
private final TreeMap<K, V> m_map = new TreeMap<>();
/** Default constructor. */
public InterpolatingTreeMap() {}
/**
* Inserts a key-value pair.
*

View File

@@ -17,6 +17,11 @@ import java.security.NoSuchAlgorithmException;
import java.util.Locale;
import java.util.Scanner;
/**
* Loads a native library at runtime.
*
* @param <T> The class to load.
*/
public final class RuntimeLoader<T> {
private static String defaultExtractionRoot;

View File

@@ -70,16 +70,38 @@ public class WPIUtilJNI {
libraryLoaded = true;
}
/**
* Write the given string to stderr.
*
* @param str String to write.
*/
public static native void writeStderr(String str);
/** Enable mock time. */
public static native void enableMockTime();
/** Disable mock time. */
public static native void disableMockTime();
/**
* Set mock time.
*
* @param time The desired time in microseconds.
*/
public static native void setMockTime(long time);
/**
* Returns the time.
*
* @return The time.
*/
public static native long now();
/**
* Returns the system time.
*
* @return The system time.
*/
public static native long getSystemTime();
/**

View File

@@ -16,6 +16,9 @@ public class CleanupPool implements AutoCloseable {
// state ArrayDeque is faster anyway.
private final Deque<AutoCloseable> m_closers = new ArrayDeque<>();
/** Default constructor. */
public CleanupPool() {}
/**
* Registers an object in the object stack for cleanup.
*

View File

@@ -9,6 +9,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** Attribute for telling JVM to skip object cleanup. */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface SkipCleanup {}

View File

@@ -267,4 +267,7 @@ public class DataLogJNI extends WPIUtilJNI {
* @param timestamp Time stamp (may be 0 to indicate now)
*/
static native void appendStringArray(long impl, int entry, String[] value, long timestamp);
/** Utility class. */
private DataLogJNI() {}
}

View File

@@ -26,6 +26,14 @@ public final class ProtobufBuffer<T, MessageType extends ProtoMessage<?>> {
m_proto = proto;
}
/**
* Creates a ProtobufBuffer for the given Protobuf object.
*
* @param <T> The type to serialize.
* @param <MessageType> The Protobuf message type.
* @param proto The Protobuf object.
* @return A ProtobufBuffer for the given Protobuf object.
*/
public static <T, MessageType extends ProtoMessage<?>> ProtobufBuffer<T, MessageType> create(
Protobuf<T, MessageType> proto) {
return new ProtobufBuffer<>(proto);

View File

@@ -15,10 +15,14 @@ import java.util.function.LongConsumer;
import java.util.function.LongSupplier;
import java.util.function.Supplier;
/** Helper class for building Sendable dashboard representations. */
public interface SendableBuilder extends AutoCloseable {
/** The backend kinds used for the sendable builder. */
enum BackendKind {
/** Unknown. */
kUnknown,
/** NetworkTables. */
kNetworkTables
}

View File

@@ -506,6 +506,9 @@ public final class SendableRegistry {
/** Sendable builder for the sendable. */
public SendableBuilder builder;
/** Default constructor. */
public CallbackData() {}
}
// As foreachLiveWindow is single threaded, cache the components it

View File

@@ -12,7 +12,7 @@ import java.util.Collection;
/**
* Reusable buffer for serialization/deserialization to/from a raw struct.
*
* @param <T> object type
* @param <T> Object type.
*/
public final class StructBuffer<T> {
private StructBuffer(Struct<T> struct) {
@@ -21,6 +21,13 @@ public final class StructBuffer<T> {
m_struct = struct;
}
/**
* Returns a StructBuffer for the given struct.
*
* @param struct A struct.
* @param <T> Object type.
* @return A StructBuffer for the given struct.
*/
public static <T> StructBuffer<T> create(Struct<T> struct) {
return new StructBuffer<>(struct);
}

View File

@@ -14,6 +14,9 @@ import java.util.Stack;
/** Database of raw struct dynamic descriptors. */
public class StructDescriptorDatabase {
/** Default constructor. */
public StructDescriptorDatabase() {}
/**
* Adds a structure schema to the database. If the struct references other structs that have not
* yet been added, it will not be valid until those structs are also added.

View File

@@ -6,18 +6,31 @@ package edu.wpi.first.util.struct;
/** Known data types for raw struct dynamic fields (see StructFieldDescriptor). */
public enum StructFieldType {
/** bool. */
kBool("bool", false, false, 1),
/** char. */
kChar("char", false, false, 1),
/** int8. */
kInt8("int8", true, false, 1),
/** int16. */
kInt16("int16", true, false, 2),
/** int32. */
kInt32("int32", true, false, 4),
/** int64. */
kInt64("int64", true, false, 8),
/** uint8. */
kUint8("uint8", false, true, 1),
/** uint16. */
kUint16("uint16", false, true, 2),
/** uint32. */
kUint32("uint32", false, true, 4),
/** uint64. */
kUint64("uint64", false, true, 8),
/** float. */
kFloat("float", false, false, 4),
/** double. */
kDouble("double", false, false, 8),
/** struct. */
kStruct("struct", false, false, 0);
/** The name of the data type. */

View File

@@ -4,25 +4,50 @@
package edu.wpi.first.util.struct.parser;
/** Exception for parsing errors. */
public class ParseException extends Exception {
/** The parser position. */
private final int m_pos;
/**
* Constructs a ParseException.
*
* @param pos The parser position.
* @param s Reason for parse failure.
*/
public ParseException(int pos, String s) {
super(s);
m_pos = pos;
}
/**
* Constructs a ParseException.
*
* @param pos The parser position.
* @param message Reason for parse failure.
* @param cause Exception that caused the parser failure.
*/
public ParseException(int pos, String message, Throwable cause) {
super(message, cause);
m_pos = pos;
}
/**
* Constructs a ParseException.
*
* @param pos The parser position.
* @param cause Exception that caused the parser failure.
*/
public ParseException(int pos, Throwable cause) {
super(cause);
m_pos = pos;
}
/**
* Returns position in parsed string.
*
* @return Position in parsed string.
*/
public int getPosition() {
return m_pos;
}

View File

@@ -8,18 +8,26 @@ import java.util.Map;
/** Raw struct schema declaration. */
public class ParsedDeclaration {
/** Type string. */
@SuppressWarnings("MemberName")
public String typeString;
/** Name. */
@SuppressWarnings("MemberName")
public String name;
/** Enum values. */
@SuppressWarnings("MemberName")
public Map<String, Long> enumValues;
/** Array size. */
@SuppressWarnings("MemberName")
public int arraySize = 1;
/** Bit width. */
@SuppressWarnings("MemberName")
public int bitWidth;
/** Default constructor. */
public ParsedDeclaration() {}
}

View File

@@ -9,6 +9,10 @@ import java.util.List;
/** Raw struct schema. */
public class ParsedSchema {
/** Declarations. */
@SuppressWarnings("MemberName")
public List<ParsedDeclaration> declarations = new ArrayList<>();
/** Default constructor. */
public ParsedSchema() {}
}

View File

@@ -6,17 +6,40 @@ package edu.wpi.first.util.struct.parser;
/** A lexed raw struct schema token. */
public enum TokenKind {
/** Unknown. */
kUnknown("unknown"),
/** Integer. */
kInteger("integer"),
/** Identifier. */
kIdentifier("identifier"),
/** Left square bracket. */
kLeftBracket("'['"),
/** Right square bracket. */
kRightBracket("']'"),
/** Left curly brace. */
kLeftBrace("'{'"),
/** Right curly brace. */
kRightBrace("'}'"),
/** Colon. */
kColon("':'"),
/** Semicolon. */
kSemicolon("';'"),
/** Comma. */
kComma("','"),
/** Equals. */
kEquals("'='"),
/** End of input. */
kEndOfInput("<EOF>");
private final String m_name;