diff --git a/build.gradle b/build.gradle index 840ddae62f..d00f4a272d 100644 --- a/build.gradle +++ b/build.gradle @@ -82,7 +82,7 @@ subprojects { } checkstyle { - toolVersion = "8.1" + toolVersion = "8.10" configFile = new File(rootDir, "styleguide/checkstyle.xml") } diff --git a/cameraserver/src/main/java/edu/wpi/first/wpilibj/CameraServer.java b/cameraserver/src/main/java/edu/wpi/first/wpilibj/CameraServer.java index 4a85920854..76be85cb71 100644 --- a/cameraserver/src/main/java/edu/wpi/first/wpilibj/CameraServer.java +++ b/cameraserver/src/main/java/edu/wpi/first/wpilibj/CameraServer.java @@ -7,6 +7,10 @@ package edu.wpi.first.wpilibj; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.concurrent.atomic.AtomicInteger; + import edu.wpi.cscore.AxisCamera; import edu.wpi.cscore.CameraServerJNI; import edu.wpi.cscore.CvSink; @@ -21,17 +25,11 @@ import edu.wpi.cscore.VideoMode.PixelFormat; import edu.wpi.cscore.VideoProperty; import edu.wpi.cscore.VideoSink; import edu.wpi.cscore.VideoSource; -//import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType; -//import edu.wpi.first.wpilibj.hal.HAL; import edu.wpi.first.networktables.EntryListenerFlags; import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableEntry; import edu.wpi.first.networktables.NetworkTableInstance; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.ArrayList; -import java.util.Hashtable; - /** * Singleton class for creating and keeping camera servers. * Also publishes camera information to NetworkTables. @@ -420,7 +418,7 @@ public class CameraServer { // synchronization issues, so just update to current setting if someone // else tries to change it. m_tableListener = NetworkTableInstance.getDefault().addEntryListener(kPublishName + "/", - (event) -> { + event -> { String relativeKey = event.name.substring(kPublishName.length() + 1); // get source (sourceName/...) diff --git a/cameraserver/src/main/java/edu/wpi/first/wpilibj/vision/VisionRunner.java b/cameraserver/src/main/java/edu/wpi/first/wpilibj/vision/VisionRunner.java index bd79573e7e..2abfa2551d 100644 --- a/cameraserver/src/main/java/edu/wpi/first/wpilibj/vision/VisionRunner.java +++ b/cameraserver/src/main/java/edu/wpi/first/wpilibj/vision/VisionRunner.java @@ -7,14 +7,12 @@ package edu.wpi.first.wpilibj.vision; +import org.opencv.core.Mat; + import edu.wpi.cscore.CvSink; import edu.wpi.cscore.VideoSource; import edu.wpi.first.wpilibj.CameraServerSharedStore; -//import edu.wpi.first.wpilibj.DriverStation; -//import edu.wpi.first.wpilibj.RobotBase; -import org.opencv.core.Mat; - /** * A vision runner is a convenient wrapper object to make it easy to run vision pipelines * from robot code. The easiest way to use this is to run it in a {@link VisionThread} diff --git a/cscore/build.gradle b/cscore/build.gradle index c7bad1c77d..c13040a8b4 100644 --- a/cscore/build.gradle +++ b/cscore/build.gradle @@ -109,7 +109,3 @@ model { } } } - -checkstyle { - sourceSets = [] -} diff --git a/cscore/src/dev/java/edu/wpi/cscore/DevMain.java b/cscore/src/dev/java/edu/wpi/cscore/DevMain.java index a0cd6f83d8..c406e9f6ae 100644 --- a/cscore/src/dev/java/edu/wpi/cscore/DevMain.java +++ b/cscore/src/dev/java/edu/wpi/cscore/DevMain.java @@ -10,6 +10,9 @@ package edu.wpi.cscore; import edu.wpi.first.wpiutil.RuntimeDetector; public class DevMain { + /** + * Main method. + */ public static void main(String[] args) { System.out.println("Hello World!"); System.out.println(RuntimeDetector.getPlatformPath()); diff --git a/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java b/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java index 0af45b9195..3dc8fe2c5e 100644 --- a/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java +++ b/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java @@ -8,12 +8,14 @@ package edu.wpi.cscore; import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.function.Consumer; + import org.opencv.core.Core; + import edu.wpi.first.wpiutil.RuntimeDetector; public class CameraServerJNI { @@ -21,11 +23,12 @@ public class CameraServerJNI { static File jniLibrary = null; static boolean cvLibraryLoaded = false; static File cvJniLibrary = null; + static { if (!libraryLoaded) { try { System.loadLibrary("cscore"); - } catch (UnsatisfiedLinkError e) { + } catch (UnsatisfiedLinkError linkError) { try { String resname = RuntimeDetector.getLibraryResource("cscore"); InputStream is = CameraServerJNI.class.getResourceAsStream(resname); @@ -69,7 +72,7 @@ public class CameraServerJNI { try { System.loadLibrary(opencvName); - } catch (UnsatisfiedLinkError e) { + } catch (UnsatisfiedLinkError linkError) { try { String resname = RuntimeDetector.getLibraryResource(opencvName); InputStream is = CameraServerJNI.class.getResourceAsStream(resname); @@ -109,7 +112,7 @@ public class CameraServerJNI { } } - public static void ForceLoad() {} + public static void forceLoad() {} // // Property Functions @@ -239,9 +242,10 @@ public class CameraServerJNI { kSourceBytesReceived(1), kSourceFramesReceived(2); + @SuppressWarnings("MemberName") private int value; - private TelemetryKind(int value) { + TelemetryKind(int value) { this.value = value; } diff --git a/cscore/src/main/java/edu/wpi/cscore/CvSource.java b/cscore/src/main/java/edu/wpi/cscore/CvSource.java index 74ab4f2f7e..7d447d66d2 100644 --- a/cscore/src/main/java/edu/wpi/cscore/CvSource.java +++ b/cscore/src/main/java/edu/wpi/cscore/CvSource.java @@ -19,7 +19,11 @@ public class CvSource extends VideoSource { * @param mode Video mode being generated */ public CvSource(String name, VideoMode mode) { - super(CameraServerJNI.createCvSource(name, mode.pixelFormat.getValue(), mode.width, mode.height, mode.fps)); + super(CameraServerJNI.createCvSource(name, + mode.pixelFormat.getValue(), + mode.width, + mode.height, + mode.fps)); } /** @@ -80,66 +84,108 @@ public class CvSource extends VideoSource { * @param value Current value * @return Property */ - public VideoProperty createProperty(String name, VideoProperty.Kind kind, int minimum, int maximum, int step, int defaultValue, int value) { + public VideoProperty createProperty(String name, + VideoProperty.Kind kind, + int minimum, + int maximum, + int step, + int defaultValue, + int value) { return new VideoProperty( - CameraServerJNI.createSourceProperty(m_handle, name, kind.getValue(), minimum, maximum, step, defaultValue, value)); + CameraServerJNI.createSourceProperty(m_handle, + name, + kind.getValue(), + minimum, + maximum, + step, + defaultValue, + value)); } - /// Create an integer property. - /// @param name Property name - /// @param minimum Minimum value - /// @param maximum Maximum value - /// @param step Step value - /// @param defaultValue Default value - /// @param value Current value - /// @return Property - public VideoProperty createIntegerProperty(String name, int minimum, int maximum, int step, int defaultValue, int value) { + /** + * Create an integer property. + * @param name Property name + * @param minimum Minimum value + * @param maximum Maximum value + * @param step Step value + * @param defaultValue Default value + * @param value Current value + * @return Property + */ + public VideoProperty createIntegerProperty(String name, + int minimum, + int maximum, + int step, + int defaultValue, + int value) { return new VideoProperty( - CameraServerJNI.createSourceProperty(m_handle, name, VideoProperty.Kind.kInteger.getValue(), minimum, maximum, step, defaultValue, value)); + CameraServerJNI.createSourceProperty(m_handle, + name, + VideoProperty.Kind.kInteger.getValue(), + minimum, + maximum, + step, + defaultValue, + value)); } - /// Create a boolean property. - /// @param name Property name - /// @param defaultValue Default value - /// @param value Current value - /// @return Property + /** + * Create a boolean property. + * @param name Property name + * @param defaultValue Default value + * @param value Current value + * @return Property + */ public VideoProperty createBooleanProperty(String name, boolean defaultValue, boolean value) { return new VideoProperty( - CameraServerJNI.createSourceProperty(m_handle, name, VideoProperty.Kind.kBoolean.getValue(), 0, 1, 1, defaultValue ? 1 : 0, value ? 1 : 0)); + CameraServerJNI.createSourceProperty(m_handle, + name, + VideoProperty.Kind.kBoolean.getValue(), + 0, + 1, + 1, + defaultValue ? 1 : 0, + value ? 1 : 0)); } - /// Create a string property. - /// @param name Property name - /// @param value Current value - /// @return Property + /** + * Create a string property. + * @param name Property name + * @param value Current value + * @return Property + */ public VideoProperty createStringProperty(String name, String value) { VideoProperty prop = new VideoProperty( - CameraServerJNI.createSourceProperty(m_handle, name, VideoProperty.Kind.kString.getValue(), 0, 0, 0, 0, 0)); + CameraServerJNI.createSourceProperty(m_handle, + name, + VideoProperty.Kind.kString.getValue(), + 0, + 0, + 0, + 0, + 0)); prop.setString(value); return prop; } - /// Create a property with a change callback. - /// @param name Property name - /// @param kind Property kind - /// @param minimum Minimum value - /// @param maximum Maximum value - /// @param step Step value - /// @param defaultValue Default value - /// @param value Current value - /// @param onChange Callback to call when the property value changes - /// @return Property - //public VideoProperty createProperty( - // String name, VideoProperty.Kind kind, int minimum, int maximum, int step, int defaultValue, int value, - // std::function - // onChange); - /** * Configure enum property choices. * @param property Property * @param choices Choices */ - public void SetEnumPropertyChoices(VideoProperty property, String[] choices) { + public void setEnumPropertyChoices(VideoProperty property, String[] choices) { CameraServerJNI.setSourceEnumPropertyChoices(m_handle, property.m_handle, choices); } + + /** + * Configure enum property choices. + * @param property Property + * @param choices Choices + * @deprecated Use {@code setEnumPropertyChoices} instead. + */ + @Deprecated + @SuppressWarnings("MethodName") + public void SetEnumPropertyChoices(VideoProperty property, String[] choices) { + setEnumPropertyChoices(property, choices); + } } diff --git a/cscore/src/main/java/edu/wpi/cscore/HttpCamera.java b/cscore/src/main/java/edu/wpi/cscore/HttpCamera.java index 3498ee3ab5..43eeba3d22 100644 --- a/cscore/src/main/java/edu/wpi/cscore/HttpCamera.java +++ b/cscore/src/main/java/edu/wpi/cscore/HttpCamera.java @@ -13,9 +13,11 @@ package edu.wpi.cscore; public class HttpCamera extends VideoCamera { public enum HttpCameraKind { kUnknown(0), kMJPGStreamer(1), kCSCore(2), kAxis(3); + + @SuppressWarnings("MemberName") private int value; - private HttpCameraKind(int value) { + HttpCameraKind(int value) { this.value = value; } @@ -24,6 +26,12 @@ public class HttpCamera extends VideoCamera { } } + /** + * Convert from the numerical representation of kind to an enum type. + * + * @param kind The numerical representation of kind + * @return The kind + */ public static HttpCameraKind getHttpCameraKindFromInt(int kind) { switch (kind) { case 1: return HttpCameraKind.kMJPGStreamer; diff --git a/cscore/src/main/java/edu/wpi/cscore/UsbCameraInfo.java b/cscore/src/main/java/edu/wpi/cscore/UsbCameraInfo.java index e0d35dff19..b00a4df32b 100644 --- a/cscore/src/main/java/edu/wpi/cscore/UsbCameraInfo.java +++ b/cscore/src/main/java/edu/wpi/cscore/UsbCameraInfo.java @@ -8,9 +8,15 @@ package edu.wpi.cscore; /** - * USB camera information + * USB camera information. */ public class UsbCameraInfo { + /** + * Create a new set of UsbCameraInfo. + * @param dev Device number (e.g. N in '/dev/videoN' on Linux) + * @param path Path to device if available (e.g. '/dev/video0' on Linux) + * @param name Vendor/model name of the camera as provided by the USB driver + */ public UsbCameraInfo(int dev, String path, String name) { this.dev = dev; this.path = path; @@ -18,17 +24,20 @@ public class UsbCameraInfo { } /** - * Device number (e.g. N in '/dev/videoN' on Linux) + * Device number (e.g. N in '/dev/videoN' on Linux). */ + @SuppressWarnings("MemberName") public int dev; /** - * Path to device if available (e.g. '/dev/video0' on Linux) + * Path to device if available (e.g. '/dev/video0' on Linux). */ + @SuppressWarnings("MemberName") public String path; /** - * Vendor/model name of the camera as provided by the USB driver + * Vendor/model name of the camera as provided by the USB driver. */ + @SuppressWarnings("MemberName") public String name; } diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoEvent.java b/cscore/src/main/java/edu/wpi/cscore/VideoEvent.java index a67299a3d4..f0be9e31f4 100644 --- a/cscore/src/main/java/edu/wpi/cscore/VideoEvent.java +++ b/cscore/src/main/java/edu/wpi/cscore/VideoEvent.java @@ -8,7 +8,7 @@ package edu.wpi.cscore; /** - * Video event + * Video event. */ public class VideoEvent { public enum Kind { @@ -30,9 +30,10 @@ public class VideoEvent { kNetworkInterfacesChanged(0x4000), kTelemetryUpdated(0x8000); + @SuppressWarnings("MemberName") private int value; - private Kind(int value) { + Kind(int value) { this.value = value; } @@ -41,6 +42,12 @@ public class VideoEvent { } } + /** + * Convert from the numerical representation of kind to an enum type. + * + * @param kind The numerical representation of kind + * @return The kind + */ public static Kind getKindFromInt(int kind) { switch (kind) { case 0x0001: return Kind.kSourceCreated; @@ -76,22 +83,31 @@ public class VideoEvent { this.valueStr = valueStr; } + @SuppressWarnings("MemberName") public Kind kind; // Valid for kSource* and kSink* respectively + @SuppressWarnings("MemberName") public int sourceHandle; + @SuppressWarnings("MemberName") public int sinkHandle; // Source/sink/property name + @SuppressWarnings("MemberName") public String name; // Fields for kSourceVideoModeChanged event + @SuppressWarnings("MemberName") public VideoMode mode; // Fields for kSourceProperty* events + @SuppressWarnings("MemberName") public int propertyHandle; + @SuppressWarnings("MemberName") public VideoProperty.Kind propertyKind; + @SuppressWarnings("MemberName") public int value; + @SuppressWarnings("MemberName") public String valueStr; public VideoSource getSource() { diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoMode.java b/cscore/src/main/java/edu/wpi/cscore/VideoMode.java index 9b6570eef2..65b2e2b774 100644 --- a/cscore/src/main/java/edu/wpi/cscore/VideoMode.java +++ b/cscore/src/main/java/edu/wpi/cscore/VideoMode.java @@ -8,14 +8,16 @@ package edu.wpi.cscore; /** - * Video mode + * Video mode. */ public class VideoMode { public enum PixelFormat { kUnknown(0), kMJPEG(1), kYUYV(2), kRGB565(3), kBGR(4), kGray(5); + + @SuppressWarnings("MemberName") private int value; - private PixelFormat(int value) { + PixelFormat(int value) { this.value = value; } @@ -23,12 +25,16 @@ public class VideoMode { return value; } } + private static final PixelFormat[] m_pixelFormatValues = PixelFormat.values(); public static PixelFormat getPixelFormatFromInt(int pixelFormat) { return m_pixelFormatValues[pixelFormat]; } + /** + * Create a new video mode. + */ public VideoMode(int pixelFormat, int width, int height, int fps) { this.pixelFormat = getPixelFormatFromInt(pixelFormat); this.width = width; @@ -36,6 +42,9 @@ public class VideoMode { this.fps = fps; } + /** + * Create a new video mode. + */ public VideoMode(PixelFormat pixelFormat, int width, int height, int fps) { this.pixelFormat = pixelFormat; this.width = width; @@ -44,22 +53,26 @@ public class VideoMode { } /** - * Pixel format + * Pixel format. */ + @SuppressWarnings("MemberName") public PixelFormat pixelFormat; /** - * Width in pixels + * Width in pixels. */ + @SuppressWarnings("MemberName") public int width; /** - * Height in pixels + * Height in pixels. */ + @SuppressWarnings("MemberName") public int height; /** - * Frames per second + * Frames per second. */ + @SuppressWarnings("MemberName") public int fps; } diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoProperty.java b/cscore/src/main/java/edu/wpi/cscore/VideoProperty.java index 84a660db06..3115031277 100644 --- a/cscore/src/main/java/edu/wpi/cscore/VideoProperty.java +++ b/cscore/src/main/java/edu/wpi/cscore/VideoProperty.java @@ -10,9 +10,11 @@ package edu.wpi.cscore; public class VideoProperty { public enum Kind { kNone(0), kBoolean(1), kInteger(2), kString(4), kEnum(8); + + @SuppressWarnings("MemberName") private int value; - private Kind(int value) { + Kind(int value) { this.value = value; } @@ -21,6 +23,12 @@ public class VideoProperty { } } + /** + * Convert from the numerical representation of kind to an enum type. + * + * @param kind The numerical representation of kind + * @return The kind + */ public static Kind getKindFromInt(int kind) { switch (kind) { case 1: return Kind.kBoolean; diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoSink.java b/cscore/src/main/java/edu/wpi/cscore/VideoSink.java index 86e5eb14d6..bf3e5a6f20 100644 --- a/cscore/src/main/java/edu/wpi/cscore/VideoSink.java +++ b/cscore/src/main/java/edu/wpi/cscore/VideoSink.java @@ -15,9 +15,11 @@ package edu.wpi.cscore; public class VideoSink implements AutoCloseable { public enum Kind { kUnknown(0), kMjpeg(2), kCv(4); + + @SuppressWarnings("MemberName") private int value; - private Kind(int value) { + Kind(int value) { this.value = value; } @@ -26,6 +28,12 @@ public class VideoSink implements AutoCloseable { } } + /** + * Convert from the numerical representation of kind to an enum type. + * + * @param kind The numerical representation of kind + * @return The kind + */ public static Kind getKindFromInt(int kind) { switch (kind) { case 2: return Kind.kMjpeg; @@ -59,6 +67,7 @@ public class VideoSink implements AutoCloseable { return m_handle; } + @Override public boolean equals(Object other) { if (this == other) { return true; @@ -73,6 +82,7 @@ public class VideoSink implements AutoCloseable { return m_handle == sink.m_handle; } + @Override public int hashCode() { return m_handle; } @@ -141,7 +151,7 @@ public class VideoSink implements AutoCloseable { public static VideoSink[] enumerateSinks() { int[] handles = CameraServerJNI.enumerateSinks(); VideoSink[] rv = new VideoSink[handles.length]; - for (int i=0; inative declaration : AthenaJava\target\native\include\HAL\Analog.h:58
enum values diff --git a/hal/src/main/java/edu/wpi/first/wpilibj/hal/JNIWrapper.java b/hal/src/main/java/edu/wpi/first/wpilibj/hal/JNIWrapper.java index edac22e20e..e5ba15864a 100644 --- a/hal/src/main/java/edu/wpi/first/wpilibj/hal/JNIWrapper.java +++ b/hal/src/main/java/edu/wpi/first/wpilibj/hal/JNIWrapper.java @@ -7,13 +7,14 @@ package edu.wpi.first.wpilibj.hal; -import edu.wpi.first.wpiutil.RuntimeDetector; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import edu.wpi.first.wpiutil.RuntimeDetector; + /** * Base class for all JNI wrappers. */ diff --git a/ntcore/build.gradle b/ntcore/build.gradle index 75a9152e8a..0d5d0b22f3 100644 --- a/ntcore/build.gradle +++ b/ntcore/build.gradle @@ -44,10 +44,6 @@ model { } } -checkstyle { - sourceSets = [] -} - pmdMain { pmdMain.enabled = false } diff --git a/ntcore/src/dev/java/edu/wpi/first/ntcore/DevMain.java b/ntcore/src/dev/java/edu/wpi/first/ntcore/DevMain.java index 36d6790a55..289a3eefd8 100644 --- a/ntcore/src/dev/java/edu/wpi/first/ntcore/DevMain.java +++ b/ntcore/src/dev/java/edu/wpi/first/ntcore/DevMain.java @@ -11,9 +11,12 @@ import edu.wpi.first.networktables.NetworkTablesJNI; import edu.wpi.first.wpiutil.RuntimeDetector; public class DevMain { - public static void main(String[] args) { - System.out.println("Hello World!"); - System.out.println(RuntimeDetector.getPlatformPath()); - NetworkTablesJNI.flush(NetworkTablesJNI.getDefaultInstance()); - } + /** + * Main method. + */ + public static void main(String[] args) { + System.out.println("Hello World!"); + System.out.println(RuntimeDetector.getPlatformPath()); + NetworkTablesJNI.flush(NetworkTablesJNI.getDefaultInstance()); + } } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/ConnectionInfo.java b/ntcore/src/main/java/edu/wpi/first/networktables/ConnectionInfo.java index eaa897e9e7..5388ebebd5 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/ConnectionInfo.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/ConnectionInfo.java @@ -15,43 +15,49 @@ public final class ConnectionInfo { * The remote identifier (as set on the remote node by * {@link NetworkTableInstance#setNetworkIdentity(String)}). */ + @SuppressWarnings("MemberName") public final String remote_id; /** * The IP address of the remote node. */ + @SuppressWarnings("MemberName") public final String remote_ip; /** * The port number of the remote node. */ + @SuppressWarnings("MemberName") public final int remote_port; /** * The last time any update was received from the remote node (same scale as * returned by {@link NetworkTablesJNI#now()}). */ + @SuppressWarnings("MemberName") public final long last_update; /** * The protocol version being used for this connection. This is in protocol * layer format, so 0x0200 = 2.0, 0x0300 = 3.0). */ + @SuppressWarnings("MemberName") public final int protocol_version; /** Constructor. * This should generally only be used internally to NetworkTables. - * @param remote_id Remote identifier - * @param remote_ip Remote IP address - * @param remote_port Remote port number - * @param last_update Last time an update was received - * @param protocol_version The protocol version used for the connection + * @param remoteId Remote identifier + * @param remoteIp Remote IP address + * @param remotePort Remote port number + * @param lastUpdate Last time an update was received + * @param protocolVersion The protocol version used for the connection */ - public ConnectionInfo(String remote_id, String remote_ip, int remote_port, long last_update, int protocol_version) { - this.remote_id = remote_id; - this.remote_ip = remote_ip; - this.remote_port = remote_port; - this.last_update = last_update; - this.protocol_version = protocol_version; + public ConnectionInfo(String remoteId, String remoteIp, int remotePort, long lastUpdate, + int protocolVersion) { + remote_id = remoteId; + remote_ip = remoteIp; + remote_port = remotePort; + last_update = lastUpdate; + protocol_version = protocolVersion; } } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/ConnectionNotification.java b/ntcore/src/main/java/edu/wpi/first/networktables/ConnectionNotification.java index 8adc6953a9..a5efdcef08 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/ConnectionNotification.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/ConnectionNotification.java @@ -14,16 +14,19 @@ public final class ConnectionNotification { /** * Listener that was triggered. */ + @SuppressWarnings("MemberName") public final int listener; /** * True if event is due to connection being established. */ + @SuppressWarnings("MemberName") public final boolean connected; /** * Connection information. */ + @SuppressWarnings("MemberName") public final ConnectionInfo conn; /** Constructor. @@ -33,16 +36,17 @@ public final class ConnectionNotification { * @param connected Connected if true * @param conn Connection information */ - public ConnectionNotification(NetworkTableInstance inst, int listener, boolean connected, ConnectionInfo conn) { - this.inst = inst; + public ConnectionNotification(NetworkTableInstance inst, int listener, boolean connected, + ConnectionInfo conn) { + this.m_inst = inst; this.listener = listener; this.connected = connected; this.conn = conn; } - private final NetworkTableInstance inst; + private final NetworkTableInstance m_inst; public NetworkTableInstance getInstance() { - return inst; + return m_inst; } } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/EntryInfo.java b/ntcore/src/main/java/edu/wpi/first/networktables/EntryInfo.java index af85d977a3..ef4a328364 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/EntryInfo.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/EntryInfo.java @@ -12,18 +12,23 @@ package edu.wpi.first.networktables; */ public final class EntryInfo { /** Entry handle. */ + @SuppressWarnings("MemberName") public final int entry; /** Entry name. */ + @SuppressWarnings("MemberName") public final String name; /** Entry type. */ + @SuppressWarnings("MemberName") public final NetworkTableType type; /** Entry flags. */ + @SuppressWarnings("MemberName") public final int flags; /** Timestamp of last change to entry (type or value). */ + @SuppressWarnings("MemberName") public final long last_change; /** Constructor. @@ -33,31 +38,32 @@ public final class EntryInfo { * @param name Name * @param type Type (integer version of {@link NetworkTableType}) * @param flags Flags - * @param last_change Timestamp of last change + * @param lastChange Timestamp of last change */ - public EntryInfo(NetworkTableInstance inst, int entry, String name, int type, int flags, long last_change) { - this.inst = inst; + public EntryInfo(NetworkTableInstance inst, int entry, String name, int type, int flags, + long lastChange) { + this.m_inst = inst; this.entry = entry; this.name = name; this.type = NetworkTableType.getFromInt(type); this.flags = flags; - this.last_change = last_change; + this.last_change = lastChange; } /* Network table instance. */ - private final NetworkTableInstance inst; + private final NetworkTableInstance m_inst; /* Cached entry object. */ - private NetworkTableEntry entryObject; + private NetworkTableEntry m_entryObject; /** * Get the entry as an object. * @return NetworkTableEntry for this entry. */ NetworkTableEntry getEntry() { - if (entryObject == null) { - entryObject = new NetworkTableEntry(inst, entry); + if (m_entryObject == null) { + m_entryObject = new NetworkTableEntry(m_inst, entry); } - return entryObject; + return m_entryObject; } } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/EntryListenerFlags.java b/ntcore/src/main/java/edu/wpi/first/networktables/EntryListenerFlags.java index 995e64df1a..9cdc0f0c67 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/EntryListenerFlags.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/EntryListenerFlags.java @@ -10,51 +10,63 @@ package edu.wpi.first.networktables; /** * Flag values for use with entry listeners. * - * The flags are a bitmask and must be OR'ed together to indicate the + *

The flags are a bitmask and must be OR'ed together to indicate the * combination of events desired to be received. * - * The constants kNew, kDelete, kUpdate, and kFlags represent different events + *

The constants kNew, kDelete, kUpdate, and kFlags represent different events * that can occur to entries. * - * By default, notifications are only generated for remote changes occurring + *

By default, notifications are only generated for remote changes occurring * after the listener is created. The constants kImmediate and kLocal are * modifiers that cause notifications to be generated at other times. */ public interface EntryListenerFlags { - /** Initial listener addition. - * Set this flag to receive immediate notification of entries matching the + /** + * Initial listener addition. + * + *

Set this flag to receive immediate notification of entries matching the * flag criteria (generally only useful when combined with kNew). */ - public static final int kImmediate = 0x01; + int kImmediate = 0x01; - /** Changed locally. - * Set this flag to receive notification of both local changes and changes + /** + * Changed locally. + * + *

Set this flag to receive notification of both local changes and changes * coming from remote nodes. By default, notifications are only generated * for remote changes. Must be combined with some combination of kNew, * kDelete, kUpdate, and kFlags to receive notifications of those respective * events. */ - public static final int kLocal = 0x02; + int kLocal = 0x02; - /** Newly created entry. - * Set this flag to receive a notification when an entry is created. + /** + * Newly created entry. + * + *

Set this flag to receive a notification when an entry is created. */ - public static final int kNew = 0x04; + int kNew = 0x04; - /** Entry was deleted. - * Set this flag to receive a notification when an entry is deleted. + /** + * Entry was deleted. + * + *

Set this flag to receive a notification when an entry is deleted. */ - public static final int kDelete = 0x08; + int kDelete = 0x08; - /** Entry's value changed. - * Set this flag to receive a notification when an entry's value (or type) + /** + * Entry's value changed. + * + *

Set this flag to receive a notification when an entry's value (or type) * changes. */ - public static final int kUpdate = 0x10; + int kUpdate = 0x10; - /** Entry's flags changed. - * Set this flag to receive a notification when an entry's flags value + /** + * Entry's flags changed. + * + *

Set this flag to receive a notification when an entry's flags value * changes. */ - public static final int kFlags = 0x20; + int kFlags = 0x20; } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/EntryNotification.java b/ntcore/src/main/java/edu/wpi/first/networktables/EntryNotification.java index 5b12421876..f7c48d53fe 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/EntryNotification.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/EntryNotification.java @@ -14,27 +14,32 @@ public final class EntryNotification { /** * Listener that was triggered. */ + @SuppressWarnings("MemberName") public final int listener; /** * Entry handle. */ + @SuppressWarnings("MemberName") public final int entry; /** * Entry name. */ + @SuppressWarnings("MemberName") public final String name; /** * The new value. */ + @SuppressWarnings("MemberName") public final NetworkTableValue value; /** * Update flags. For example, {@link EntryListenerFlags#kNew} if the key did * not previously exist. */ + @SuppressWarnings("MemberName") public final int flags; /** Constructor. @@ -46,8 +51,9 @@ public final class EntryNotification { * @param value The new value * @param flags Update flags */ - public EntryNotification(NetworkTableInstance inst, int listener, int entry, String name, NetworkTableValue value, int flags) { - this.inst = inst; + public EntryNotification(NetworkTableInstance inst, int listener, int entry, String name, + NetworkTableValue value, int flags) { + this.m_inst = inst; this.listener = listener; this.entry = entry; this.name = name; @@ -56,19 +62,19 @@ public final class EntryNotification { } /* Network table instance. */ - private final NetworkTableInstance inst; + private final NetworkTableInstance m_inst; /* Cached entry object. */ - NetworkTableEntry entryObject; + NetworkTableEntry m_entryObject; /** * Get the entry as an object. * @return NetworkTableEntry for this entry. */ public NetworkTableEntry getEntry() { - if (entryObject == null) { - entryObject = new NetworkTableEntry(inst, entry); + if (m_entryObject == null) { + m_entryObject = new NetworkTableEntry(m_inst, entry); } - return entryObject; + return m_entryObject; } } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/LogMessage.java b/ntcore/src/main/java/edu/wpi/first/networktables/LogMessage.java index 97dc5450cb..e8c85c2d7f 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/LogMessage.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/LogMessage.java @@ -27,26 +27,31 @@ public final class LogMessage { /** * The logger that generated the message. */ + @SuppressWarnings("MemberName") public final int logger; /** * Log level of the message. */ + @SuppressWarnings("MemberName") public final int level; /** * The filename of the source file that generated the message. */ + @SuppressWarnings("MemberName") public final String filename; /** * The line number in the source file that generated the message. */ + @SuppressWarnings("MemberName") public final int line; /** * The message. */ + @SuppressWarnings("MemberName") public final String message; /** Constructor. @@ -58,8 +63,9 @@ public final class LogMessage { * @param line Line number * @param message Message */ - public LogMessage(NetworkTableInstance inst, int logger, int level, String filename, int line, String message) { - this.inst = inst; + public LogMessage(NetworkTableInstance inst, int logger, int level, String filename, int line, + String message) { + this.m_inst = inst; this.logger = logger; this.level = level; this.filename = filename; @@ -67,9 +73,9 @@ public final class LogMessage { this.message = message; } - private final NetworkTableInstance inst; + private final NetworkTableInstance m_inst; NetworkTableInstance getInstance() { - return inst; + return m_inst; } } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTable.java b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTable.java index bdff5eed63..c880d534df 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTable.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTable.java @@ -21,14 +21,14 @@ import java.util.function.Consumer; */ public final class NetworkTable { /** - * The path separator for sub-tables and keys + * The path separator for sub-tables and keys. * */ public static final char PATH_SEPARATOR = '/'; - private final String path; - private final String pathWithSep; - private final NetworkTableInstance inst; + private final String m_path; + private final String m_pathWithSep; + private final NetworkTableInstance m_inst; /** * Gets the "base name" of a key. For example, "/foo/bar" becomes "bar". @@ -121,31 +121,35 @@ public final class NetworkTable { * Constructor. Use NetworkTableInstance.getTable() or getSubTable() instead. */ NetworkTable(NetworkTableInstance inst, String path) { - this.path = path; - this.pathWithSep = path + PATH_SEPARATOR; - this.inst = inst; + m_path = path; + m_pathWithSep = path + PATH_SEPARATOR; + m_inst = inst; } /** * Gets the instance for the table. * @return Instance */ - public NetworkTableInstance getInstance() { return inst; } + public NetworkTableInstance getInstance() { + return m_inst; + } - public String toString() { return "NetworkTable: " + path; } + public String toString() { + return "NetworkTable: " + m_path; + } - private final ConcurrentMap entries = new ConcurrentHashMap(); + private final ConcurrentMap m_entries = new ConcurrentHashMap<>(); /** - * Gets the entry for a subkey. + * Gets the entry for a sub key. * @param key the key name * @return Network table entry. */ public NetworkTableEntry getEntry(String key) { - NetworkTableEntry entry = entries.get(key); + NetworkTableEntry entry = m_entries.get(key); if (entry == null) { - entry = inst.getEntry(pathWithSep + key); - entries.putIfAbsent(key, entry); + entry = m_inst.getEntry(m_pathWithSep + key); + m_entries.putIfAbsent(key, entry); } return entry; } @@ -157,11 +161,13 @@ public final class NetworkTable { * @return Listener handle */ public int addEntryListener(TableEntryListener listener, int flags) { - final int prefixLen = path.length() + 1; - return inst.addEntryListener(pathWithSep, (event) -> { + final int prefixLen = m_path.length() + 1; + return m_inst.addEntryListener(m_pathWithSep, event -> { String relativeKey = event.name.substring(prefixLen); - if (relativeKey.indexOf(PATH_SEPARATOR) != -1) // part of a subtable + if (relativeKey.indexOf(PATH_SEPARATOR) != -1) { + // part of a sub table return; + } listener.valueChanged(this, relativeKey, event.getEntry(), event.value, event.flags); }, flags); } @@ -175,9 +181,8 @@ public final class NetworkTable { */ public int addEntryListener(String key, TableEntryListener listener, int flags) { final NetworkTableEntry entry = getEntry(key); - return inst.addEntryListener(entry, (event) -> { - listener.valueChanged(this, key, entry, event.value, event.flags); - }, flags); + return m_inst.addEntryListener(entry, + event -> listener.valueChanged(this, key, entry, event.value, event.flags), flags); } /** @@ -185,7 +190,7 @@ public final class NetworkTable { * @param listener listener handle */ public void removeEntryListener(int listener) { - inst.removeEntryListener(listener); + m_inst.removeEntryListener(listener); } /** @@ -198,25 +203,28 @@ public final class NetworkTable { */ public int addSubTableListener(TableListener listener, boolean localNotify) { int flags = EntryListenerFlags.kNew | EntryListenerFlags.kImmediate; - if (localNotify) + if (localNotify) { flags |= EntryListenerFlags.kLocal; + } - final int prefixLen = path.length() + 1; + final int prefixLen = m_path.length() + 1; final NetworkTable parent = this; - return inst.addEntryListener(pathWithSep, new Consumer() { - final Set notifiedTables = new HashSet(); + return m_inst.addEntryListener(m_pathWithSep, new Consumer() { + final Set m_notifiedTables = new HashSet<>(); @Override public void accept(EntryNotification event) { String relativeKey = event.name.substring(prefixLen); int endSubTable = relativeKey.indexOf(PATH_SEPARATOR); - if (endSubTable == -1) + if (endSubTable == -1) { return; + } String subTableKey = relativeKey.substring(0, endSubTable); - if (notifiedTables.contains(subTableKey)) + if (m_notifiedTables.contains(subTableKey)) { return; - notifiedTables.add(subTableKey); + } + m_notifiedTables.add(subTableKey); listener.tableCreated(parent, subTableKey, parent.getSubTable(subTableKey)); } }, flags); @@ -227,7 +235,7 @@ public final class NetworkTable { * @param listener listener handle */ public void removeTableListener(int listener) { - inst.removeEntryListener(listener); + m_inst.removeEntryListener(listener); } /** @@ -238,11 +246,11 @@ public final class NetworkTable { * @return a sub table relative to this one */ public NetworkTable getSubTable(String key) { - return new NetworkTable(inst, pathWithSep + key); + return new NetworkTable(m_inst, m_pathWithSep + key); } /** - * Checks the table and tells if it contains the specified key + * Checks the table and tells if it contains the specified key. * * @param key the key to search for * @return true if the table as a value assigned to the given key @@ -252,12 +260,15 @@ public final class NetworkTable { } /** + * Checks the table and tells if it contains the specified sub table. + * * @param key the key to search for - * @return true if there is a subtable with the key which contains at least - * one key/subtable of its own + * @return true if there is a subtable with the key which contains at least one key/subtable of + * its own */ public boolean containsSubTable(String key) { - int[] handles = NetworkTablesJNI.getEntries(inst.getHandle(), pathWithSep + key + PATH_SEPARATOR, 0); + int[] handles = NetworkTablesJNI.getEntries(m_inst.getHandle(), + m_pathWithSep + key + PATH_SEPARATOR, 0); return handles.length != 0; } @@ -267,16 +278,17 @@ public final class NetworkTable { * @return keys currently in the table */ public Set getKeys(int types) { - Set keys = new HashSet(); - int prefixLen = path.length() + 1; - for (EntryInfo info : inst.getEntryInfo(pathWithSep, types)) { + Set keys = new HashSet<>(); + int prefixLen = m_path.length() + 1; + for (EntryInfo info : m_inst.getEntryInfo(m_pathWithSep, types)) { String relativeKey = info.name.substring(prefixLen); - if (relativeKey.indexOf(PATH_SEPARATOR) != -1) + if (relativeKey.indexOf(PATH_SEPARATOR) != -1) { continue; + } keys.add(relativeKey); // populate entries as we go - if (entries.get(relativeKey) == null) { - entries.putIfAbsent(relativeKey, new NetworkTableEntry(inst, info.entry)); + if (m_entries.get(relativeKey) == null) { + m_entries.putIfAbsent(relativeKey, new NetworkTableEntry(m_inst, info.entry)); } } return keys; @@ -295,13 +307,14 @@ public final class NetworkTable { * @return subtables currently in the table */ public Set getSubTables() { - Set keys = new HashSet(); - int prefixLen = path.length() + 1; - for (EntryInfo info : inst.getEntryInfo(pathWithSep, 0)) { + Set keys = new HashSet<>(); + int prefixLen = m_path.length() + 1; + for (EntryInfo info : m_inst.getEntryInfo(m_pathWithSep, 0)) { String relativeKey = info.name.substring(prefixLen); int endSubTable = relativeKey.indexOf(PATH_SEPARATOR); - if (endSubTable == -1) + if (endSubTable == -1) { continue; + } keys.add(relativeKey.substring(0, endSubTable)); } return keys; @@ -318,7 +331,7 @@ public final class NetworkTable { } /** - * Put a value in the table + * Put a value in the table. * * @param key the key to be assigned to * @param value the value that will be assigned @@ -339,21 +352,20 @@ public final class NetworkTable { } /** - * Gets the value associated with a key as an object + * Gets the value associated with a key as an object. * * @param key the key of the value to look up - * @return the value associated with the given key, or nullptr if the key - * does not exist + * @return the value associated with the given key, or nullptr if the key does not exist */ NetworkTableValue getValue(String key) { return getEntry(key).getValue(); } /** - * {@inheritDoc} + * Get the path of the NetworkTable. */ public String getPath() { - return path; + return m_path; } /** @@ -363,7 +375,7 @@ public final class NetworkTable { * @throws PersistentException if error saving file */ public void saveEntries(String filename) throws PersistentException { - inst.saveEntries(filename, pathWithSep); + m_inst.saveEntries(filename, m_pathWithSep); } /** @@ -374,23 +386,23 @@ public final class NetworkTable { * @throws PersistentException if error saving file */ public String[] loadEntries(String filename) throws PersistentException { - return inst.loadEntries(filename, pathWithSep); + return m_inst.loadEntries(filename, m_pathWithSep); } @Override - public boolean equals(Object o) { - if (o == this) { + public boolean equals(Object other) { + if (other == this) { return true; } - if (!(o instanceof NetworkTable)) { + if (!(other instanceof NetworkTable)) { return false; } - NetworkTable other = (NetworkTable) o; - return inst.equals(other.inst) && path.equals(other.path); + NetworkTable ntOther = (NetworkTable) other; + return m_inst.equals(ntOther.m_inst) && m_path.equals(ntOther.m_path); } @Override public int hashCode() { - return Objects.hash(inst, path); + return Objects.hash(m_inst, m_path); } } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableEntry.java b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableEntry.java index d40037d061..e73004f7cb 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableEntry.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableEntry.java @@ -11,7 +11,7 @@ import java.nio.ByteBuffer; import java.util.function.Consumer; /** - * NetworkTables Entry + * NetworkTables Entry. */ public final class NetworkTableEntry { /** @@ -178,7 +178,8 @@ public final class NetworkTableEntry { * @return the entry's value or the given default value */ public Boolean[] getBooleanArray(Boolean[] defaultValue) { - return NetworkTableValue.fromNative(NetworkTablesJNI.getBooleanArray(m_handle, NetworkTableValue.toNative(defaultValue))); + return NetworkTableValue.fromNative(NetworkTablesJNI.getBooleanArray(m_handle, + NetworkTableValue.toNative(defaultValue))); } /** @@ -198,7 +199,8 @@ public final class NetworkTableEntry { * @return the entry's value or the given default value */ public Double[] getDoubleArray(Double[] defaultValue) { - return NetworkTableValue.fromNative(NetworkTablesJNI.getDoubleArray(m_handle, NetworkTableValue.toNative(defaultValue))); + return NetworkTableValue.fromNative(NetworkTablesJNI.getDoubleArray(m_handle, + NetworkTableValue.toNative(defaultValue))); } /** @@ -208,7 +210,8 @@ public final class NetworkTableEntry { * @return the entry's value or the given default value */ public Number[] getNumberArray(Number[] defaultValue) { - return NetworkTableValue.fromNative(NetworkTablesJNI.getDoubleArray(m_handle, NetworkTableValue.toNative(defaultValue))); + return NetworkTableValue.fromNative(NetworkTablesJNI.getDoubleArray(m_handle, + NetworkTableValue.toNative(defaultValue))); } /** @@ -229,46 +232,48 @@ public final class NetworkTableEntry { */ public boolean setDefaultValue(Object defaultValue) { if (defaultValue instanceof NetworkTableValue) { - long time = ((NetworkTableValue)defaultValue).getTime(); - Object o = ((NetworkTableValue)defaultValue).getValue(); - switch (((NetworkTableValue)defaultValue).getType()) { + long time = ((NetworkTableValue) defaultValue).getTime(); + Object otherValue = ((NetworkTableValue) defaultValue).getValue(); + switch (((NetworkTableValue) defaultValue).getType()) { case kBoolean: - return NetworkTablesJNI.setDefaultBoolean(m_handle, time, ((Boolean)o).booleanValue()); + return NetworkTablesJNI.setDefaultBoolean(m_handle, time, + ((Boolean) otherValue).booleanValue()); case kDouble: - return NetworkTablesJNI.setDefaultDouble(m_handle, time, ((Number)o).doubleValue()); + return NetworkTablesJNI.setDefaultDouble(m_handle, time, + ((Number) otherValue).doubleValue()); case kString: - return NetworkTablesJNI.setDefaultString(m_handle, time, (String)o); + return NetworkTablesJNI.setDefaultString(m_handle, time, (String) otherValue); case kRaw: - return NetworkTablesJNI.setDefaultRaw(m_handle, time, (byte[])o); + return NetworkTablesJNI.setDefaultRaw(m_handle, time, (byte[]) otherValue); case kBooleanArray: - return NetworkTablesJNI.setDefaultBooleanArray(m_handle, time, (boolean[])o); + return NetworkTablesJNI.setDefaultBooleanArray(m_handle, time, (boolean[]) otherValue); case kDoubleArray: - return NetworkTablesJNI.setDefaultDoubleArray(m_handle, time, (double[])o); + return NetworkTablesJNI.setDefaultDoubleArray(m_handle, time, (double[]) otherValue); case kStringArray: - return NetworkTablesJNI.setDefaultStringArray(m_handle, time, (String[])o); + return NetworkTablesJNI.setDefaultStringArray(m_handle, time, (String[]) otherValue); case kRpc: // TODO default: return true; } } else if (defaultValue instanceof Boolean) { - return setDefaultBoolean((Boolean)defaultValue); + return setDefaultBoolean((Boolean) defaultValue); } else if (defaultValue instanceof Number) { - return setDefaultNumber((Number)defaultValue); + return setDefaultNumber((Number) defaultValue); } else if (defaultValue instanceof String) { - return setDefaultString((String)defaultValue); - } else if (defaultValue instanceof byte[]) { - return setDefaultRaw((byte[])defaultValue); - } else if (defaultValue instanceof boolean[]) { - return setDefaultBooleanArray((boolean[])defaultValue); - } else if (defaultValue instanceof double[]) { - return setDefaultDoubleArray((double[])defaultValue); - } else if (defaultValue instanceof Boolean[]) { - return setDefaultBooleanArray((Boolean[])defaultValue); - } else if (defaultValue instanceof Number[]) { - return setDefaultNumberArray((Number[])defaultValue); - } else if (defaultValue instanceof String[]) { - return setDefaultStringArray((String[])defaultValue); + return setDefaultString((String) defaultValue); + } else if (defaultValue instanceof byte[]) { + return setDefaultRaw((byte[]) defaultValue); + } else if (defaultValue instanceof boolean[]) { + return setDefaultBooleanArray((boolean[]) defaultValue); + } else if (defaultValue instanceof double[]) { + return setDefaultDoubleArray((double[]) defaultValue); + } else if (defaultValue instanceof Boolean[]) { + return setDefaultBooleanArray((Boolean[]) defaultValue); + } else if (defaultValue instanceof Number[]) { + return setDefaultNumberArray((Number[]) defaultValue); + } else if (defaultValue instanceof String[]) { + return setDefaultStringArray((String[]) defaultValue); } else { throw new IllegalArgumentException("Value of type " + defaultValue.getClass().getName() + " cannot be put into a table"); @@ -335,7 +340,8 @@ public final class NetworkTableEntry { * @return False if the entry exists with a different type */ public boolean setDefaultBooleanArray(Boolean[] defaultValue) { - return NetworkTablesJNI.setDefaultBooleanArray(m_handle, 0, NetworkTableValue.toNative(defaultValue)); + return NetworkTablesJNI.setDefaultBooleanArray(m_handle, + 0, NetworkTableValue.toNative(defaultValue)); } /** @@ -353,7 +359,8 @@ public final class NetworkTableEntry { * @return False if the entry exists with a different type */ public boolean setDefaultNumberArray(Number[] defaultValue) { - return NetworkTablesJNI.setDefaultDoubleArray(m_handle, 0, NetworkTableValue.toNative(defaultValue)); + return NetworkTablesJNI.setDefaultDoubleArray(m_handle, + 0, NetworkTableValue.toNative(defaultValue)); } /** @@ -366,53 +373,55 @@ public final class NetworkTableEntry { } /** - * Sets the entry's value + * Sets the entry's value. * @param value the value that will be assigned * @return False if the table key already exists with a different type * @throws IllegalArgumentException if the value is not a known type */ public boolean setValue(Object value) { if (value instanceof NetworkTableValue) { - long time = ((NetworkTableValue)value).getTime(); - Object o = ((NetworkTableValue)value).getValue(); - switch (((NetworkTableValue)value).getType()) { + long time = ((NetworkTableValue) value).getTime(); + Object otherValue = ((NetworkTableValue) value).getValue(); + switch (((NetworkTableValue) value).getType()) { case kBoolean: - return NetworkTablesJNI.setBoolean(m_handle, time, ((Boolean)o).booleanValue(), false); + return NetworkTablesJNI.setBoolean(m_handle, time, ((Boolean) otherValue).booleanValue(), + false); case kDouble: - return NetworkTablesJNI.setDouble(m_handle, time, ((Number)o).doubleValue(), false); + return NetworkTablesJNI.setDouble(m_handle, time, ((Number) otherValue).doubleValue(), + false); case kString: - return NetworkTablesJNI.setString(m_handle, time, (String)o, false); + return NetworkTablesJNI.setString(m_handle, time, (String) otherValue, false); case kRaw: - return NetworkTablesJNI.setRaw(m_handle, time, (byte[])o, false); + return NetworkTablesJNI.setRaw(m_handle, time, (byte[]) otherValue, false); case kBooleanArray: - return NetworkTablesJNI.setBooleanArray(m_handle, time, (boolean[])o, false); + return NetworkTablesJNI.setBooleanArray(m_handle, time, (boolean[]) otherValue, false); case kDoubleArray: - return NetworkTablesJNI.setDoubleArray(m_handle, time, (double[])o, false); + return NetworkTablesJNI.setDoubleArray(m_handle, time, (double[]) otherValue, false); case kStringArray: - return NetworkTablesJNI.setStringArray(m_handle, time, (String[])o, false); + return NetworkTablesJNI.setStringArray(m_handle, time, (String[]) otherValue, false); case kRpc: // TODO default: return true; } } else if (value instanceof Boolean) { - return setBoolean((Boolean)value); + return setBoolean((Boolean) value); } else if (value instanceof Number) { - return setNumber((Number)value); + return setNumber((Number) value); } else if (value instanceof String) { - return setString((String)value); + return setString((String) value); } else if (value instanceof byte[]) { - return setRaw((byte[])value); + return setRaw((byte[]) value); } else if (value instanceof boolean[]) { - return setBooleanArray((boolean[])value); + return setBooleanArray((boolean[]) value); } else if (value instanceof double[]) { - return setDoubleArray((double[])value); + return setDoubleArray((double[]) value); } else if (value instanceof Boolean[]) { - return setBooleanArray((Boolean[])value); + return setBooleanArray((Boolean[]) value); } else if (value instanceof Number[]) { - return setNumberArray((Number[])value); + return setNumberArray((Number[]) value); } else if (value instanceof String[]) { - return setStringArray((String[])value); + return setStringArray((String[]) value); } else { throw new IllegalArgumentException("Value of type " + value.getClass().getName() + " cannot be put into a table"); @@ -471,10 +480,12 @@ public final class NetworkTableEntry { * @return False if the entry exists with a different type */ public boolean setRaw(ByteBuffer value, int len) { - if (!value.isDirect()) + if (!value.isDirect()) { throw new IllegalArgumentException("must be a direct buffer"); - if (value.capacity() < len) + } + if (value.capacity() < len) { throw new IllegalArgumentException("buffer is too small, must be at least " + len); + } return NetworkTablesJNI.setRaw(m_handle, 0, value, len, false); } @@ -531,29 +542,29 @@ public final class NetworkTableEntry { */ public void forceSetValue(Object value) { if (value instanceof NetworkTableValue) { - long time = ((NetworkTableValue)value).getTime(); - Object o = ((NetworkTableValue)value).getValue(); - switch (((NetworkTableValue)value).getType()) { + long time = ((NetworkTableValue) value).getTime(); + Object otherValue = ((NetworkTableValue) value).getValue(); + switch (((NetworkTableValue) value).getType()) { case kBoolean: - NetworkTablesJNI.setBoolean(m_handle, time, ((Boolean)o).booleanValue(), true); + NetworkTablesJNI.setBoolean(m_handle, time, ((Boolean) otherValue).booleanValue(), true); return; case kDouble: - NetworkTablesJNI.setDouble(m_handle, time, ((Number)o).doubleValue(), true); + NetworkTablesJNI.setDouble(m_handle, time, ((Number) otherValue).doubleValue(), true); return; case kString: - NetworkTablesJNI.setString(m_handle, time, (String)o, true); + NetworkTablesJNI.setString(m_handle, time, (String) otherValue, true); return; case kRaw: - NetworkTablesJNI.setRaw(m_handle, time, (byte[])o, true); + NetworkTablesJNI.setRaw(m_handle, time, (byte[]) otherValue, true); return; case kBooleanArray: - NetworkTablesJNI.setBooleanArray(m_handle, time, (boolean[])o, true); + NetworkTablesJNI.setBooleanArray(m_handle, time, (boolean[]) otherValue, true); return; case kDoubleArray: - NetworkTablesJNI.setDoubleArray(m_handle, time, (double[])o, true); + NetworkTablesJNI.setDoubleArray(m_handle, time, (double[]) otherValue, true); return; case kStringArray: - NetworkTablesJNI.setStringArray(m_handle, time, (String[])o, true); + NetworkTablesJNI.setStringArray(m_handle, time, (String[]) otherValue, true); return; case kRpc: // TODO @@ -561,23 +572,23 @@ public final class NetworkTableEntry { return; } } else if (value instanceof Boolean) { - forceSetBoolean((Boolean)value); + forceSetBoolean((Boolean) value); } else if (value instanceof Number) { - forceSetNumber((Number)value); + forceSetNumber((Number) value); } else if (value instanceof String) { - forceSetString((String)value); + forceSetString((String) value); } else if (value instanceof byte[]) { - forceSetRaw((byte[])value); + forceSetRaw((byte[]) value); } else if (value instanceof boolean[]) { - forceSetBooleanArray((boolean[])value); + forceSetBooleanArray((boolean[]) value); } else if (value instanceof double[]) { - forceSetDoubleArray((double[])value); + forceSetDoubleArray((double[]) value); } else if (value instanceof Boolean[]) { - forceSetBooleanArray((Boolean[])value); + forceSetBooleanArray((Boolean[]) value); } else if (value instanceof Number[]) { - forceSetNumberArray((Number[])value); + forceSetNumberArray((Number[]) value); } else if (value instanceof String[]) { - forceSetStringArray((String[])value); + forceSetStringArray((String[]) value); } else { throw new IllegalArgumentException("Value of type " + value.getClass().getName() + " cannot be put into a table"); @@ -731,8 +742,8 @@ public final class NetworkTableEntry { /** * Call a RPC function. May be used on either the client or server. - * This function is non-blocking. Either {@link RpcCall#GetResult()} or - * {@link RpcCall#CancelResult()} must be called on the return value to either + * This function is non-blocking. Either {@link RpcCall#getResult()} or + * {@link RpcCall#cancelResult()} must be called on the return value to either * get or ignore the result of the call. * @param params parameter * @return RPC call object. @@ -742,7 +753,7 @@ public final class NetworkTableEntry { } /** - * Add a listener for changes to the entry + * Add a listener for changes to the entry. * @param listener the listener to add * @param flags bitmask specifying desired notifications * @return listener handle @@ -752,7 +763,7 @@ public final class NetworkTableEntry { } /** - * Remove a listener from receiving entry events + * Remove a listener from receiving entry events. * @param listener the listener to be removed */ public void removeListener(int listener) { @@ -760,15 +771,15 @@ public final class NetworkTableEntry { } @Override - public boolean equals(Object o) { - if (o == this) { + public boolean equals(Object other) { + if (other == this) { return true; } - if (!(o instanceof NetworkTableEntry)) { + if (!(other instanceof NetworkTableEntry)) { return false; } - NetworkTableEntry other = (NetworkTableEntry) o; - return m_handle == other.m_handle; + + return m_handle == ((NetworkTableEntry) other).m_handle; } @Override diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableInstance.java b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableInstance.java index 758902aca1..ffe477f25c 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableInstance.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableInstance.java @@ -19,18 +19,18 @@ import java.util.function.Consumer; /** * NetworkTables Instance. * - * Instances are completely independent from each other. Table operations on + *

Instances are completely independent from each other. Table operations on * one instance will not be visible to other instances unless the instances are * connected via the network. The main limitation on instances is that you * cannot have two servers on the same network port. The main utility of * instances is for unit testing, but they can also enable one program to * connect to two different NetworkTables networks. * - * The global "default" instance (as returned by {@link #getDefault()}) is + *

The global "default" instance (as returned by {@link #getDefault()}) is * always available, and is intended for the common case when there is only * a single NetworkTables instance being used in the program. * - * Additional instances can be created with the {@link #create()} function. + *

Additional instances can be created with the {@link #create()} function. * A reference must be kept to the NetworkTableInstance returned by this * function to keep it from being garbage collected. */ @@ -89,7 +89,7 @@ public final class NetworkTableInstance implements AutoCloseable { * Get global default instance. * @return Global default instance */ - public synchronized static NetworkTableInstance getDefault() { + public static synchronized NetworkTableInstance getDefault() { if (s_defaultInstance == null) { s_defaultInstance = new NetworkTableInstance(NetworkTablesJNI.getDefaultInstance()); } @@ -131,7 +131,7 @@ public final class NetworkTableInstance implements AutoCloseable { * only return a subset of all entries. * * @param prefix entry name required prefix; only entries whose name - * starts with this string are returned + * starts with this string are returned * @param types bitmask of types; 0 is treated as a "don't care" * @return Array of entries. */ @@ -150,7 +150,7 @@ public final class NetworkTableInstance implements AutoCloseable { * only return a subset of all entries. * * @param prefix entry name required prefix; only entries whose name - * starts with this string are returned + * starts with this string are returned * @param types bitmask of types; 0 is treated as a "don't care" * @return Array of entry information. */ @@ -203,12 +203,12 @@ public final class NetworkTableInstance implements AutoCloseable { */ private static class EntryConsumer { - final NetworkTableEntry entry; - final Consumer consumer; + final NetworkTableEntry m_entry; + final Consumer m_consumer; EntryConsumer(NetworkTableEntry entry, Consumer consumer) { - this.entry = entry; - this.consumer = consumer; + m_entry = entry; + m_consumer = consumer; } } @@ -238,7 +238,8 @@ public final class NetworkTableInstance implements AutoCloseable { m_entryListenerLock.unlock(); } Thread.currentThread().interrupt(); - wasInterrupted = true; // don't try to destroy poller, as its handle is likely no longer valid + // don't try to destroy poller, as its handle is likely no longer valid + wasInterrupted = true; break; } for (EntryNotification event : events) { @@ -250,11 +251,12 @@ public final class NetworkTableInstance implements AutoCloseable { m_entryListenerLock.unlock(); } if (listener != null) { - event.entryObject = listener.entry; + event.m_entryObject = listener.m_entry; try { - listener.consumer.accept(event); + listener.m_consumer.accept(event); } catch (Throwable throwable) { - System.err.println("Unhandled exception during entry listener callback: " + throwable.toString()); + System.err.println("Unhandled exception during entry listener callback: " + + throwable.toString()); throwable.printStackTrace(); } } @@ -305,7 +307,9 @@ public final class NetworkTableInstance implements AutoCloseable { * @param flags {@link EntryListenerFlags} bitmask * @return Listener handle */ - public int addEntryListener(NetworkTableEntry entry, Consumer listener, int flags) { + public int addEntryListener(NetworkTableEntry entry, + Consumer listener, + int flags) { if (!equals(entry.getInstance())) { throw new IllegalArgumentException("entry does not belong to this instance"); } @@ -315,7 +319,8 @@ public final class NetworkTableInstance implements AutoCloseable { m_entryListenerPoller = NetworkTablesJNI.createEntryListenerPoller(m_handle); startEntryListenerThread(); } - int handle = NetworkTablesJNI.addPolledEntryListener(m_entryListenerPoller, entry.getHandle(), flags); + int handle = NetworkTablesJNI.addPolledEntryListener(m_entryListenerPoller, entry.getHandle(), + flags); m_entryListeners.put(handle, new EntryConsumer<>(entry, listener)); return handle; } finally { @@ -354,7 +359,8 @@ public final class NetworkTableInstance implements AutoCloseable { if (timeout < 0) { m_entryListenerWaitQueueCond.await(); } else { - return m_entryListenerWaitQueueCond.await((long) (timeout * 1e9), TimeUnit.NANOSECONDS); + return m_entryListenerWaitQueueCond.await((long) (timeout * 1e9), + TimeUnit.NANOSECONDS); } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); @@ -369,11 +375,13 @@ public final class NetworkTableInstance implements AutoCloseable { } private final ReentrantLock m_connectionListenerLock = new ReentrantLock(); - private final Map> m_connectionListeners = new HashMap<>(); + private final Map> m_connectionListeners + = new HashMap<>(); private Thread m_connectionListenerThread; private int m_connectionListenerPoller; private boolean m_connectionListenerWaitQueue; - private final Condition m_connectionListenerWaitQueueCond = m_connectionListenerLock.newCondition(); + private final Condition m_connectionListenerWaitQueueCond + = m_connectionListenerLock.newCondition(); private void startConnectionListenerThread() { m_connectionListenerThread = new Thread(() -> { @@ -394,7 +402,8 @@ public final class NetworkTableInstance implements AutoCloseable { m_connectionListenerLock.unlock(); } Thread.currentThread().interrupt(); - wasInterrupted = true; // don't try to destroy poller, as its handle is likely no longer valid + // don't try to destroy poller, as its handle is likely no longer valid + wasInterrupted = true; break; } for (ConnectionNotification event : events) { @@ -409,7 +418,8 @@ public final class NetworkTableInstance implements AutoCloseable { try { listener.accept(event); } catch (Throwable throwable) { - System.err.println("Unhandled exception during connection listener callback: " + throwable.toString()); + System.err.println("Unhandled exception during connection listener callback: " + + throwable.toString()); throwable.printStackTrace(); } } @@ -436,14 +446,16 @@ public final class NetworkTableInstance implements AutoCloseable { * @param immediateNotify Notify listener of all existing connections * @return Listener handle */ - public int addConnectionListener(Consumer listener, boolean immediateNotify) { + public int addConnectionListener(Consumer listener, + boolean immediateNotify) { m_connectionListenerLock.lock(); try { if (m_connectionListenerPoller == 0) { m_connectionListenerPoller = NetworkTablesJNI.createConnectionListenerPoller(m_handle); startConnectionListenerThread(); } - int handle = NetworkTablesJNI.addPolledConnectionListener(m_connectionListenerPoller, immediateNotify); + int handle = NetworkTablesJNI.addPolledConnectionListener(m_connectionListenerPoller, + immediateNotify); m_connectionListeners.put(handle, listener); return handle; } finally { @@ -488,7 +500,8 @@ public final class NetworkTableInstance implements AutoCloseable { if (timeout < 0) { m_connectionListenerWaitQueueCond.await(); } else { - return m_connectionListenerWaitQueueCond.await((long) (timeout * 1e9), TimeUnit.NANOSECONDS); + return m_connectionListenerWaitQueueCond.await((long) (timeout * 1e9), + TimeUnit.NANOSECONDS); } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); @@ -532,7 +545,8 @@ public final class NetworkTableInstance implements AutoCloseable { m_rpcCallLock.unlock(); } Thread.currentThread().interrupt(); - wasInterrupted = true; // don't try to destroy poller, as its handle is likely no longer valid + // don't try to destroy poller, as its handle is likely no longer valid + wasInterrupted = true; break; } for (RpcAnswer event : events) { @@ -544,11 +558,12 @@ public final class NetworkTableInstance implements AutoCloseable { m_rpcCallLock.unlock(); } if (listener != null) { - event.entryObject = listener.entry; + event.m_entryObject = listener.m_entry; try { - listener.consumer.accept(event); + listener.m_consumer.accept(event); } catch (Throwable throwable) { - System.err.println("Unhandled exception during RPC callback: " + throwable.toString()); + System.err.println("Unhandled exception during RPC callback: " + + throwable.toString()); throwable.printStackTrace(); } } @@ -707,7 +722,7 @@ public final class NetworkTableInstance implements AutoCloseable { } /** - * Starts a client using the specified server and the default port + * Starts a client using the specified server and the default port. * * @param serverName server name */ @@ -716,7 +731,7 @@ public final class NetworkTableInstance implements AutoCloseable { } /** - * Starts a client using the specified server and port + * Starts a client using the specified server and port. * * @param serverName server name * @param port port to communicate over @@ -992,7 +1007,8 @@ public final class NetworkTableInstance implements AutoCloseable { events = NetworkTablesJNI.pollLogger(this, m_loggerPoller); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); - wasInterrupted = true; // don't try to destroy poller, as its handle is likely no longer valid + // don't try to destroy poller, as its handle is likely no longer valid + wasInterrupted = true; break; } for (LogMessage event : events) { @@ -1007,7 +1023,8 @@ public final class NetworkTableInstance implements AutoCloseable { try { logger.accept(event); } catch (Throwable throwable) { - System.err.println("Unhandled exception during logger callback: " + throwable.toString()); + System.err.println("Unhandled exception during logger callback: " + + throwable.toString()); throwable.printStackTrace(); } } @@ -1106,15 +1123,15 @@ public final class NetworkTableInstance implements AutoCloseable { } @Override - public boolean equals(Object o) { - if (o == this) { + public boolean equals(Object other) { + if (other == this) { return true; } - if (!(o instanceof NetworkTableInstance)) { + if (!(other instanceof NetworkTableInstance)) { return false; } - NetworkTableInstance other = (NetworkTableInstance) o; - return m_handle == other.m_handle; + + return m_handle == ((NetworkTableInstance) other).m_handle; } @Override diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableType.java b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableType.java index 70a09a81fd..54a9f55353 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableType.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableType.java @@ -21,9 +21,10 @@ public enum NetworkTableType { kStringArray(0x40), kRpc(0x80); + @SuppressWarnings("MemberName") private final int value; - private NetworkTableType(int value) { + NetworkTableType(int value) { this.value = value; } @@ -31,6 +32,12 @@ public enum NetworkTableType { return value; } + /** + * Convert from the numerical representation of type to an enum type. + * + * @param value The numerical representation of kind + * @return The kind + */ public static NetworkTableType getFromInt(int value) { switch (value) { case 0x01: return kBoolean; diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableValue.java b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableValue.java index aa4c8567d7..4b6f0c8251 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableValue.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTableValue.java @@ -133,98 +133,98 @@ public final class NetworkTableValue { /** * Get the entry's boolean value. - * @throws ClassCastException if the entry value is not of boolean type. * @return The boolean value. + * @throws ClassCastException if the entry value is not of boolean type. */ public boolean getBoolean() { if (m_type != NetworkTableType.kBoolean) { throw new ClassCastException("cannot convert " + m_type + " to boolean"); } - return ((Boolean)m_value).booleanValue(); + return ((Boolean) m_value).booleanValue(); } /** * Get the entry's double value. - * @throws ClassCastException if the entry value is not of double type. * @return The double value. + * @throws ClassCastException if the entry value is not of double type. */ public double getDouble() { if (m_type != NetworkTableType.kDouble) { throw new ClassCastException("cannot convert " + m_type + " to double"); } - return ((Number)m_value).doubleValue(); + return ((Number) m_value).doubleValue(); } /** * Get the entry's string value. - * @throws ClassCastException if the entry value is not of string type. * @return The string value. + * @throws ClassCastException if the entry value is not of string type. */ public String getString() { if (m_type != NetworkTableType.kString) { throw new ClassCastException("cannot convert " + m_type + " to string"); } - return (String)m_value; + return (String) m_value; } /** * Get the entry's raw value. - * @throws ClassCastException if the entry value is not of raw type. * @return The raw value. + * @throws ClassCastException if the entry value is not of raw type. */ public byte[] getRaw() { if (m_type != NetworkTableType.kRaw) { throw new ClassCastException("cannot convert " + m_type + " to raw"); } - return (byte[])m_value; + return (byte[]) m_value; } /** * Get the entry's rpc definition value. - * @throws ClassCastException if the entry value is not of rpc definition type. * @return The rpc definition value. + * @throws ClassCastException if the entry value is not of rpc definition type. */ public byte[] getRpc() { if (m_type != NetworkTableType.kRpc) { throw new ClassCastException("cannot convert " + m_type + " to rpc"); } - return (byte[])m_value; + return (byte[]) m_value; } /** * Get the entry's boolean array value. - * @throws ClassCastException if the entry value is not of boolean array type. * @return The boolean array value. + * @throws ClassCastException if the entry value is not of boolean array type. */ public boolean[] getBooleanArray() { if (m_type != NetworkTableType.kBooleanArray) { throw new ClassCastException("cannot convert " + m_type + " to boolean array"); } - return (boolean[])m_value; + return (boolean[]) m_value; } /** * Get the entry's double array value. - * @throws ClassCastException if the entry value is not of double array type. * @return The double array value. + * @throws ClassCastException if the entry value is not of double array type. */ public double[] getDoubleArray() { if (m_type != NetworkTableType.kDoubleArray) { throw new ClassCastException("cannot convert " + m_type + " to double array"); } - return (double[])m_value; + return (double[]) m_value; } /** * Get the entry's string array value. - * @throws ClassCastException if the entry value is not of string array type. * @return The string array value. + * @throws ClassCastException if the entry value is not of string array type. */ public String[] getStringArray() { if (m_type != NetworkTableType.kStringArray) { throw new ClassCastException("cannot convert " + m_type + " to string array"); } - return (String[])m_value; + return (String[]) m_value; } /* @@ -422,15 +422,15 @@ public final class NetworkTableValue { } @Override - public boolean equals(Object o) { - if (o == this) { + public boolean equals(Object other) { + if (other == this) { return true; } - if (!(o instanceof NetworkTableValue)) { + if (!(other instanceof NetworkTableValue)) { return false; } - NetworkTableValue other = (NetworkTableValue) o; - return m_type == other.m_type && m_value.equals(other.m_value); + NetworkTableValue ntOther = (NetworkTableValue) other; + return m_type == ntOther.m_type && m_value.equals(ntOther.m_value); } @Override @@ -440,29 +440,33 @@ public final class NetworkTableValue { static boolean[] toNative(Boolean[] arr) { boolean[] out = new boolean[arr.length]; - for (int i = 0; i < arr.length; i++) + for (int i = 0; i < arr.length; i++) { out[i] = arr[i]; + } return out; } static double[] toNative(Number[] arr) { double[] out = new double[arr.length]; - for (int i = 0; i < arr.length; i++) + for (int i = 0; i < arr.length; i++) { out[i] = arr[i].doubleValue(); + } return out; } static Boolean[] fromNative(boolean[] arr) { Boolean[] out = new Boolean[arr.length]; - for (int i = 0; i < arr.length; i++) + for (int i = 0; i < arr.length; i++) { out[i] = arr[i]; + } return out; } static Double[] fromNative(double[] arr) { Double[] out = new Double[arr.length]; - for (int i = 0; i < arr.length; i++) + for (int i = 0; i < arr.length; i++) { out[i] = arr[i]; + } return out; } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTablesJNI.java b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTablesJNI.java index 039bb208ba..f5fe74a79b 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTablesJNI.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/NetworkTablesJNI.java @@ -8,32 +8,35 @@ package edu.wpi.first.networktables; import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.nio.ByteBuffer; + import edu.wpi.first.wpiutil.RuntimeDetector; public final class NetworkTablesJNI { static boolean libraryLoaded = false; static File jniLibrary = null; + static { if (!libraryLoaded) { try { System.loadLibrary("ntcore"); - } catch (UnsatisfiedLinkError e) { + } catch (UnsatisfiedLinkError linkError) { try { String resname = RuntimeDetector.getLibraryResource("ntcore"); InputStream is = NetworkTablesJNI.class.getResourceAsStream(resname); if (is != null) { // create temporary file - if (System.getProperty("os.name").startsWith("Windows")) + if (System.getProperty("os.name").startsWith("Windows")) { jniLibrary = File.createTempFile("NetworkTablesJNI", ".dll"); - else if (System.getProperty("os.name").startsWith("Mac")) + } else if (System.getProperty("os.name").startsWith("Mac")) { jniLibrary = File.createTempFile("libNetworkTablesJNI", ".dylib"); - else + } else { jniLibrary = File.createTempFile("libNetworkTablesJNI", ".so"); + } // flag for delete on exit jniLibrary.deleteOnExit(); OutputStream os = new FileOutputStream(jniLibrary); diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/PersistentException.java b/ntcore/src/main/java/edu/wpi/first/networktables/PersistentException.java index 5542f9cb6e..205b01586d 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/PersistentException.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/PersistentException.java @@ -10,17 +10,12 @@ package edu.wpi.first.networktables; import java.io.IOException; /** - * An exception thrown when persistent load/save fails in a {@link NetworkTable} - * + * An exception thrown when persistent load/save fails in a {@link NetworkTable}. */ public final class PersistentException extends IOException { public static final long serialVersionUID = 0; - /** - * @param message The error message - */ public PersistentException(String message) { super(message); } - } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/RpcAnswer.java b/ntcore/src/main/java/edu/wpi/first/networktables/RpcAnswer.java index 03c6fca4fb..c7659441f8 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/RpcAnswer.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/RpcAnswer.java @@ -12,18 +12,23 @@ package edu.wpi.first.networktables; */ public final class RpcAnswer implements AutoCloseable { /** Entry handle. */ + @SuppressWarnings("MemberName") public final int entry; /** Call handle. */ + @SuppressWarnings("MemberName") public int call; /** Entry name. */ + @SuppressWarnings("MemberName") public final String name; /** Call raw parameters. */ + @SuppressWarnings("MemberName") public final String params; /** Connection that called the RPC. */ + @SuppressWarnings("MemberName") public final ConnectionInfo conn; /** Constructor. @@ -35,8 +40,9 @@ public final class RpcAnswer implements AutoCloseable { * @param params Call raw parameters * @param conn Connection info */ - public RpcAnswer(NetworkTableInstance inst, int entry, int call, String name, String params, ConnectionInfo conn) { - this.inst = inst; + public RpcAnswer(NetworkTableInstance inst, int entry, int call, String name, String params, + ConnectionInfo conn) { + this.m_inst = inst; this.entry = entry; this.call = call; this.name = name; @@ -79,19 +85,19 @@ public final class RpcAnswer implements AutoCloseable { } /* Network table instance. */ - private final NetworkTableInstance inst; + private final NetworkTableInstance m_inst; /* Cached entry object. */ - NetworkTableEntry entryObject; + NetworkTableEntry m_entryObject; /** * Get the entry as an object. * @return NetworkTableEntry for the RPC. */ NetworkTableEntry getEntry() { - if (entryObject == null) { - entryObject = new NetworkTableEntry(inst, entry); + if (m_entryObject == null) { + m_entryObject = new NetworkTableEntry(m_inst, entry); } - return entryObject; + return m_entryObject; } } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/RpcCall.java b/ntcore/src/main/java/edu/wpi/first/networktables/RpcCall.java index d2a37cb9ba..a473957608 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/RpcCall.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/RpcCall.java @@ -10,7 +10,7 @@ package edu.wpi.first.networktables; /** * NetworkTables Remote Procedure Call. */ -public final class RpcCall implements AutoCloseable{ +public final class RpcCall implements AutoCloseable { /** Constructor. * This should generally only be used internally to NetworkTables. * @param entry Entry diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/TableEntryListener.java b/ntcore/src/main/java/edu/wpi/first/networktables/TableEntryListener.java index de451b6947..676e57ea69 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/TableEntryListener.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/TableEntryListener.java @@ -8,7 +8,7 @@ package edu.wpi.first.networktables; /** - * A listener that listens to changes in values in a {@link NetworkTable} + * A listener that listens to changes in values in a {@link NetworkTable}. */ @FunctionalInterface public interface TableEntryListener extends EntryListenerFlags { @@ -20,7 +20,8 @@ public interface TableEntryListener extends EntryListenerFlags { * @param entry the entry associated with the value that changed * @param value the new value * @param flags update flags; for example, EntryListenerFlags.kNew if the key - * did not previously exist in the table + * did not previously exist in the table */ - void valueChanged(NetworkTable table, String key, NetworkTableEntry entry, NetworkTableValue value, int flags); + void valueChanged(NetworkTable table, String key, NetworkTableEntry entry, + NetworkTableValue value, int flags); } diff --git a/ntcore/src/main/java/edu/wpi/first/networktables/TableListener.java b/ntcore/src/main/java/edu/wpi/first/networktables/TableListener.java index 94911a0959..3c686e5b8c 100644 --- a/ntcore/src/main/java/edu/wpi/first/networktables/TableListener.java +++ b/ntcore/src/main/java/edu/wpi/first/networktables/TableListener.java @@ -8,7 +8,7 @@ package edu.wpi.first.networktables; /** - * A listener that listens to new tables in a {@link NetworkTable} + * A listener that listens to new tables in a {@link NetworkTable}. */ @FunctionalInterface public interface TableListener { diff --git a/ntcore/src/main/java/edu/wpi/first/wpilibj/networktables/NetworkTable.java b/ntcore/src/main/java/edu/wpi/first/wpilibj/networktables/NetworkTable.java index aa623fd70c..28c933cc0f 100644 --- a/ntcore/src/main/java/edu/wpi/first/wpilibj/networktables/NetworkTable.java +++ b/ntcore/src/main/java/edu/wpi/first/wpilibj/networktables/NetworkTable.java @@ -7,6 +7,17 @@ package edu.wpi.first.wpilibj.networktables; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.function.Consumer; + import edu.wpi.first.networktables.ConnectionInfo; import edu.wpi.first.networktables.ConnectionNotification; import edu.wpi.first.networktables.EntryInfo; @@ -21,22 +32,13 @@ import edu.wpi.first.wpilibj.tables.IRemote; import edu.wpi.first.wpilibj.tables.IRemoteConnectionListener; import edu.wpi.first.wpilibj.tables.ITable; import edu.wpi.first.wpilibj.tables.ITableListener; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.function.Consumer; /** * A network table that knows its subtable path. * @deprecated Use {@link edu.wpi.first.networktables.NetworkTable} instead. */ @Deprecated +@SuppressWarnings("checkstyle:all") public class NetworkTable implements ITable, IRemote { /** * The path separator for sub-tables and keys diff --git a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemote.java b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemote.java index 6da1c13fc1..22b6f96642 100644 --- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemote.java +++ b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemote.java @@ -9,10 +9,11 @@ package edu.wpi.first.wpilibj.tables; /** - * Represents an object that has a remote connection + * Represents an object that has a remote connection. * @deprecated Use {@link edu.wpi.first.networktables.NetworkTableInstance}. */ @Deprecated +@SuppressWarnings("checkstyle:all") public interface IRemote { /** * Register an object to listen for connection and disconnection events diff --git a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemoteConnectionListener.java b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemoteConnectionListener.java index a8356df48c..a3ff118f75 100644 --- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemoteConnectionListener.java +++ b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemoteConnectionListener.java @@ -10,10 +10,11 @@ package edu.wpi.first.wpilibj.tables; import edu.wpi.first.networktables.ConnectionInfo; /** - * A listener that listens for connection changes in a {@link IRemote} object + * A listener that listens for connection changes in a {@link IRemote} object. * @deprecated Use Consumer<{@link edu.wpi.first.networktables.ConnectionNotification}>. */ @Deprecated +@SuppressWarnings("checkstyle:all") public interface IRemoteConnectionListener { /** * Called when an IRemote is connected diff --git a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITable.java b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITable.java index 7bb6a0b63b..2d0d5d6a40 100644 --- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITable.java +++ b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITable.java @@ -12,10 +12,11 @@ import java.util.Set; /** - * A table whose values can be read and written to + * A table whose values can be read and written to. * @deprecated Use {@link edu.wpi.first.networktables.NetworkTable}. */ @Deprecated +@SuppressWarnings("checkstyle:all") public interface ITable { /** diff --git a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITableListener.java b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITableListener.java index 13ab2715f2..b08312b324 100644 --- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITableListener.java +++ b/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITableListener.java @@ -8,13 +8,14 @@ package edu.wpi.first.wpilibj.tables; /** - * A listener that listens to changes in values in a {@link ITable} + * A listener that listens to changes in values in a {@link ITable}. * @deprecated Use Consumer<{@link edu.wpi.first.networktables.EntryNotification}>, * {@link edu.wpi.first.networktables.TableEntryListener}, or * {@link edu.wpi.first.networktables.TableListener} as appropriate. */ @FunctionalInterface @Deprecated +@SuppressWarnings("checkstyle:all") public interface ITableListener { /** * Called when a key-value pair is changed in a {@link ITable} diff --git a/ntcore/src/test/java/edu/wpi/first/networktables/ConnectionListenerTest.java b/ntcore/src/test/java/edu/wpi/first/networktables/ConnectionListenerTest.java index 10033af05d..81a14d86cc 100644 --- a/ntcore/src/test/java/edu/wpi/first/networktables/ConnectionListenerTest.java +++ b/ntcore/src/test/java/edu/wpi/first/networktables/ConnectionListenerTest.java @@ -9,34 +9,38 @@ package edu.wpi.first.networktables; import java.util.ArrayList; import java.util.List; + import junit.framework.TestCase; public class ConnectionListenerTest extends TestCase { - NetworkTableInstance serverInst; - NetworkTableInstance clientInst; + NetworkTableInstance m_serverInst; + NetworkTableInstance m_clientInst; @Override protected void setUp() throws Exception { - serverInst = NetworkTableInstance.create(); - serverInst.setNetworkIdentity("server"); + m_serverInst = NetworkTableInstance.create(); + m_serverInst.setNetworkIdentity("server"); - clientInst = NetworkTableInstance.create(); - clientInst.setNetworkIdentity("client"); + m_clientInst = NetworkTableInstance.create(); + m_clientInst.setNetworkIdentity("client"); } @Override protected void tearDown() throws Exception { - clientInst.close(); - serverInst.close(); + m_clientInst.close(); + m_serverInst.close(); } + /** + * Connect to the server. + */ private void connect() { - serverInst.startServer("connectionlistenertest.ini", "127.0.0.1", 10000); - clientInst.startClient("127.0.0.1", 10000); + m_serverInst.startServer("connectionlistenertest.ini", "127.0.0.1", 10000); + m_clientInst.startClient("127.0.0.1", 10000); // wait for client to report it's started, then wait another 0.1 sec try { - while ((clientInst.getNetworkMode() & NetworkTableInstance.kNetModeStarting) != 0) { + while ((m_clientInst.getNetworkMode() & NetworkTableInstance.kNetModeStarting) != 0) { Thread.sleep(100); } Thread.sleep(100); @@ -45,9 +49,12 @@ public class ConnectionListenerTest extends TestCase { } } + /** + * Test the JNI. + */ public void testJNI() { // set up the poller - int poller = NetworkTablesJNI.createConnectionListenerPoller(serverInst.getHandle()); + int poller = NetworkTablesJNI.createConnectionListenerPoller(m_serverInst.getHandle()); assertTrue("bad poller handle", poller != 0); int handle = NetworkTablesJNI.addPolledConnectionListener(poller, false); assertTrue("bad listener handle", handle != 0); @@ -56,10 +63,10 @@ public class ConnectionListenerTest extends TestCase { connect(); // get the event - assertTrue(serverInst.waitForConnectionListenerQueue(1.0)); + assertTrue(m_serverInst.waitForConnectionListenerQueue(1.0)); ConnectionNotification[] events = null; try { - events = NetworkTablesJNI.pollConnectionListenerTimeout(serverInst, poller, 0.0); + events = NetworkTablesJNI.pollConnectionListenerTimeout(m_serverInst, poller, 0.0); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); fail("unexpected interrupted exception" + ex); @@ -71,7 +78,7 @@ public class ConnectionListenerTest extends TestCase { assertTrue(events[0].connected); // trigger a disconnect event - clientInst.stopClient(); + m_clientInst.stopClient(); try { Thread.sleep(100); } catch (InterruptedException ex) { @@ -79,9 +86,9 @@ public class ConnectionListenerTest extends TestCase { } // get the event - assertTrue(serverInst.waitForConnectionListenerQueue(1.0)); + assertTrue(m_serverInst.waitForConnectionListenerQueue(1.0)); try { - events = NetworkTablesJNI.pollConnectionListenerTimeout(serverInst, poller, 0.0); + events = NetworkTablesJNI.pollConnectionListenerTimeout(m_serverInst, poller, 0.0); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); fail("unexpected interrupted exception" + ex); @@ -94,24 +101,27 @@ public class ConnectionListenerTest extends TestCase { } + /** + * Test threaded behavior. + */ public void testThreaded() { - serverInst.startServer("connectionlistenertest.ini", "127.0.0.1", 10000); + m_serverInst.startServer("connectionlistenertest.ini", "127.0.0.1", 10000); List events = new ArrayList<>(); - int handle = serverInst.addConnectionListener((event) -> events.add(event), false); + final int handle = m_serverInst.addConnectionListener(events::add, false); // trigger a connect event - clientInst.startClient("127.0.0.1", 10000); + m_clientInst.startClient("127.0.0.1", 10000); // wait for client to report it's started, then wait another 0.1 sec try { - while ((clientInst.getNetworkMode() & NetworkTableInstance.kNetModeStarting) != 0) { + while ((m_clientInst.getNetworkMode() & NetworkTableInstance.kNetModeStarting) != 0) { Thread.sleep(100); } Thread.sleep(100); } catch (InterruptedException ex) { fail("interrupted while waiting for client to start"); } - assertTrue(serverInst.waitForConnectionListenerQueue(1.0)); + assertTrue(m_serverInst.waitForConnectionListenerQueue(1.0)); // get the event assertEquals(events.size(), 1); @@ -120,7 +130,7 @@ public class ConnectionListenerTest extends TestCase { events.clear(); // trigger a disconnect event - clientInst.stopClient(); + m_clientInst.stopClient(); try { Thread.sleep(100); } catch (InterruptedException ex) { @@ -128,7 +138,7 @@ public class ConnectionListenerTest extends TestCase { } // get the event - assertTrue(serverInst.waitForConnectionListenerQueue(1.0)); + assertTrue(m_serverInst.waitForConnectionListenerQueue(1.0)); assertEquals(events.size(), 1); assertEquals(handle, events.get(0).listener); assertFalse(events.get(0).connected); diff --git a/ntcore/src/test/java/edu/wpi/first/networktables/EntryListenerTest.java b/ntcore/src/test/java/edu/wpi/first/networktables/EntryListenerTest.java index 18b992a1f3..7c510246e8 100644 --- a/ntcore/src/test/java/edu/wpi/first/networktables/EntryListenerTest.java +++ b/ntcore/src/test/java/edu/wpi/first/networktables/EntryListenerTest.java @@ -9,36 +9,37 @@ package edu.wpi.first.networktables; import java.util.ArrayList; import java.util.List; + import junit.framework.TestCase; public class EntryListenerTest extends TestCase { - NetworkTableInstance serverInst; - NetworkTableInstance clientInst; + NetworkTableInstance m_serverInst; + NetworkTableInstance m_clientInst; @Override protected void setUp() throws Exception { - serverInst = NetworkTableInstance.create(); - serverInst.setNetworkIdentity("server"); + m_serverInst = NetworkTableInstance.create(); + m_serverInst.setNetworkIdentity("server"); - clientInst = NetworkTableInstance.create(); - clientInst.setNetworkIdentity("client"); + m_clientInst = NetworkTableInstance.create(); + m_clientInst.setNetworkIdentity("client"); } @Override protected void tearDown() throws Exception { - clientInst.close(); - serverInst.close(); + m_clientInst.close(); + m_serverInst.close(); } private void connect() { - serverInst.startServer("connectionlistenertest.ini", "127.0.0.1", 10000); - clientInst.startClient("127.0.0.1", 10000); + m_serverInst.startServer("connectionlistenertest.ini", "127.0.0.1", 10000); + m_clientInst.startClient("127.0.0.1", 10000); // Use connection listener to ensure we've connected - int poller = NetworkTablesJNI.createConnectionListenerPoller(clientInst.getHandle()); + int poller = NetworkTablesJNI.createConnectionListenerPoller(m_clientInst.getHandle()); NetworkTablesJNI.addPolledConnectionListener(poller, false); try { - if (NetworkTablesJNI.pollConnectionListenerTimeout(clientInst, poller, 1.0).length == 0) { + if (NetworkTablesJNI.pollConnectionListenerTimeout(m_clientInst, poller, 1.0).length == 0) { fail("client didn't connect to server"); } } catch (InterruptedException ex) { @@ -47,28 +48,31 @@ public class EntryListenerTest extends TestCase { } } + /** + * Test prefix with a new remote. + */ public void testPrefixNewRemote() { connect(); List events = new ArrayList<>(); - int handle = serverInst.addEntryListener("/foo", (event) -> events.add(event), + final int handle = m_serverInst.addEntryListener("/foo", events::add, EntryListenerFlags.kNew); // Trigger an event - clientInst.getEntry("/foo/bar").setDouble(1.0); - clientInst.getEntry("/baz").setDouble(1.0); - clientInst.flush(); + m_clientInst.getEntry("/foo/bar").setDouble(1.0); + m_clientInst.getEntry("/baz").setDouble(1.0); + m_clientInst.flush(); try { Thread.sleep(100); } catch (InterruptedException ex) { fail("interrupted while waiting for entries to update"); } - assertTrue(serverInst.waitForEntryListenerQueue(1.0)); + assertTrue(m_serverInst.waitForEntryListenerQueue(1.0)); // Check the event assertEquals(events.size(), 1); assertEquals(events.get(0).listener, handle); - assertEquals(events.get(0).getEntry(), serverInst.getEntry("/foo/bar")); + assertEquals(events.get(0).getEntry(), m_serverInst.getEntry("/foo/bar")); assertEquals(events.get(0).name, "/foo/bar"); assertEquals(events.get(0).value, NetworkTableValue.makeDouble(1.0)); assertEquals(events.get(0).flags, EntryListenerFlags.kNew); diff --git a/ntcore/src/test/java/edu/wpi/first/networktables/LoggerTest.java b/ntcore/src/test/java/edu/wpi/first/networktables/LoggerTest.java index d02b2afc76..a31d9233c0 100644 --- a/ntcore/src/test/java/edu/wpi/first/networktables/LoggerTest.java +++ b/ntcore/src/test/java/edu/wpi/first/networktables/LoggerTest.java @@ -9,30 +9,34 @@ package edu.wpi.first.networktables; import java.util.ArrayList; import java.util.List; + import junit.framework.TestCase; public class LoggerTest extends TestCase { - NetworkTableInstance clientInst; + NetworkTableInstance m_clientInst; @Override protected void setUp() throws Exception { - clientInst = NetworkTableInstance.create(); + m_clientInst = NetworkTableInstance.create(); } @Override protected void tearDown() throws Exception { - clientInst.close(); + m_clientInst.close(); } + /** + * Test the logger. + */ public void testLogger() { List msgs = new ArrayList<>(); - clientInst.addLogger((msg) -> msgs.add(msg), LogMessage.kInfo, 100); + m_clientInst.addLogger(msgs::add, LogMessage.kInfo, 100); - clientInst.startClient("127.0.0.1", 10000); + m_clientInst.startClient("127.0.0.1", 10000); // wait for client to report it's started, then wait another 0.1 sec try { - while ((clientInst.getNetworkMode() & NetworkTableInstance.kNetModeStarting) != 0) { + while ((m_clientInst.getNetworkMode() & NetworkTableInstance.kNetModeStarting) != 0) { Thread.sleep(100); } Thread.sleep(100); diff --git a/ntcore/src/test/java/edu/wpi/first/networktables/NetworkTableTest.java b/ntcore/src/test/java/edu/wpi/first/networktables/NetworkTableTest.java index ba6f14a103..91eeb8656c 100644 --- a/ntcore/src/test/java/edu/wpi/first/networktables/NetworkTableTest.java +++ b/ntcore/src/test/java/edu/wpi/first/networktables/NetworkTableTest.java @@ -9,6 +9,7 @@ package edu.wpi.first.networktables; import java.util.ArrayList; import java.util.List; + import junit.framework.TestCase; public class NetworkTableTest extends TestCase { diff --git a/styleguide/checkstyle.xml b/styleguide/checkstyle.xml index b92bd008a1..346eed324c 100644 --- a/styleguide/checkstyle.xml +++ b/styleguide/checkstyle.xml @@ -60,6 +60,16 @@ module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" + + + + + + @@ -72,10 +82,7 @@ module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH" /> - - - + + diff --git a/styleguide/checkstyleExamples.xml b/styleguide/checkstyleExamples.xml deleted file mode 100644 index 99aabc8ef2..0000000000 --- a/styleguide/checkstyleExamples.xml +++ /dev/null @@ -1,290 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/styleguide/suppressions.xml b/styleguide/suppressions.xml index 80e5a1b0d0..c2cd3479d0 100644 --- a/styleguide/suppressions.xml +++ b/styleguide/suppressions.xml @@ -5,6 +5,8 @@ suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" - + + diff --git a/wpilibj/src/dev/java/edu/wpi/first/wpilibj/DevMain.java b/wpilibj/src/dev/java/edu/wpi/first/wpilibj/DevMain.java index fbab67352e..240a182c62 100644 --- a/wpilibj/src/dev/java/edu/wpi/first/wpilibj/DevMain.java +++ b/wpilibj/src/dev/java/edu/wpi/first/wpilibj/DevMain.java @@ -8,8 +8,8 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.networktables.NetworkTablesJNI; -import edu.wpi.first.wpiutil.RuntimeDetector; import edu.wpi.first.wpilibj.hal.HALUtil; +import edu.wpi.first.wpiutil.RuntimeDetector; public class DevMain { /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java index 072b680b7b..fe3ce6ac89 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogInput.java @@ -9,8 +9,8 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.wpilibj.hal.AnalogJNI; import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType; -import edu.wpi.first.wpilibj.sim.AnalogInSim; import edu.wpi.first.wpilibj.hal.HAL; +import edu.wpi.first.wpilibj.sim.AnalogInSim; import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; import edu.wpi.first.wpilibj.util.AllocationException; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java index 1af1c87cd5..0aae1d5ae7 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/AnalogOutput.java @@ -9,8 +9,8 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.wpilibj.hal.AnalogJNI; import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType; -import edu.wpi.first.wpilibj.sim.AnalogOutSim; import edu.wpi.first.wpilibj.hal.HAL; +import edu.wpi.first.wpilibj.sim.AnalogOutSim; import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java index aa9943b687..a3b3b3c2f0 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java @@ -193,7 +193,7 @@ public class Compressor extends SendableBase { @Override public void initSendable(SendableBuilder builder) { builder.setSmartDashboardType("Compressor"); - builder.addBooleanProperty("Enabled", this::enabled, (value) -> { + builder.addBooleanProperty("Enabled", this::enabled, value -> { if (value) { start(); } else { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java index 04ce144be2..24f7b336f9 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilter.java @@ -12,8 +12,8 @@ import java.util.concurrent.locks.ReentrantLock; import edu.wpi.first.wpilibj.hal.DigitalGlitchFilterJNI; import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; import edu.wpi.first.wpilibj.hal.HAL; +import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; /** * Class to enable glitch filtering on a set of digital inputs. This class will manage adding and diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java index 8f8bcd5014..e7aa34d69a 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java @@ -166,7 +166,7 @@ public class DoubleSolenoid extends SolenoidBase { public void initSendable(SendableBuilder builder) { builder.setSmartDashboardType("Double Solenoid"); builder.setSafeState(() -> set(Value.kOff)); - builder.addStringProperty("Value", () -> get().name().substring(1), (value) -> { + builder.addStringProperty("Value", () -> get().name().substring(1), value -> { if ("Forward".equals(value)) { set(Value.kForward); } else if ("Reverse".equals(value)) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/GenericHID.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/GenericHID.java index ab4dff08f2..6b3ef31cfe 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/GenericHID.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/GenericHID.java @@ -7,10 +7,11 @@ package edu.wpi.first.wpilibj; -import edu.wpi.first.wpilibj.hal.HAL; import java.util.HashMap; import java.util.Map; +import edu.wpi.first.wpilibj.hal.HAL; + /** * GenericHID Interface. */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java index 12aa795343..7201d545f8 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java @@ -7,14 +7,14 @@ package edu.wpi.first.wpilibj; +import java.util.Arrays; +import java.util.Optional; + import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType; import edu.wpi.first.wpilibj.hal.HAL; import edu.wpi.first.wpilibj.hal.RelayJNI; import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; -import java.util.Arrays; -import java.util.Optional; - import static java.util.Objects.requireNonNull; /** @@ -334,6 +334,6 @@ public class Relay extends SendableBase implements MotorSafety { builder.setSmartDashboardType("Relay"); builder.setSafeState(() -> set(Value.kOff)); builder.addStringProperty("Value", () -> get().getPrettyValue(), - (value) -> set(Value.getValueOf(value).orElse(Value.kOff))); + value -> set(Value.getValueOf(value).orElse(Value.kOff))); } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/buttons/Trigger.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/buttons/Trigger.java index ae213b4f64..1e686950d4 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/buttons/Trigger.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/buttons/Trigger.java @@ -183,11 +183,7 @@ public abstract class Trigger extends SendableBase { @Override public void initSendable(SendableBuilder builder) { builder.setSmartDashboardType("Button"); - builder.setSafeState(() -> { - m_sendablePressed = false; - }); - builder.addBooleanProperty("pressed", this::grab, (value) -> { - m_sendablePressed = value; - }); + builder.setSafeState(() -> m_sendablePressed = false); + builder.addBooleanProperty("pressed", this::grab, value -> m_sendablePressed = value); } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Command.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Command.java index 027d3c8d3c..ab8c9835b7 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Command.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/command/Command.java @@ -555,7 +555,7 @@ public abstract class Command extends SendableBase { public void initSendable(SendableBuilder builder) { builder.setSmartDashboardType("Command"); builder.addStringProperty(".name", this::getName, null); - builder.addBooleanProperty("running", this::isRunning, (value) -> { + builder.addBooleanProperty("running", this::isRunning, value -> { if (value) { if (!isRunning()) { start(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java index 689c1586dd..a0d65203da 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java @@ -13,9 +13,9 @@ import java.util.Map; import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableEntry; import edu.wpi.first.networktables.NetworkTableInstance; +import edu.wpi.first.wpilibj.Sendable; import edu.wpi.first.wpilibj.command.Scheduler; import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl; -import edu.wpi.first.wpilibj.Sendable; /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindowSendable.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindowSendable.java index ecb45babc1..85d88c3a9f 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindowSendable.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindowSendable.java @@ -7,8 +7,8 @@ package edu.wpi.first.wpilibj.livewindow; -import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder; /** * Live Window Sendable is a special type of object sendable to the live window. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilder.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilder.java index c9ef49220d..d143082dc7 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilder.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilder.java @@ -7,14 +7,15 @@ package edu.wpi.first.wpilibj.smartdashboard; -import edu.wpi.first.networktables.NetworkTableEntry; -import edu.wpi.first.networktables.NetworkTableValue; import java.util.function.BooleanSupplier; import java.util.function.Consumer; import java.util.function.DoubleConsumer; import java.util.function.DoubleSupplier; import java.util.function.Supplier; +import edu.wpi.first.networktables.NetworkTableEntry; +import edu.wpi.first.networktables.NetworkTableValue; + public interface SendableBuilder { /** * Set the string representation of the named data type that will be used diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java index 95d2e6c9bc..0b16c403f9 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java @@ -7,18 +7,19 @@ package edu.wpi.first.wpilibj.smartdashboard; -import edu.wpi.first.networktables.EntryListenerFlags; -import edu.wpi.first.networktables.NetworkTable; -import edu.wpi.first.networktables.NetworkTableEntry; -import edu.wpi.first.networktables.NetworkTableValue; +import java.util.ArrayList; +import java.util.List; import java.util.function.BooleanSupplier; import java.util.function.Consumer; import java.util.function.DoubleConsumer; import java.util.function.DoubleSupplier; import java.util.function.Function; import java.util.function.Supplier; -import java.util.ArrayList; -import java.util.List; + +import edu.wpi.first.networktables.EntryListenerFlags; +import edu.wpi.first.networktables.NetworkTable; +import edu.wpi.first.networktables.NetworkTableEntry; +import edu.wpi.first.networktables.NetworkTableValue; public class SendableBuilderImpl implements SendableBuilder { private static class Property { @@ -185,10 +186,10 @@ public class SendableBuilderImpl implements SendableBuilder { public void addBooleanProperty(String key, BooleanSupplier getter, BooleanConsumer setter) { Property property = new Property(m_table, key); if (getter != null) { - property.m_update = (entry) -> entry.setBoolean(getter.getAsBoolean()); + property.m_update = entry -> entry.setBoolean(getter.getAsBoolean()); } if (setter != null) { - property.m_createListener = (entry) -> entry.addListener((event) -> { + property.m_createListener = entry -> entry.addListener(event -> { if (event.value.isBoolean()) { setter.accept(event.value.getBoolean()); } @@ -208,10 +209,10 @@ public class SendableBuilderImpl implements SendableBuilder { public void addDoubleProperty(String key, DoubleSupplier getter, DoubleConsumer setter) { Property property = new Property(m_table, key); if (getter != null) { - property.m_update = (entry) -> entry.setDouble(getter.getAsDouble()); + property.m_update = entry -> entry.setDouble(getter.getAsDouble()); } if (setter != null) { - property.m_createListener = (entry) -> entry.addListener((event) -> { + property.m_createListener = entry -> entry.addListener(event -> { if (event.value.isDouble()) { setter.accept(event.value.getDouble()); } @@ -231,10 +232,10 @@ public class SendableBuilderImpl implements SendableBuilder { public void addStringProperty(String key, Supplier getter, Consumer setter) { Property property = new Property(m_table, key); if (getter != null) { - property.m_update = (entry) -> entry.setString(getter.get()); + property.m_update = entry -> entry.setString(getter.get()); } if (setter != null) { - property.m_createListener = (entry) -> entry.addListener((event) -> { + property.m_createListener = entry -> entry.addListener(event -> { if (event.value.isString()) { setter.accept(event.value.getString()); } @@ -255,10 +256,10 @@ public class SendableBuilderImpl implements SendableBuilder { Consumer setter) { Property property = new Property(m_table, key); if (getter != null) { - property.m_update = (entry) -> entry.setBooleanArray(getter.get()); + property.m_update = entry -> entry.setBooleanArray(getter.get()); } if (setter != null) { - property.m_createListener = (entry) -> entry.addListener((event) -> { + property.m_createListener = entry -> entry.addListener(event -> { if (event.value.isBooleanArray()) { setter.accept(event.value.getBooleanArray()); } @@ -279,10 +280,10 @@ public class SendableBuilderImpl implements SendableBuilder { Consumer setter) { Property property = new Property(m_table, key); if (getter != null) { - property.m_update = (entry) -> entry.setDoubleArray(getter.get()); + property.m_update = entry -> entry.setDoubleArray(getter.get()); } if (setter != null) { - property.m_createListener = (entry) -> entry.addListener((event) -> { + property.m_createListener = entry -> entry.addListener(event -> { if (event.value.isDoubleArray()) { setter.accept(event.value.getDoubleArray()); } @@ -303,10 +304,10 @@ public class SendableBuilderImpl implements SendableBuilder { Consumer setter) { Property property = new Property(m_table, key); if (getter != null) { - property.m_update = (entry) -> entry.setStringArray(getter.get()); + property.m_update = entry -> entry.setStringArray(getter.get()); } if (setter != null) { - property.m_createListener = (entry) -> entry.addListener((event) -> { + property.m_createListener = entry -> entry.addListener(event -> { if (event.value.isStringArray()) { setter.accept(event.value.getStringArray()); } @@ -326,10 +327,10 @@ public class SendableBuilderImpl implements SendableBuilder { public void addRawProperty(String key, Supplier getter, Consumer setter) { Property property = new Property(m_table, key); if (getter != null) { - property.m_update = (entry) -> entry.setRaw(getter.get()); + property.m_update = entry -> entry.setRaw(getter.get()); } if (setter != null) { - property.m_createListener = (entry) -> entry.addListener((event) -> { + property.m_createListener = entry -> entry.addListener(event -> { if (event.value.isRaw()) { setter.accept(event.value.getRaw()); } @@ -350,10 +351,10 @@ public class SendableBuilderImpl implements SendableBuilder { Consumer setter) { Property property = new Property(m_table, key); if (getter != null) { - property.m_update = (entry) -> entry.setValue(getter.get()); + property.m_update = entry -> entry.setValue(getter.get()); } if (setter != null) { - property.m_createListener = (entry) -> entry.addListener((event) -> { + property.m_createListener = entry -> entry.addListener(event -> { setter.accept(event.value); }, EntryListenerFlags.kImmediate | EntryListenerFlags.kNew | EntryListenerFlags.kUpdate); } diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/SpeedControllerGroupTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/SpeedControllerGroupTest.java index 3af8a666f0..0c1cc739b3 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/SpeedControllerGroupTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/SpeedControllerGroupTest.java @@ -7,13 +7,13 @@ package edu.wpi.first.wpilibj; +import java.util.Arrays; +import java.util.Collection; + import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import java.util.Arrays; -import java.util.Collection; - import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/UnitTestUtility.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/UnitTestUtility.java index a7c6f8e668..a601aa9685 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/UnitTestUtility.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/UnitTestUtility.java @@ -7,10 +7,10 @@ package edu.wpi.first.wpilibj; -import com.google.common.base.Stopwatch; - import java.util.concurrent.TimeUnit; +import com.google.common.base.Stopwatch; + import edu.wpi.first.wpilibj.hal.HAL; import edu.wpi.first.wpilibj.util.BaseSystemNotInitializedException; diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/CommandSequentialGroupTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/CommandSequentialGroupTest.java index 5d41b929b5..a7ecca45aa 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/CommandSequentialGroupTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/CommandSequentialGroupTest.java @@ -7,10 +7,10 @@ package edu.wpi.first.wpilibj.command; -import org.junit.Test; - import java.util.logging.Logger; +import org.junit.Test; + /** * Ported from the old CrioTest Classes. */ diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/CommandSupersedeTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/CommandSupersedeTest.java index 7c09a57886..0373d58b18 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/CommandSupersedeTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/CommandSupersedeTest.java @@ -7,10 +7,10 @@ package edu.wpi.first.wpilibj.command; -import org.junit.Test; - import java.util.logging.Logger; +import org.junit.Test; + /** * Ported from the old CrioTest Classes. */ diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/ConditionalCommandTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/ConditionalCommandTest.java index 878854b762..8a1c720cc7 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/ConditionalCommandTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/command/ConditionalCommandTest.java @@ -7,12 +7,13 @@ package edu.wpi.first.wpilibj.command; +import org.junit.Before; +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.junit.Before; //import org.junit.Ignore; -import org.junit.Test; public class ConditionalCommandTest extends AbstractCommandTest { MockConditionalCommand m_command; diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/hal/JNITest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/hal/JNITest.java index 89a8bd337f..097a7080b5 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/hal/JNITest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/hal/JNITest.java @@ -7,9 +7,10 @@ package edu.wpi.first.wpilibj.hal; -import edu.wpi.first.networktables.NetworkTablesJNI; import org.junit.Test; +import edu.wpi.first.networktables.NetworkTablesJNI; + public class JNITest { @Test public void jniNtcoreLinkTest() { diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogInputSimTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogInputSimTest.java index ee4a50e13f..3292da8d67 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogInputSimTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogInputSimTest.java @@ -7,18 +7,18 @@ package edu.wpi.first.wpilibj.sim; -import static org.junit.Assert.assertEquals; - import org.junit.Test; import edu.wpi.first.wpilibj.AnalogInput; import edu.wpi.first.wpilibj.hal.HAL; +import static org.junit.Assert.assertEquals; + public class AnalogInputSimTest { static class DoubleStore { - public boolean wasTriggered = false; - public boolean wasCorrectType = false; - public double setValue = 0; + public boolean m_wasTriggered = false; + public boolean m_wasCorrectType = false; + public double m_setValue = 0; } @Test @@ -30,7 +30,7 @@ public class AnalogInputSimTest { AnalogInSim inputSim = input.getSimObject(); - for (double i = 0; i < 5.0; i+=0.1) { + for (double i = 0; i < 5.0; i += 0.1) { inputSim.setVoltage(0); assertEquals(input.getVoltage(), 0, 0.001); diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogOutputSimTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogOutputSimTest.java index 08850d4d0b..3a537c9655 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogOutputSimTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/sim/AnalogOutputSimTest.java @@ -7,25 +7,25 @@ package edu.wpi.first.wpilibj.sim; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import org.junit.Test; import edu.wpi.first.wpilibj.AnalogOutput; import edu.wpi.first.wpilibj.hal.HAL; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class AnalogOutputSimTest { static class DoubleStore { - public boolean wasTriggered = false; - public boolean wasCorrectType = false; - public double setValue = -1; + public boolean m_wasTriggered = false; + public boolean m_wasCorrectType = false; + public double m_setValue = -1; public void reset() { - wasCorrectType = false; - wasTriggered = false; - setValue = -1; + m_wasCorrectType = false; + m_wasTriggered = false; + m_setValue = -1; } } @@ -41,27 +41,27 @@ public class AnalogOutputSimTest { DoubleStore store = new DoubleStore(); - try (CallbackStore cb = outputSim.registerVoltageCallback((s, v) -> { - store.wasTriggered = true; - store.wasCorrectType = true; - store.setValue = v.getDouble(); + try (CallbackStore cb = outputSim.registerVoltageCallback((name, value) -> { + store.m_wasTriggered = true; + store.m_wasCorrectType = true; + store.m_setValue = value.getDouble(); }, false)) { - assertFalse(store.wasTriggered); + assertFalse(store.m_wasTriggered); - for (double i = 0.1; i < 5.0; i+=0.1) { + for (double i = 0.1; i < 5.0; i += 0.1) { store.reset(); output.setVoltage(0); - assertTrue(store.wasTriggered); - assertEquals(store.setValue, 0, 0.001); + assertTrue(store.m_wasTriggered); + assertEquals(store.m_setValue, 0, 0.001); store.reset(); output.setVoltage(i); - assertTrue(store.wasTriggered); - assertEquals(store.setValue, i, 0.001); + assertTrue(store.m_wasTriggered); + assertEquals(store.m_setValue, i, 0.001); } } diff --git a/wpilibjExamples/build.gradle b/wpilibjExamples/build.gradle index 371346df3e..34b68dcad2 100644 --- a/wpilibjExamples/build.gradle +++ b/wpilibjExamples/build.gradle @@ -21,10 +21,6 @@ dependencies { compile project(':cameraserver') } -checkstyle { - configFile = new File(rootDir, "styleguide/checkstyleExamples.xml") -} - pmd { consoleOutput = true reportsDir = file("$project.buildDir/reports/pmd") diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/commandgroup/ReplaceMeCommandGroup.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/commandgroup/ReplaceMeCommandGroup.java index 8a5304f890..d1dae8c929 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/commandgroup/ReplaceMeCommandGroup.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/commandgroup/ReplaceMeCommandGroup.java @@ -10,6 +10,9 @@ package edu.wpi.first.wpilibj.commands.commandgroup; import edu.wpi.first.wpilibj.command.CommandGroup; public class ReplaceMeCommandGroup extends CommandGroup { + /** + * Add your docs here. + */ public ReplaceMeCommandGroup() { // Add Commands here: // e.g. addSequential(new Command1()); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/instant/ReplaceMeInstantCommand.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/instant/ReplaceMeInstantCommand.java index 167a13b817..bf24a14955 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/instant/ReplaceMeInstantCommand.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/instant/ReplaceMeInstantCommand.java @@ -13,6 +13,9 @@ import edu.wpi.first.wpilibj.command.InstantCommand; * Add your docs here. */ public class ReplaceMeInstantCommand extends InstantCommand { + /** + * Add your docs here. + */ public ReplaceMeInstantCommand() { super(); // Use requires() here to declare subsystem dependencies diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/pidsubsystem/ReplaceMePIDSubsystem.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/pidsubsystem/ReplaceMePIDSubsystem.java index 3eff99de53..46d75f68a0 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/pidsubsystem/ReplaceMePIDSubsystem.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/pidsubsystem/ReplaceMePIDSubsystem.java @@ -13,7 +13,9 @@ import edu.wpi.first.wpilibj.command.PIDSubsystem; * Add your docs here. */ public class ReplaceMePIDSubsystem extends PIDSubsystem { - // Initialize your subsystem here + /** + * Add your docs here. + */ public ReplaceMePIDSubsystem() { // Intert a subsystem name and PID values here super("SubsystemName", 1, 2, 3); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/timed/ReplaceMeTimedCommand.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/timed/ReplaceMeTimedCommand.java index ea92b2ec12..41ba9653d7 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/timed/ReplaceMeTimedCommand.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/timed/ReplaceMeTimedCommand.java @@ -13,6 +13,9 @@ import edu.wpi.first.wpilibj.command.TimedCommand; * Add your docs here. */ public class ReplaceMeTimedCommand extends TimedCommand { + /** + * Add your docs here. + */ public ReplaceMeTimedCommand(double timeout) { super(timeout); // Use requires() here to declare subsystem dependencies diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/axiscamera/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/axiscamera/Robot.java index 0e98a2fec2..f3082b829e 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/axiscamera/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/axiscamera/Robot.java @@ -7,15 +7,16 @@ package edu.wpi.first.wpilibj.examples.axiscamera; +import org.opencv.core.Mat; +import org.opencv.core.Point; +import org.opencv.core.Scalar; +import org.opencv.imgproc.Imgproc; + import edu.wpi.cscore.AxisCamera; import edu.wpi.cscore.CvSink; import edu.wpi.cscore.CvSource; import edu.wpi.first.wpilibj.CameraServer; import edu.wpi.first.wpilibj.IterativeRobot; -import org.opencv.core.Mat; -import org.opencv.core.Point; -import org.opencv.core.Scalar; -import org.opencv.imgproc.Imgproc; /** * This is a demo program showing the use of OpenCV to do vision processing. The diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/OI.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/OI.java index 949a479094..b6135623b7 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/OI.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/OI.java @@ -9,6 +9,8 @@ package edu.wpi.first.wpilibj.examples.gearsbot; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.buttons.JoystickButton; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + import edu.wpi.first.wpilibj.examples.gearsbot.commands.Autonomous; import edu.wpi.first.wpilibj.examples.gearsbot.commands.CloseClaw; import edu.wpi.first.wpilibj.examples.gearsbot.commands.OpenClaw; @@ -17,7 +19,6 @@ import edu.wpi.first.wpilibj.examples.gearsbot.commands.Place; import edu.wpi.first.wpilibj.examples.gearsbot.commands.PrepareToPickup; import edu.wpi.first.wpilibj.examples.gearsbot.commands.SetElevatorSetpoint; import edu.wpi.first.wpilibj.examples.gearsbot.commands.SetWristSetpoint; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; /** * This class is the glue that binds the controls on the physical operator @@ -26,6 +27,9 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; public class OI { private Joystick m_joystick = new Joystick(0); + /** + * Construct the OI and all of the buttons on it. + */ public OI() { // Put Some buttons on the SmartDashboard SmartDashboard.putData("Elevator Bottom", new SetElevatorSetpoint(0)); @@ -41,14 +45,14 @@ public class OI { SmartDashboard.putData("Deliver Soda", new Autonomous()); // Create some buttons - JoystickButton dpadUp = new JoystickButton(m_joystick, 5); - JoystickButton dpadRight = new JoystickButton(m_joystick, 6); - JoystickButton dpadDown = new JoystickButton(m_joystick, 7); - JoystickButton dpadLeft = new JoystickButton(m_joystick, 8); - JoystickButton l2 = new JoystickButton(m_joystick, 9); - JoystickButton r2 = new JoystickButton(m_joystick, 10); - JoystickButton l1 = new JoystickButton(m_joystick, 11); - JoystickButton r1 = new JoystickButton(m_joystick, 12); + final JoystickButton dpadUp = new JoystickButton(m_joystick, 5); + final JoystickButton dpadRight = new JoystickButton(m_joystick, 6); + final JoystickButton dpadDown = new JoystickButton(m_joystick, 7); + final JoystickButton dpadLeft = new JoystickButton(m_joystick, 8); + final JoystickButton l2 = new JoystickButton(m_joystick, 9); + final JoystickButton r2 = new JoystickButton(m_joystick, 10); + final JoystickButton l1 = new JoystickButton(m_joystick, 11); + final JoystickButton r1 = new JoystickButton(m_joystick, 12); // Connect the buttons to commands dpadUp.whenPressed(new SetElevatorSetpoint(0.2)); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Autonomous.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Autonomous.java index 961cb2dcd4..96a9d85b34 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Autonomous.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Autonomous.java @@ -13,6 +13,9 @@ import edu.wpi.first.wpilibj.command.CommandGroup; * The main autonomous command to pickup and deliver the soda to the box. */ public class Autonomous extends CommandGroup { + /** + * Create a new autonomous command. + */ public Autonomous() { addSequential(new PrepareToPickup()); addSequential(new Pickup()); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/CloseClaw.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/CloseClaw.java index 1deb59531c..cdf4788c84 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/CloseClaw.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/CloseClaw.java @@ -8,6 +8,7 @@ package edu.wpi.first.wpilibj.examples.gearsbot.commands; import edu.wpi.first.wpilibj.command.Command; + import edu.wpi.first.wpilibj.examples.gearsbot.Robot; /** diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/DriveStraight.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/DriveStraight.java index 9bbbb4d8b0..4f4640018a 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/DriveStraight.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/DriveStraight.java @@ -11,6 +11,7 @@ import edu.wpi.first.wpilibj.PIDController; import edu.wpi.first.wpilibj.PIDSource; import edu.wpi.first.wpilibj.PIDSourceType; import edu.wpi.first.wpilibj.command.Command; + import edu.wpi.first.wpilibj.examples.gearsbot.Robot; /** @@ -22,6 +23,10 @@ import edu.wpi.first.wpilibj.examples.gearsbot.Robot; public class DriveStraight extends Command { private PIDController m_pid; + /** + * Create a new DriveStraight command. + * @param distance The distance to drive + */ public DriveStraight(double distance) { requires(Robot.m_drivetrain); m_pid = new PIDController(4, 0, 0, new PIDSource() { diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/OpenClaw.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/OpenClaw.java index fb9fe6e7b6..486181de61 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/OpenClaw.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/OpenClaw.java @@ -8,6 +8,7 @@ package edu.wpi.first.wpilibj.examples.gearsbot.commands; import edu.wpi.first.wpilibj.command.TimedCommand; + import edu.wpi.first.wpilibj.examples.gearsbot.Robot; /** diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Pickup.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Pickup.java index 0babf048e3..304ddf917e 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Pickup.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Pickup.java @@ -14,6 +14,9 @@ import edu.wpi.first.wpilibj.command.CommandGroup; * state to drive around. */ public class Pickup extends CommandGroup { + /** + * Create a new pickup command. + */ public Pickup() { addSequential(new CloseClaw()); addParallel(new SetWristSetpoint(-45)); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Place.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Place.java index 28ae7e5d80..c1a18416a2 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Place.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/Place.java @@ -13,6 +13,9 @@ import edu.wpi.first.wpilibj.command.CommandGroup; * Place a held soda can onto the platform. */ public class Place extends CommandGroup { + /** + * Create a new place command. + */ public Place() { addSequential(new SetElevatorSetpoint(0.25)); addSequential(new SetWristSetpoint(0)); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/PrepareToPickup.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/PrepareToPickup.java index 91b4fdcfaf..911c535b31 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/PrepareToPickup.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/PrepareToPickup.java @@ -13,6 +13,9 @@ import edu.wpi.first.wpilibj.command.CommandGroup; * Make sure the robot is in a state to pickup soda cans. */ public class PrepareToPickup extends CommandGroup { + /** + * Create a new prepare to pickup command. + */ public PrepareToPickup() { addParallel(new OpenClaw()); addParallel(new SetWristSetpoint(0)); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetDistanceToBox.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetDistanceToBox.java index 8bd4f6cebc..fd8d1bd74b 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetDistanceToBox.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetDistanceToBox.java @@ -11,6 +11,7 @@ import edu.wpi.first.wpilibj.PIDController; import edu.wpi.first.wpilibj.PIDSource; import edu.wpi.first.wpilibj.PIDSourceType; import edu.wpi.first.wpilibj.command.Command; + import edu.wpi.first.wpilibj.examples.gearsbot.Robot; /** @@ -22,6 +23,10 @@ import edu.wpi.first.wpilibj.examples.gearsbot.Robot; public class SetDistanceToBox extends Command { private PIDController m_pid; + /** + * Create a new set distance to box command. + * @param distance The distance away from the box to drive to + */ public SetDistanceToBox(double distance) { requires(Robot.m_drivetrain); m_pid = new PIDController(-2, 0, 0, new PIDSource() { diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetElevatorSetpoint.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetElevatorSetpoint.java index 1491108113..34fc769198 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetElevatorSetpoint.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetElevatorSetpoint.java @@ -8,6 +8,7 @@ package edu.wpi.first.wpilibj.examples.gearsbot.commands; import edu.wpi.first.wpilibj.command.Command; + import edu.wpi.first.wpilibj.examples.gearsbot.Robot; /** diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetWristSetpoint.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetWristSetpoint.java index 2f8511fad6..496a1df36a 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetWristSetpoint.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/SetWristSetpoint.java @@ -8,6 +8,7 @@ package edu.wpi.first.wpilibj.examples.gearsbot.commands; import edu.wpi.first.wpilibj.command.Command; + import edu.wpi.first.wpilibj.examples.gearsbot.Robot; /** diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/TankDriveWithJoystick.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/TankDriveWithJoystick.java index 25bc2cc9a9..642fa5d207 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/TankDriveWithJoystick.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/commands/TankDriveWithJoystick.java @@ -8,6 +8,7 @@ package edu.wpi.first.wpilibj.examples.gearsbot.commands; import edu.wpi.first.wpilibj.command.Command; + import edu.wpi.first.wpilibj.examples.gearsbot.Robot; /** diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Claw.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Claw.java index b97bbf8ff3..b484d88e12 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Claw.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Claw.java @@ -20,6 +20,9 @@ public class Claw extends Subsystem { private Victor m_motor = new Victor(7); private DigitalInput m_contact = new DigitalInput(5); + /** + * Create a new claw subsystem. + */ public Claw() { super(); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/DriveTrain.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/DriveTrain.java index f1c014592f..fed14f8d34 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/DriveTrain.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/DriveTrain.java @@ -16,9 +16,10 @@ import edu.wpi.first.wpilibj.SpeedController; import edu.wpi.first.wpilibj.SpeedControllerGroup; import edu.wpi.first.wpilibj.command.Subsystem; import edu.wpi.first.wpilibj.drive.DifferentialDrive; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + import edu.wpi.first.wpilibj.examples.gearsbot.Robot; import edu.wpi.first.wpilibj.examples.gearsbot.commands.TankDriveWithJoystick; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; /** * The DriveTrain subsystem incorporates the sensors and actuators attached to @@ -39,6 +40,9 @@ public class DriveTrain extends Subsystem { private AnalogInput m_rangefinder = new AnalogInput(6); private AnalogGyro m_gyro = new AnalogGyro(1); + /** + * Create a new drive train subsystem. + */ public DriveTrain() { super(); @@ -87,10 +91,8 @@ public class DriveTrain extends Subsystem { /** * Tank style driving for the DriveTrain. * - * @param left - * Speed in range [-1,1] - * @param right - * Speed in range [-1,1] + * @param left Speed in range [-1,1] + * @param right Speed in range [-1,1] */ public void drive(double left, double right) { m_drive.tankDrive(left, right); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Elevator.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Elevator.java index 12daddf08e..b7ebb491f7 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Elevator.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Elevator.java @@ -10,9 +10,10 @@ package edu.wpi.first.wpilibj.examples.gearsbot.subsystems; import edu.wpi.first.wpilibj.AnalogPotentiometer; import edu.wpi.first.wpilibj.Victor; import edu.wpi.first.wpilibj.command.PIDSubsystem; -import edu.wpi.first.wpilibj.examples.gearsbot.Robot; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj.examples.gearsbot.Robot; + /** * The elevator subsystem uses PID to go to a given height. Unfortunately, in * it's current state PID values for simulation are different than in the real @@ -27,6 +28,9 @@ public class Elevator extends PIDSubsystem { private static final double kP_simulation = 18; private static final double kI_simulation = 0.2; + /** + * Create a new elevator subsystem. + */ public Elevator() { super(kP_real, kI_real, 0); if (Robot.isSimulation()) { // Check for simulation and update PID values diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Wrist.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Wrist.java index 664c7db1fe..f268c11bc1 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Wrist.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gearsbot/subsystems/Wrist.java @@ -10,9 +10,10 @@ package edu.wpi.first.wpilibj.examples.gearsbot.subsystems; import edu.wpi.first.wpilibj.AnalogPotentiometer; import edu.wpi.first.wpilibj.Victor; import edu.wpi.first.wpilibj.command.PIDSubsystem; -import edu.wpi.first.wpilibj.examples.gearsbot.Robot; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj.examples.gearsbot.Robot; + /** * The wrist subsystem is like the elevator, but with a rotational joint instead * of a linear joint. @@ -24,6 +25,9 @@ public class Wrist extends PIDSubsystem { private static final double kP_real = 1; private static final double kP_simulation = 0.05; + /** + * Create a new wrist subsystem. + */ public Wrist() { super(kP_real, 0, 0); if (Robot.isSimulation()) { // Check for simulation and update PID values diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/intermediatevision/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/intermediatevision/Robot.java index e1b3516e41..ded1e48d76 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/intermediatevision/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/intermediatevision/Robot.java @@ -7,15 +7,16 @@ package edu.wpi.first.wpilibj.examples.intermediatevision; +import org.opencv.core.Mat; +import org.opencv.core.Point; +import org.opencv.core.Scalar; +import org.opencv.imgproc.Imgproc; + import edu.wpi.cscore.CvSink; import edu.wpi.cscore.CvSource; import edu.wpi.cscore.UsbCamera; import edu.wpi.first.wpilibj.CameraServer; import edu.wpi.first.wpilibj.IterativeRobot; -import org.opencv.core.Mat; -import org.opencv.core.Point; -import org.opencv.core.Scalar; -import org.opencv.imgproc.Imgproc; /** * This is a demo program showing the use of OpenCV to do vision processing. The diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/motorcontrol/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/motorcontrol/Robot.java index 307458e44c..bdb4105e46 100755 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/motorcontrol/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/motorcontrol/Robot.java @@ -9,8 +9,8 @@ package edu.wpi.first.wpilibj.examples.motorcontrol; import edu.wpi.first.wpilibj.IterativeRobot; import edu.wpi.first.wpilibj.Joystick; -import edu.wpi.first.wpilibj.SpeedController; import edu.wpi.first.wpilibj.Spark; +import edu.wpi.first.wpilibj.SpeedController; /** * This sample program shows how to control a motor using a joystick. In the diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/OI.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/OI.java index a7fe56a59c..c1646e19d4 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/OI.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/OI.java @@ -7,6 +7,10 @@ package edu.wpi.first.wpilibj.examples.pacgoat; +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.buttons.JoystickButton; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + import edu.wpi.first.wpilibj.examples.pacgoat.commands.Collect; import edu.wpi.first.wpilibj.examples.pacgoat.commands.DriveForward; import edu.wpi.first.wpilibj.examples.pacgoat.commands.LowGoal; @@ -17,10 +21,6 @@ import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Collector; import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Pivot; import edu.wpi.first.wpilibj.examples.pacgoat.triggers.DoubleButton; -import edu.wpi.first.wpilibj.Joystick; -import edu.wpi.first.wpilibj.buttons.JoystickButton; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; - /** * The operator interface of the robot, it has been simplified from the real * robot to allow control with a single PS3 joystick. As a result, not all @@ -29,6 +29,9 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; public class OI { public Joystick m_joystick = new Joystick(0); + /** + * Create a new OI and all of the buttons on it. + */ public OI() { new JoystickButton(m_joystick, 12).whenPressed(new LowGoal()); new JoystickButton(m_joystick, 10).whenPressed(new Collect()); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Collect.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Collect.java index 6d3763e96f..d9db916a7e 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Collect.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Collect.java @@ -16,6 +16,9 @@ import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Pivot; * Get the robot set to collect balls. */ public class Collect extends CommandGroup { + /** + * Create a new collect command. + */ public Collect() { addSequential(new SetCollectionSpeed(Collector.kForward)); addParallel(new CloseClaw()); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveAndShootAutonomous.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveAndShootAutonomous.java index 18d5b2bb64..f614e8f8d2 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveAndShootAutonomous.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveAndShootAutonomous.java @@ -16,6 +16,9 @@ import edu.wpi.first.wpilibj.examples.pacgoat.Robot; * it will wait briefly. */ public class DriveAndShootAutonomous extends CommandGroup { + /** + * Create a new drive and shoot autonomous. + */ public DriveAndShootAutonomous() { addSequential(new CloseClaw()); addSequential(new WaitForPressure(), 2); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveForward.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveForward.java index 90cb207923..faa93bc04e 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveForward.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/DriveForward.java @@ -30,6 +30,11 @@ public class DriveForward extends Command { this(dist, 0.5); } + /** + * Create a new drive forward command. + * @param dist The distance to drive + * @param maxSpeed The maximum speed to drive at + */ public DriveForward(double dist, double maxSpeed) { requires(Robot.drivetrain); m_distance = dist; diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/LowGoal.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/LowGoal.java index 99f94b1a27..08214e1ed8 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/LowGoal.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/LowGoal.java @@ -17,6 +17,9 @@ import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Pivot; * it. */ public class LowGoal extends CommandGroup { + /** + * Create a new low goal command. + */ public LowGoal() { addSequential(new SetPivotSetpoint(Pivot.kLowGoal)); addSequential(new SetCollectionSpeed(Collector.kReverse)); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Shoot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Shoot.java index af8f41d269..40ccb25db6 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Shoot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/commands/Shoot.java @@ -15,6 +15,9 @@ import edu.wpi.first.wpilibj.examples.pacgoat.subsystems.Collector; * Shoot the ball at the current angle. */ public class Shoot extends CommandGroup { + /** + * Create a new shoot command. + */ public Shoot() { addSequential(new WaitForPressure()); addSequential(new SetCollectionSpeed(Collector.kStop)); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Collector.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Collector.java index d618f71fa1..1c895d0629 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Collector.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Collector.java @@ -30,6 +30,9 @@ public class Collector extends Subsystem { private DigitalInput m_openDetector = new DigitalInput(6); private Solenoid m_piston = new Solenoid(1, 1); + /** + * Create a new collector subsystem. + */ public Collector() { // Put everything to the LiveWindow for testing. addChild("Roller Motor", (Victor) m_rollerMotor); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/DriveTrain.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/DriveTrain.java index 1c219c265d..20dc654126 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/DriveTrain.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/DriveTrain.java @@ -9,7 +9,6 @@ package edu.wpi.first.wpilibj.examples.pacgoat.subsystems; import edu.wpi.first.wpilibj.AnalogGyro; import edu.wpi.first.wpilibj.CounterBase.EncodingType; -import edu.wpi.first.wpilibj.drive.DifferentialDrive; import edu.wpi.first.wpilibj.Encoder; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.PIDSourceType; @@ -17,6 +16,7 @@ import edu.wpi.first.wpilibj.SpeedController; import edu.wpi.first.wpilibj.SpeedControllerGroup; import edu.wpi.first.wpilibj.Victor; import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj.drive.DifferentialDrive; import edu.wpi.first.wpilibj.examples.pacgoat.Robot; import edu.wpi.first.wpilibj.examples.pacgoat.commands.DriveWithJoystick; @@ -40,6 +40,9 @@ public class DriveTrain extends Subsystem { private Encoder m_leftEncoder = new Encoder(3, 4, false, EncodingType.k4X); private AnalogGyro m_gyro = new AnalogGyro(2); + /** + * Create a new drive train subsystem. + */ public DriveTrain() { // Configure drive motors addChild("Front Left CIM", (Victor) m_frontLeftCIM); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Pivot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Pivot.java index 4cd6bf3b02..23e2b2c6ec 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Pivot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Pivot.java @@ -38,6 +38,9 @@ public class Pivot extends PIDSubsystem { // Motor to move the pivot. private SpeedController m_motor = new Victor(5); + /** + * Create a new pivot subsystem. + */ public Pivot() { super("Pivot", 7.0, 0.0, 8.0); setAbsoluteTolerance(0.005); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Shooter.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Shooter.java index 1bb2a8d732..93c44ccf8a 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Shooter.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/subsystems/Shooter.java @@ -32,6 +32,9 @@ public class Shooter extends Subsystem { //NOTE: currently ignored in simulation DigitalInput m_hotGoalSensor = new DigitalInput(3); + /** + * Create a new shooter subsystem. + */ public Shooter() { // Put everything to the LiveWindow for testing. addChild("Hot Goal Sensor", m_hotGoalSensor); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/triggers/DoubleButton.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/triggers/DoubleButton.java index 0745e1ea55..0533dc7cff 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/triggers/DoubleButton.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/pacgoat/triggers/DoubleButton.java @@ -19,6 +19,12 @@ public class DoubleButton extends Trigger { private int m_button1; private int m_button2; + /** + * Create a new double button trigger. + * @param joy The joystick + * @param button1 The first button + * @param button2 The second button + */ public DoubleButton(Joystick joy, int button1, int button2) { this.m_joy = joy; this.m_button1 = button1; diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/potentiometerpid/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/potentiometerpid/Robot.java index cb30a55f70..bbd72f7af0 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/potentiometerpid/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/potentiometerpid/Robot.java @@ -9,10 +9,10 @@ package edu.wpi.first.wpilibj.examples.potentiometerpid; import edu.wpi.first.wpilibj.AnalogInput; import edu.wpi.first.wpilibj.IterativeRobot; +import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.PIDController; import edu.wpi.first.wpilibj.Spark; import edu.wpi.first.wpilibj.SpeedController; -import edu.wpi.first.wpilibj.Joystick; /** * This is a sample program to demonstrate how to use a soft potentiometer and a diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/sample/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/sample/Robot.java index 664cc5ef4f..b07a15022f 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/sample/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/sample/Robot.java @@ -7,8 +7,8 @@ package edu.wpi.first.wpilibj.templates.sample; -import edu.wpi.first.wpilibj.SampleRobot; import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.SampleRobot; import edu.wpi.first.wpilibj.Spark; import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.drive.DifferentialDrive; diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timed/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timed/Robot.java index 2cb96fcae6..4cbbb42b4a 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timed/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/timed/Robot.java @@ -49,8 +49,7 @@ public class Robot extends TimedRobot { @Override public void autonomousInit() { m_autoSelected = m_chooser.getSelected(); - // m_autoSelected = SmartDashboard.getString("Auto Selector", - // kDefaultAuto); + // m_autoSelected = SmartDashboard.getString("Auto Selector", kDefaultAuto); System.out.println("Auto selected: " + m_autoSelected); } diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AbstractInterruptTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AbstractInterruptTest.java index a53bd21443..3e40bd9643 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AbstractInterruptTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AbstractInterruptTest.java @@ -7,13 +7,13 @@ package edu.wpi.first.wpilibj; -import org.junit.After; -import org.junit.Test; - import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +import org.junit.After; +import org.junit.Test; + import edu.wpi.first.wpilibj.test.AbstractComsSetup; import static org.hamcrest.Matchers.both; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogCrossConnectTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogCrossConnectTest.java index 2c680a2e0d..796e919d09 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogCrossConnectTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogCrossConnectTest.java @@ -7,13 +7,13 @@ package edu.wpi.first.wpilibj; +import java.util.logging.Logger; + import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.AnalogTriggerOutput.AnalogTriggerType; import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture; import edu.wpi.first.wpilibj.test.TestBench; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java index 1af02f0605..8f5ad485f2 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java @@ -7,12 +7,12 @@ package edu.wpi.first.wpilibj; +import java.util.logging.Logger; + import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture; import edu.wpi.first.wpilibj.mockhardware.FakePotentiometerSource; import edu.wpi.first.wpilibj.test.AbstractComsSetup; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometerTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometerTest.java index 8256444282..dbfddfa70a 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometerTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometerTest.java @@ -7,16 +7,16 @@ package edu.wpi.first.wpilibj; +import java.util.Arrays; +import java.util.Collection; +import java.util.logging.Logger; + import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Arrays; -import java.util.Collection; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.interfaces.Accelerometer; import edu.wpi.first.wpilibj.test.AbstractComsSetup; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java index 93fb6ef470..260ac12231 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java @@ -7,10 +7,10 @@ package edu.wpi.first.wpilibj; -import org.junit.Test; - import java.util.logging.Logger; +import org.junit.Test; + import edu.wpi.first.wpilibj.test.AbstractComsSetup; import static org.junit.Assert.assertEquals; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CounterTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CounterTest.java index 4ad00d76a5..3d6bd2e40c 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CounterTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CounterTest.java @@ -7,6 +7,9 @@ package edu.wpi.first.wpilibj; +import java.util.Collection; +import java.util.logging.Logger; + import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -15,9 +18,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Collection; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.fixtures.FakeCounterFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; import edu.wpi.first.wpilibj.test.TestBench; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DIOCrossConnectTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DIOCrossConnectTest.java index ff776a0473..b61b76180a 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DIOCrossConnectTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DIOCrossConnectTest.java @@ -7,6 +7,9 @@ package edu.wpi.first.wpilibj; +import java.util.Collection; +import java.util.logging.Logger; + import org.junit.After; import org.junit.AfterClass; import org.junit.Test; @@ -14,9 +17,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Collection; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.fixtures.DIOCrossConnectFixture; import edu.wpi.first.wpilibj.test.TestBench; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilterTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilterTest.java index 2b91208546..fb9b7ff2e5 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilterTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilterTest.java @@ -7,10 +7,10 @@ package edu.wpi.first.wpilibj; -import org.junit.Test; - import java.util.logging.Logger; +import org.junit.Test; + import edu.wpi.first.wpilibj.test.AbstractComsSetup; import static org.junit.Assert.assertEquals; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DriverStationTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DriverStationTest.java index 094b3a30ba..301a7eed00 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DriverStationTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DriverStationTest.java @@ -7,10 +7,10 @@ package edu.wpi.first.wpilibj; -import org.junit.Test; - import java.util.logging.Logger; +import org.junit.Test; + import edu.wpi.first.wpilibj.test.AbstractComsSetup; import static org.junit.Assert.assertEquals; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/EncoderTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/EncoderTest.java index cb78b99b50..98337907a6 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/EncoderTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/EncoderTest.java @@ -7,6 +7,9 @@ package edu.wpi.first.wpilibj; +import java.util.Collection; +import java.util.logging.Logger; + import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -15,9 +18,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Collection; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.fixtures.FakeEncoderFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; import edu.wpi.first.wpilibj.test.TestBench; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/FilterNoiseTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/FilterNoiseTest.java index 14a6bc9529..23490165bd 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/FilterNoiseTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/FilterNoiseTest.java @@ -7,6 +7,10 @@ package edu.wpi.first.wpilibj; +import java.util.Arrays; +import java.util.Collection; +import java.util.logging.Logger; + import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -15,10 +19,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Arrays; -import java.util.Collection; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.fixtures.FilterNoiseFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; import edu.wpi.first.wpilibj.test.TestBench; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/FilterOutputTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/FilterOutputTest.java index 30a46f1fb8..a672f1a0e7 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/FilterOutputTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/FilterOutputTest.java @@ -7,6 +7,10 @@ package edu.wpi.first.wpilibj; +import java.util.Arrays; +import java.util.Collection; +import java.util.logging.Logger; + import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -15,10 +19,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Arrays; -import java.util.Collection; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.fixtures.FilterOutputFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; import edu.wpi.first.wpilibj.test.TestBench; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java index fad1155b86..aee0514106 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java @@ -7,12 +7,12 @@ package edu.wpi.first.wpilibj; +import java.util.logging.Logger; + import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.fixtures.TiltPanCameraFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; import edu.wpi.first.wpilibj.test.TestBench; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java index f41096f1de..59400c7c15 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java @@ -7,6 +7,10 @@ package edu.wpi.first.wpilibj; +import java.util.Arrays; +import java.util.Collection; +import java.util.logging.Logger; + import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -15,10 +19,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Arrays; -import java.util.Collection; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.filters.LinearDigitalFilter; import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java index 13daf64248..5857681292 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java @@ -7,6 +7,10 @@ package edu.wpi.first.wpilibj; +import java.util.Arrays; +import java.util.Collection; +import java.util.logging.Logger; + import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; @@ -14,10 +18,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Arrays; -import java.util.Collection; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; import edu.wpi.first.wpilibj.test.TestBench; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java index 4e05a9cbb0..71d6f49e5e 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java @@ -7,13 +7,13 @@ package edu.wpi.first.wpilibj; +import java.util.logging.Logger; + import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.test.AbstractComsSetup; import static org.junit.Assert.assertEquals; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PDPTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PDPTest.java index e00c7001b8..3d3bc571eb 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PDPTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PDPTest.java @@ -7,6 +7,10 @@ package edu.wpi.first.wpilibj; +import java.util.Arrays; +import java.util.Collection; +import java.util.logging.Logger; + import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -15,10 +19,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Arrays; -import java.util.Collection; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.can.CANMessageNotFoundException; import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java index 35f5064b17..ad05703306 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java @@ -7,6 +7,11 @@ package edu.wpi.first.wpilibj; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.logging.Logger; + import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -16,11 +21,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.logging.Logger; - import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableInstance; import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PreferencesTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PreferencesTest.java index bacefe259f..41633ad842 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PreferencesTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PreferencesTest.java @@ -7,16 +7,16 @@ package edu.wpi.first.wpilibj; -import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.Arrays; import java.util.logging.Logger; +import org.junit.Before; +import org.junit.Test; + import edu.wpi.first.wpilibj.networktables.NetworkTable; import edu.wpi.first.wpilibj.test.AbstractComsSetup; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java index 0cec277857..a55a81689a 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java @@ -7,12 +7,12 @@ package edu.wpi.first.wpilibj; +import java.util.logging.Logger; + import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.util.logging.Logger; - import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableInstance; import edu.wpi.first.wpilibj.Relay.Direction; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RobotDriveTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RobotDriveTest.java index e0715d5409..b0e773634e 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RobotDriveTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RobotDriveTest.java @@ -7,16 +7,15 @@ package edu.wpi.first.wpilibj; +import java.util.logging.Logger; + import org.junit.BeforeClass; import org.junit.Test; import edu.wpi.first.wpilibj.drive.DifferentialDrive; import edu.wpi.first.wpilibj.drive.MecanumDrive; - import edu.wpi.first.wpilibj.test.AbstractComsSetup; -import java.util.logging.Logger; - import static org.junit.Assert.assertEquals; /** diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java index e98575f7fb..d21206b8b2 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java @@ -7,13 +7,13 @@ package edu.wpi.first.wpilibj; +import java.util.logging.Logger; + import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.fixtures.SampleFixture; import edu.wpi.first.wpilibj.test.AbstractComsSetup; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/TimerTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/TimerTest.java index 745daaf783..2acd5bb90b 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/TimerTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/TimerTest.java @@ -7,10 +7,10 @@ package edu.wpi.first.wpilibj; -import org.junit.Test; - import java.util.logging.Logger; +import org.junit.Test; + import edu.wpi.first.wpilibj.test.AbstractComsSetup; import static org.junit.Assert.assertEquals; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboardTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboardTest.java index af58e6a9d3..cf1d827449 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboardTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboardTest.java @@ -7,11 +7,11 @@ package edu.wpi.first.wpilibj.smartdashboard; +import java.util.logging.Logger; + import org.junit.Ignore; import org.junit.Test; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.networktables.NetworkTable; import edu.wpi.first.wpilibj.test.AbstractComsSetup; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java index d999df7c72..0ce5a565b3 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java @@ -7,15 +7,15 @@ package edu.wpi.first.wpilibj.test; +import java.util.logging.Level; +import java.util.logging.Logger; + import org.junit.BeforeClass; import org.junit.Rule; import org.junit.rules.TestWatcher; import org.junit.runner.Description; import org.junit.runners.model.MultipleFailureException; -import java.util.logging.Level; -import java.util.logging.Logger; - import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.MockDS; import edu.wpi.first.wpilibj.RobotBase; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuite.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuite.java index 794d0e4c34..b8af56d8ce 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuite.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuite.java @@ -7,11 +7,6 @@ package edu.wpi.first.wpilibj.test; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.Request; -import org.junit.runners.Suite.SuiteClasses; - import java.lang.reflect.Method; import java.util.List; import java.util.Vector; @@ -19,6 +14,11 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Pattern; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.Request; +import org.junit.runners.Suite.SuiteClasses; + /** * Allows tests suites and tests to be run selectively from the command line using a regex text * pattern. diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuiteTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuiteTest.java index d3ece6ea5d..acff9d4bad 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuiteTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuiteTest.java @@ -7,6 +7,8 @@ package edu.wpi.first.wpilibj.test; +import java.util.List; + import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -15,8 +17,6 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; import org.junit.runners.model.InitializationError; -import java.util.List; - import edu.wpi.first.wpilibj.test.AbstractTestSuite.ClassMethodPair; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLanucher.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLanucher.java index 77ed801477..0350ea4fdd 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLanucher.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLanucher.java @@ -7,6 +7,8 @@ package edu.wpi.first.wpilibj.test; +import java.io.File; + import org.apache.tools.ant.BuildLogger; import org.apache.tools.ant.DefaultLogger; import org.apache.tools.ant.Project; @@ -14,8 +16,6 @@ import org.apache.tools.ant.taskdefs.optional.junit.FormatterElement; import org.apache.tools.ant.taskdefs.optional.junit.JUnitTask; import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest; -import java.io.File; - /** * Provides an entry point for tests to run with ANT. This allows ant to output JUnit XML test * results for Jenkins. diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/QuickTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/QuickTest.java index 2f24c64097..87b05d0adf 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/QuickTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/QuickTest.java @@ -7,10 +7,10 @@ package edu.wpi.first.wpilibj.test; -import org.junit.Test; - import java.util.logging.Logger; +import org.junit.Test; + /** * This class is designated to allow for simple testing of the library without the overlying testing * framework. This test is NOT run as a normal part of the testing process and must be explicitly diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/RepeatRule.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/RepeatRule.java index 5e987d6fac..deb0da8dcb 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/RepeatRule.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/RepeatRule.java @@ -7,14 +7,14 @@ package edu.wpi.first.wpilibj.test; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + /** * This JUnit Rule allows you to apply this rule to any test to allow it to run multiple times. This * is important if you have a test that fails only "sometimes" and needs to be rerun to find the diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java index 72f67038d5..107d1dd063 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java @@ -7,16 +7,6 @@ package edu.wpi.first.wpilibj.test; -import junit.framework.JUnit4TestAdapter; -import junit.runner.Version; - -import org.junit.runner.JUnitCore; -import org.junit.runner.Result; -import org.junit.runner.RunWith; -import org.junit.runner.notification.Failure; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -27,6 +17,16 @@ import java.util.logging.LogManager; import java.util.logging.Logger; import java.util.regex.Pattern; +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.RunWith; +import org.junit.runner.notification.Failure; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +import junit.framework.JUnit4TestAdapter; +import junit.runner.Version; + import edu.wpi.first.wpilibj.WpiLibJTestSuite; import edu.wpi.first.wpilibj.command.CommandTestSuite; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboardTestSuite; diff --git a/wpiutil/build.gradle b/wpiutil/build.gradle index 5d5370f508..f5b391d226 100644 --- a/wpiutil/build.gradle +++ b/wpiutil/build.gradle @@ -23,7 +23,3 @@ model { } } } - -checkstyle { - sourceSets = [] -} diff --git a/wpiutil/src/dev/java/edu/wpi/first/wpiutil/DevMain.java b/wpiutil/src/dev/java/edu/wpi/first/wpiutil/DevMain.java index 90c3670a8c..51d9e40c27 100644 --- a/wpiutil/src/dev/java/edu/wpi/first/wpiutil/DevMain.java +++ b/wpiutil/src/dev/java/edu/wpi/first/wpiutil/DevMain.java @@ -8,8 +8,11 @@ package edu.wpi.first.wpiutil; public class DevMain { - public static void main(String[] args) { - System.out.println("Hello World!"); - System.out.println(RuntimeDetector.getPlatformPath()); - } + /** + * Main entry point. + */ + public static void main(String[] args) { + System.out.println("Hello World!"); + System.out.println(RuntimeDetector.getPlatformPath()); + } } diff --git a/wpiutil/src/main/java/edu/wpi/first/wpiutil/RuntimeDetector.java b/wpiutil/src/main/java/edu/wpi/first/wpiutil/RuntimeDetector.java index c02d52645b..324a7bdc39 100644 --- a/wpiutil/src/main/java/edu/wpi/first/wpiutil/RuntimeDetector.java +++ b/wpiutil/src/main/java/edu/wpi/first/wpiutil/RuntimeDetector.java @@ -56,24 +56,36 @@ public class RuntimeDetector { } } + /** + * Get the file prefix for the current system. + */ public static synchronized String getFilePrefix() { computePlatform(); return filePrefix; } + /** + * Get the file extension for the current system. + */ public static synchronized String getFileExtension() { computePlatform(); return fileExtension; } + /** + * Get the platform path for the current system. + */ public static synchronized String getPlatformPath() { computePlatform(); return filePath; } + /** + * Get the path to the requested resource. + */ public static synchronized String getLibraryResource(String libName) { computePlatform();