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 deleted file mode 100644 index e5affb2958..0000000000 --- a/ntcore/src/main/java/edu/wpi/first/wpilibj/networktables/NetworkTable.java +++ /dev/null @@ -1,1108 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.networktables; - -import edu.wpi.first.networktables.ConnectionInfo; -import edu.wpi.first.networktables.ConnectionNotification; -import edu.wpi.first.networktables.EntryInfo; -import edu.wpi.first.networktables.EntryNotification; -import edu.wpi.first.networktables.NetworkTableEntry; -import edu.wpi.first.networktables.NetworkTableInstance; -import edu.wpi.first.networktables.NetworkTableType; -import edu.wpi.first.networktables.NetworkTableValue; -import edu.wpi.first.networktables.NetworkTablesJNI; -import edu.wpi.first.networktables.PersistentException; -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 */ - public static final char PATH_SEPARATOR = '/'; - /** The default port that network tables operates on */ - public static final int DEFAULT_PORT = 1735; - - private static boolean client = false; - private static boolean enableDS = true; - private static boolean running = false; - private static int port = DEFAULT_PORT; - private static String persistentFilename = "networktables.ini"; - - private static synchronized void checkInit() { - if (running) throw new IllegalStateException("Network tables has already been initialized"); - } - - /** - * initializes network tables - * - * @deprecated Use {@link NetworkTableInstance#startServer()} or {@link - * NetworkTableInstance#startClient()} instead. - */ - @Deprecated - public static synchronized void initialize() { - if (running) shutdown(); - NetworkTableInstance inst = NetworkTableInstance.getDefault(); - if (client) { - inst.startClient(); - if (enableDS) inst.startDSClient(port); - } else inst.startServer(persistentFilename, "", port); - running = true; - } - - /** - * shuts down network tables - * - * @deprecated Use {@link NetworkTableInstance#stopServer()} or {@link - * NetworkTableInstance#stopClient()} instead. - */ - @Deprecated - public static synchronized void shutdown() { - if (!running) return; - NetworkTableInstance inst = NetworkTableInstance.getDefault(); - if (client) { - inst.stopDSClient(); - inst.stopClient(); - } else inst.stopServer(); - running = false; - } - - /** - * set that network tables should be a server This must be called before initialize or getTable - * - * @deprecated Use {@link NetworkTableInstance#startServer()} instead. - */ - @Deprecated - public static synchronized void setServerMode() { - if (!client) return; - checkInit(); - client = false; - } - - /** - * set that network tables should be a client This must be called before initialize or getTable - * - * @deprecated Use {@link NetworkTableInstance#startClient()} instead. - */ - @Deprecated - public static synchronized void setClientMode() { - if (client) return; - checkInit(); - client = true; - } - - /** - * set the team the robot is configured for (this will set the mdns address that network tables - * will connect to in client mode) This must be called before initialize or getTable - * - * @param team the team number - * @deprecated Use {@link NetworkTableInstance#setServerTeam(int)} or {@link - * NetworkTableInstance#startClientTeam(int)} instead. - */ - @Deprecated - public static synchronized void setTeam(int team) { - NetworkTableInstance inst = NetworkTableInstance.getDefault(); - inst.setServerTeam(team, port); - if (enableDS) inst.startDSClient(port); - } - - /** - * @param address the address that network tables will connect to in client mode - * @deprecated Use {@link NetworkTableInstance#setServer(String)} or {@link - * NetworkTableInstance#startClient(String)} instead. - */ - @Deprecated - public static synchronized void setIPAddress(final String address) { - String[] addresses = new String[1]; - addresses[0] = address; - setIPAddress(addresses); - } - - /** - * @param addresses the adresses that network tables will connect to in client mode (in round - * robin order) - * @deprecated Use {@link NetworkTableInstance#setServer(String[])} or {@link - * NetworkTableInstance#startClient(String[])} instead. - */ - @Deprecated - public static synchronized void setIPAddress(final String[] addresses) { - NetworkTableInstance inst = NetworkTableInstance.getDefault(); - inst.setServer(addresses, port); - - // Stop the DS client if we're explicitly connecting to localhost - if (addresses.length > 0 - && (addresses[0].equals("localhost") || addresses[0].equals("127.0.0.1"))) - inst.stopDSClient(); - else if (enableDS) inst.startDSClient(port); - } - - /** - * Set the port number that network tables will connect to in client mode or listen to in server - * mode. - * - * @param aport the port number - * @deprecated Use the appropriate parameters to {@link NetworkTableInstance#setServer(String, - * int)}, {@link NetworkTableInstance#startClient(String, int)}, {@link - * NetworkTableInstance#startServer(String, String, int)}, and {@link - * NetworkTableInstance#startDSClient(int)} instead. - */ - @Deprecated - public static synchronized void setPort(int aport) { - if (port == aport) return; - checkInit(); - port = aport; - } - - /** - * Enable requesting the server address from the Driver Station. - * - * @param enabled whether to enable the connection to the local DS - * @deprecated Use {@link NetworkTableInstance#startDSClient()} and {@link - * NetworkTableInstance#stopDSClient()} instead. - */ - @Deprecated - public static synchronized void setDSClientEnabled(boolean enabled) { - NetworkTableInstance inst = NetworkTableInstance.getDefault(); - enableDS = enabled; - if (enableDS) inst.startDSClient(port); - else inst.stopDSClient(); - } - - /** - * Sets the persistent filename. - * - * @param filename the filename that the network tables server uses for automatic loading and - * saving of persistent values - * @deprecated Use the appropriate parameter to {@link NetworkTableInstance#startServer()} - * instead. - */ - @Deprecated - public static synchronized void setPersistentFilename(final String filename) { - if (persistentFilename.equals(filename)) return; - checkInit(); - persistentFilename = filename; - } - - /** - * Sets the network identity. This is provided in the connection info on the remote end. - * - * @param name identity - * @deprecated Use {@link NetworkTableInstance#setNetworkIdentity(String)} instead. - */ - @Deprecated - public static void setNetworkIdentity(String name) { - NetworkTableInstance.getDefault().setNetworkIdentity(name); - } - - public static boolean[] toNative(Boolean[] arr) { - boolean[] out = new boolean[arr.length]; - for (int i = 0; i < arr.length; i++) out[i] = arr[i]; - return out; - } - - public static double[] toNative(Number[] arr) { - double[] out = new double[arr.length]; - for (int i = 0; i < arr.length; i++) out[i] = arr[i].doubleValue(); - return out; - } - - public static Boolean[] fromNative(boolean[] arr) { - Boolean[] out = new Boolean[arr.length]; - for (int i = 0; i < arr.length; i++) out[i] = arr[i]; - return out; - } - - public static Double[] fromNative(double[] arr) { - Double[] out = new Double[arr.length]; - for (int i = 0; i < arr.length; i++) out[i] = arr[i]; - return out; - } - - /** - * Gets the table with the specified key. If the table does not exist, a new table will be - * created.
- * This will automatically initialize network tables if it has not been already - * - * @deprecated Use {@link NetworkTableInstance#getTable(String)} instead. - * @param key the key name - * @return the network table requested - */ - @Deprecated - public static synchronized NetworkTable getTable(String key) { - if (!running) initialize(); - String theKey; - if (key.isEmpty() || key.equals("/")) { - theKey = ""; - } else if (key.charAt(0) == NetworkTable.PATH_SEPARATOR) { - theKey = key; - } else { - theKey = NetworkTable.PATH_SEPARATOR + key; - } - return new NetworkTable(NetworkTableInstance.getDefault(), theKey); - } - - private final String path; - private final String pathWithSep; - private final NetworkTableInstance inst; - - NetworkTable(NetworkTableInstance inst, String path) { - this.path = path; - this.pathWithSep = path + PATH_SEPARATOR; - this.inst = inst; - } - - @Override - public String toString() { - return "NetworkTable: " + path; - } - - private final ConcurrentMap entries = - new ConcurrentHashMap(); - - /** - * Gets the entry for a subkey. - * - * @param key the key name - * @return Network table entry. - */ - private NetworkTableEntry getEntry(String key) { - NetworkTableEntry entry = entries.get(key); - if (entry == null) { - entry = inst.getEntry(pathWithSep + key); - entries.putIfAbsent(key, entry); - } - return entry; - } - - /** - * Gets the current network connections. - * - * @return An array of connection information. - * @deprecated Use {@link NetworkTableInstance#getConnections()} instead. - */ - @Deprecated - public static ConnectionInfo[] connections() { - return NetworkTableInstance.getDefault().getConnections(); - } - - /** - * Determine whether or not a network connection is active. - * - * @return True if connected, false if not connected. - * @deprecated Use {@link NetworkTableInstance#isConnected()} instead. - */ - @Override - @Deprecated - public boolean isConnected() { - return inst.isConnected(); - } - - /** - * Determine whether NetworkTables is operating as a server or as a client. - * - * @return True if operating as a server, false otherwise. - * @deprecated Use {@link NetworkTableInstance#getNetworkMode()} instead. - */ - @Override - @Deprecated - public boolean isServer() { - return (inst.getNetworkMode() & NetworkTableInstance.kNetModeServer) != 0; - } - - /* Backwards compatibility shims for IRemoteConnectionListener */ - private static class ConnectionListenerAdapter implements Consumer { - public int uid; - private final IRemote targetSource; - private final IRemoteConnectionListener targetListener; - - public ConnectionListenerAdapter( - IRemote targetSource, IRemoteConnectionListener targetListener) { - this.targetSource = targetSource; - this.targetListener = targetListener; - } - - @Override - public void accept(ConnectionNotification event) { - if (event.connected) targetListener.connectedEx(targetSource, event.conn); - else targetListener.disconnectedEx(targetSource, event.conn); - } - } - - private static final HashMap - globalConnectionListenerMap = - new HashMap(); - - private static IRemote staticRemote = - new IRemote() { - @Override - public void addConnectionListener( - IRemoteConnectionListener listener, boolean immediateNotify) { - NetworkTable.addGlobalConnectionListener(listener, immediateNotify); - } - - @Override - public void removeConnectionListener(IRemoteConnectionListener listener) { - NetworkTable.removeGlobalConnectionListener(listener); - } - - @Override - public boolean isConnected() { - ConnectionInfo[] conns = NetworkTableInstance.getDefault().getConnections(); - return conns.length > 0; - } - - @Override - public boolean isServer() { - return (NetworkTableInstance.getDefault().getNetworkMode() - & NetworkTableInstance.kNetModeServer) - != 0; - } - }; - - private final HashMap - connectionListenerMap = new HashMap(); - - /** - * Add a connection listener. - * - * @param listener connection listener - * @param immediateNotify call listener immediately for all existing connections - * @deprecated Use {@link NetworkTableInstance#addConnectionListener(Consumer, boolean)} instead. - */ - @Deprecated - public static synchronized void addGlobalConnectionListener( - IRemoteConnectionListener listener, boolean immediateNotify) { - ConnectionListenerAdapter adapter = new ConnectionListenerAdapter(staticRemote, listener); - if (globalConnectionListenerMap.putIfAbsent(listener, adapter) != null) { - throw new IllegalStateException("Cannot add the same listener twice"); - } - adapter.uid = NetworkTableInstance.getDefault().addConnectionListener(adapter, immediateNotify); - } - - /** - * Remove a connection listener. - * - * @param listener connection listener - * @deprecated Use {@link NetworkTableInstance#removeConnectionListener(int)} instead. - */ - @Deprecated - public static synchronized void removeGlobalConnectionListener( - IRemoteConnectionListener listener) { - ConnectionListenerAdapter adapter = globalConnectionListenerMap.remove(listener); - if (adapter != null) { - NetworkTableInstance.getDefault().removeConnectionListener(adapter.uid); - } - } - - /** - * Add a connection listener. - * - * @param listener connection listener - * @param immediateNotify call listener immediately for all existing connections - * @deprecated Use {@link NetworkTableInstance#addConnectionListener(Consumer, boolean)} instead. - */ - @Override - @Deprecated - public synchronized void addConnectionListener( - IRemoteConnectionListener listener, boolean immediateNotify) { - ConnectionListenerAdapter adapter = new ConnectionListenerAdapter(this, listener); - if (connectionListenerMap.putIfAbsent(listener, adapter) != null) { - throw new IllegalStateException("Cannot add the same listener twice"); - } - adapter.uid = inst.addConnectionListener(adapter, immediateNotify); - } - - /** - * Remove a connection listener. - * - * @param listener connection listener - * @deprecated Use {@link NetworkTableInstance#removeConnectionListener(int)} instead. - */ - @Override - @Deprecated - public synchronized void removeConnectionListener(IRemoteConnectionListener listener) { - ConnectionListenerAdapter adapter = connectionListenerMap.get(listener); - if (adapter != null && connectionListenerMap.remove(listener, adapter)) { - inst.removeConnectionListener(adapter.uid); - } - } - - /** - * {@inheritDoc} - * - * @deprecated Use {@link - * edu.wpi.first.networktables.NetworkTable#addEntryListener(TableEntryListener, int)} instead - * (with flags value of NOTIFY_NEW | NOTIFY_UPDATE). - */ - @Override - @Deprecated - public void addTableListener(ITableListener listener) { - addTableListenerEx(listener, NOTIFY_NEW | NOTIFY_UPDATE); - } - - /** - * {@inheritDoc} - * - * @deprecated Use {@link - * edu.wpi.first.networktables.NetworkTable#addEntryListener(TableEntryListener, int)} instead - * (with flags value of NOTIFY_NEW | NOTIFY_UPDATE | NOTIFY_IMMEDIATE). - */ - @Override - @Deprecated - public void addTableListener(ITableListener listener, boolean immediateNotify) { - int flags = NOTIFY_NEW | NOTIFY_UPDATE; - if (immediateNotify) flags |= NOTIFY_IMMEDIATE; - addTableListenerEx(listener, flags); - } - - /* Base class for listeners; stores uid to implement remove functions */ - private static class ListenerBase { - public int uid; - } - - private static class OldTableListenerAdapter extends ListenerBase - implements Consumer { - private final int prefixLen; - private final ITable targetSource; - private final ITableListener targetListener; - - public OldTableListenerAdapter( - int prefixLen, ITable targetSource, ITableListener targetListener) { - this.prefixLen = prefixLen; - this.targetSource = targetSource; - this.targetListener = targetListener; - } - - @Override - public void accept(EntryNotification event) { - String relativeKey = event.name.substring(prefixLen); - if (relativeKey.indexOf(PATH_SEPARATOR) != -1) return; - targetListener.valueChangedEx(targetSource, relativeKey, event.value.getValue(), event.flags); - } - } - - private final HashMap> oldListenerMap = - new HashMap>(); - - /** - * {@inheritDoc} - * - * @deprecated Use {@link - * edu.wpi.first.networktables.NetworkTable#addEntryListener(TableEntryListener, int)} - * instead. - */ - @Override - @Deprecated - public synchronized void addTableListenerEx(ITableListener listener, int flags) { - List adapters = oldListenerMap.get(listener); - if (adapters == null) { - adapters = new ArrayList(); - oldListenerMap.put(listener, adapters); - } - OldTableListenerAdapter adapter = - new OldTableListenerAdapter(path.length() + 1, this, listener); - adapter.uid = inst.addEntryListener(pathWithSep, adapter, flags); - adapters.add(adapter); - } - - /** - * {@inheritDoc} - * - * @deprecated Use {@link edu.wpi.first.networktables.NetworkTable#addEntryListener(String, - * TableEntryListener, int)} or {@link NetworkTableEntry#addListener(Consumer, int)} instead. - */ - @Override - @Deprecated - public void addTableListener(String key, ITableListener listener, boolean immediateNotify) { - int flags = NOTIFY_NEW | NOTIFY_UPDATE; - if (immediateNotify) flags |= NOTIFY_IMMEDIATE; - addTableListenerEx(key, listener, flags); - } - - private static class OldKeyListenerAdapter extends ListenerBase - implements Consumer { - private final String relativeKey; - private final ITable targetSource; - private final ITableListener targetListener; - - public OldKeyListenerAdapter( - String relativeKey, ITable targetSource, ITableListener targetListener) { - this.relativeKey = relativeKey; - this.targetSource = targetSource; - this.targetListener = targetListener; - } - - @Override - public void accept(EntryNotification event) { - targetListener.valueChangedEx(targetSource, relativeKey, event.value.getValue(), event.flags); - } - } - - /** - * {@inheritDoc} - * - * @deprecated Use {@link edu.wpi.first.networktables.NetworkTable#addEntryListener(String, - * TableEntryListener, int)} or {@link NetworkTableEntry#addListener(Consumer, int)} instead. - */ - @Override - @Deprecated - public synchronized void addTableListenerEx(String key, ITableListener listener, int flags) { - List adapters = oldListenerMap.get(listener); - if (adapters == null) { - adapters = new ArrayList(); - oldListenerMap.put(listener, adapters); - } - OldKeyListenerAdapter adapter = new OldKeyListenerAdapter(key, this, listener); - adapter.uid = inst.addEntryListener(getEntry(key), adapter, flags); - adapters.add(adapter); - } - - /** - * {@inheritDoc} - * - * @deprecated Use {@link - * edu.wpi.first.networktables.NetworkTable#addSubTableListener(TableListener, boolean)} - * instead. - */ - @Override - @Deprecated - public void addSubTableListener(final ITableListener listener) { - addSubTableListener(listener, false); - } - - private static class OldSubListenerAdapter extends ListenerBase - implements Consumer { - private final int prefixLen; - private final ITable targetSource; - private final ITableListener targetListener; - private final Set notifiedTables = new HashSet(); - - public OldSubListenerAdapter( - int prefixLen, ITable targetSource, ITableListener targetListener) { - this.prefixLen = prefixLen; - this.targetSource = targetSource; - this.targetListener = targetListener; - } - - @Override - public void accept(EntryNotification event) { - String relativeKey = event.name.substring(prefixLen); - int endSubTable = relativeKey.indexOf(PATH_SEPARATOR); - if (endSubTable == -1) return; - String subTableKey = relativeKey.substring(0, endSubTable); - if (notifiedTables.contains(subTableKey)) return; - notifiedTables.add(subTableKey); - targetListener.valueChangedEx( - targetSource, subTableKey, targetSource.getSubTable(subTableKey), event.flags); - } - } - - /** - * {@inheritDoc} - * - * @deprecated Use {@link - * edu.wpi.first.networktables.NetworkTable#addSubTableListener(TableListener, boolean)} - * instead. - */ - @Override - @Deprecated - public synchronized void addSubTableListener(final ITableListener listener, boolean localNotify) { - List adapters = oldListenerMap.get(listener); - if (adapters == null) { - adapters = new ArrayList(); - oldListenerMap.put(listener, adapters); - } - OldSubListenerAdapter adapter = new OldSubListenerAdapter(path.length() + 1, this, listener); - int flags = NOTIFY_NEW | NOTIFY_IMMEDIATE; - if (localNotify) flags |= NOTIFY_LOCAL; - adapter.uid = inst.addEntryListener(pathWithSep, adapter, flags); - adapters.add(adapter); - } - - /** - * {@inheritDoc} - * - * @deprecated Use {@link edu.wpi.first.networktables.NetworkTable#removeTableListener(int)} - * instead. - */ - @Override - @Deprecated - public synchronized void removeTableListener(ITableListener listener) { - List adapters = oldListenerMap.remove(listener); - if (adapters != null) { - for (ListenerBase adapter : adapters) inst.removeEntryListener(adapter.uid); - } - } - - /** {@inheritDoc} */ - @Override - public ITable getSubTable(String key) { - return new NetworkTable(inst, pathWithSep + key); - } - - /** {@inheritDoc} */ - @Override - public boolean containsKey(String key) { - return getEntry(key).exists(); - } - - @Override - public boolean containsSubTable(String key) { - int[] handles = - NetworkTablesJNI.getEntries(inst.getHandle(), pathWithSep + key + PATH_SEPARATOR, 0); - return handles.length != 0; - } - - /** - * @param types bitmask of types; 0 is treated as a "don't care". - * @return keys currently in the table - */ - @Override - public Set getKeys(int types) { - Set keys = new HashSet(); - int prefixLen = path.length() + 1; - for (EntryInfo info : inst.getEntryInfo(pathWithSep, types)) { - String relativeKey = info.name.substring(prefixLen); - 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)); - } - } - return keys; - } - - /** {@inheritDoc} */ - @Override - public Set getKeys() { - return getKeys(0); - } - - /** {@inheritDoc} */ - @Override - public Set getSubTables() { - Set keys = new HashSet(); - int prefixLen = path.length() + 1; - for (EntryInfo info : inst.getEntryInfo(pathWithSep, 0)) { - String relativeKey = info.name.substring(prefixLen); - int endSubTable = relativeKey.indexOf(PATH_SEPARATOR); - if (endSubTable == -1) continue; - keys.add(relativeKey.substring(0, endSubTable)); - } - return keys; - } - - /** {@inheritDoc} */ - @Override - public boolean putNumber(String key, double value) { - return getEntry(key).setNumber(value); - } - - /** {@inheritDoc} */ - @Override - public boolean setDefaultNumber(String key, double defaultValue) { - return getEntry(key).setDefaultDouble(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public double getNumber(String key, double defaultValue) { - return getEntry(key).getDouble(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public boolean putString(String key, String value) { - return getEntry(key).setString(value); - } - - /** {@inheritDoc} */ - @Override - public boolean setDefaultString(String key, String defaultValue) { - return getEntry(key).setDefaultString(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public String getString(String key, String defaultValue) { - return getEntry(key).getString(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public boolean putBoolean(String key, boolean value) { - return getEntry(key).setBoolean(value); - } - - /** {@inheritDoc} */ - @Override - public boolean setDefaultBoolean(String key, boolean defaultValue) { - return getEntry(key).setDefaultBoolean(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public boolean getBoolean(String key, boolean defaultValue) { - return getEntry(key).getBoolean(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public boolean putBooleanArray(String key, boolean[] value) { - return getEntry(key).setBooleanArray(value); - } - - /** {@inheritDoc} */ - @Override - public boolean putBooleanArray(String key, Boolean[] value) { - return getEntry(key).setBooleanArray(value); - } - - /** {@inheritDoc} */ - @Override - public boolean setDefaultBooleanArray(String key, boolean[] defaultValue) { - return getEntry(key).setDefaultBooleanArray(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public boolean setDefaultBooleanArray(String key, Boolean[] defaultValue) { - return getEntry(key).setDefaultBooleanArray(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public boolean[] getBooleanArray(String key, boolean[] defaultValue) { - return getEntry(key).getBooleanArray(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public Boolean[] getBooleanArray(String key, Boolean[] defaultValue) { - return getEntry(key).getBooleanArray(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public boolean putNumberArray(String key, double[] value) { - return getEntry(key).setDoubleArray(value); - } - - /** {@inheritDoc} */ - @Override - public boolean putNumberArray(String key, Double[] value) { - return getEntry(key).setNumberArray(value); - } - - /** {@inheritDoc} */ - @Override - public boolean setDefaultNumberArray(String key, double[] defaultValue) { - return getEntry(key).setDefaultDoubleArray(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public boolean setDefaultNumberArray(String key, Double[] defaultValue) { - return getEntry(key).setDefaultNumberArray(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public double[] getNumberArray(String key, double[] defaultValue) { - return getEntry(key).getDoubleArray(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public Double[] getNumberArray(String key, Double[] defaultValue) { - return getEntry(key).getDoubleArray(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public boolean putStringArray(String key, String[] value) { - return getEntry(key).setStringArray(value); - } - - /** {@inheritDoc} */ - @Override - public boolean setDefaultStringArray(String key, String[] defaultValue) { - return getEntry(key).setDefaultStringArray(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public String[] getStringArray(String key, String[] defaultValue) { - return getEntry(key).getStringArray(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public boolean putRaw(String key, byte[] value) { - return getEntry(key).setRaw(value); - } - - /** {@inheritDoc} */ - @Override - public boolean setDefaultRaw(String key, byte[] defaultValue) { - return getEntry(key).setDefaultRaw(defaultValue); - } - - /** {@inheritDoc} */ - @Override - public boolean putRaw(String key, ByteBuffer value, int len) { - return getEntry(key).setRaw(value, len); - } - - /** {@inheritDoc} */ - @Override - public byte[] getRaw(String key, byte[] defaultValue) { - return getEntry(key).getRaw(defaultValue); - } - - /** - * Put a value in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @return False if the table key already exists with a different type - */ - public boolean putValue(String key, NetworkTableValue value) { - return getEntry(key).setValue(value); - } - - /** - * Sets the current value in the table if it does not exist. - * - * @param key the key - * @param defaultValue the default value to set if key doens't exist. - * @return False if the table key exists with a different type - */ - public boolean setDefaultValue(String key, NetworkTableValue defaultValue) { - return getEntry(key).setDefaultValue(defaultValue); - } - - /** - * Gets the value associated with a key as a NetworkTableValue object. - * - * @param key the key of the value to look up - * @return the value associated with the given key - */ - public NetworkTableValue getValue(String key) { - return getEntry(key).getValue(); - } - - /** - * {@inheritDoc} - * - * @deprecated Use {@link edu.wpi.first.networktables.NetworkTableEntry#setValue(Object)} instead, - * e.g. `NetworkTable.getEntry(key).setValue(NetworkTableEntry.makeBoolean(false));` or - * `NetworkTable.getEntry(key).setValue(new Boolean(false));` - */ - @Override - @Deprecated - public boolean putValue(String key, Object value) throws IllegalArgumentException { - if (value instanceof Boolean) return putBoolean(key, ((Boolean) value).booleanValue()); - else if (value instanceof Number) return putDouble(key, ((Number) value).doubleValue()); - else if (value instanceof String) return putString(key, (String) value); - else if (value instanceof byte[]) return putRaw(key, (byte[]) value); - else if (value instanceof boolean[]) return putBooleanArray(key, (boolean[]) value); - else if (value instanceof double[]) return putNumberArray(key, (double[]) value); - else if (value instanceof Boolean[]) return putBooleanArray(key, toNative((Boolean[]) value)); - else if (value instanceof Number[]) return putNumberArray(key, toNative((Number[]) value)); - else if (value instanceof String[]) return putStringArray(key, (String[]) value); - else if (value instanceof NetworkTableValue) - return getEntry(key).setValue((NetworkTableValue) value); - else - throw new IllegalArgumentException( - "Value of type " + value.getClass().getName() + " cannot be put into a table"); - } - - /** - * {@inheritDoc} - * - * @deprecated Use {@link edu.wpi.first.networktables.NetworkTableEntry#getValue()} instead, e.g. - * `NetworkTable.getEntry(key).getValue();` - */ - @Override - @Deprecated - public Object getValue(String key, Object defaultValue) { - NetworkTableValue value = getValue(key); - if (value.getType() == NetworkTableType.kUnassigned) { - return defaultValue; - } - return value.getValue(); - } - - /** The persistent flag value. */ - public static final int PERSISTENT = 1; - - /** {@inheritDoc} */ - @Override - public void setPersistent(String key) { - getEntry(key).setPersistent(); - } - - /** {@inheritDoc} */ - @Override - public void clearPersistent(String key) { - getEntry(key).clearPersistent(); - } - - /** {@inheritDoc} */ - @Override - public boolean isPersistent(String key) { - return getEntry(key).isPersistent(); - } - - /** {@inheritDoc} */ - @Override - public void setFlags(String key, int flags) { - getEntry(key).setFlags(flags); - } - - /** {@inheritDoc} */ - @Override - public void clearFlags(String key, int flags) { - getEntry(key).clearFlags(flags); - } - - /** {@inheritDoc} */ - @Override - public int getFlags(String key) { - return getEntry(key).getFlags(); - } - - /** {@inheritDoc} */ - @Override - public void delete(String key) { - getEntry(key).delete(); - } - - /** - * Deletes ALL keys in ALL subtables. Use with caution! - * - * @deprecated Use {@link NetworkTableInstance#deleteAllEntries()} instead. - */ - @Deprecated - public static void globalDeleteAll() { - NetworkTableInstance.getDefault().deleteAllEntries(); - } - - /** - * Flushes all updated values immediately to the network. Note: This is rate-limited to protect - * the network from flooding. This is primarily useful for synchronizing network updates with user - * code. - * - * @deprecated Use {@link NetworkTableInstance#flush()} instead. - */ - @Deprecated - public static void flush() { - NetworkTableInstance.getDefault().flush(); - } - - /** - * Set the periodic update rate. - * - * @param interval update interval in seconds (range 0.01 to 1.0) - * @deprecated Use {@link NetworkTableInstance#setUpdateRate(double)} instead. - */ - @Deprecated - public static void setUpdateRate(double interval) { - NetworkTableInstance.getDefault().setUpdateRate(interval); - } - - /** - * Saves persistent keys to a file. The server does this automatically. - * - * @param filename file name - * @throws PersistentException if error saving file - * @deprecated Use {@link NetworkTableInstance#savePersistent(String)} instead. - */ - @Deprecated - public static void savePersistent(String filename) throws PersistentException { - NetworkTableInstance.getDefault().savePersistent(filename); - } - - /** - * Loads persistent keys from a file. The server does this automatically. - * - * @param filename file name - * @return List of warnings (errors result in an exception instead) - * @throws PersistentException if error reading file - * @deprecated Use {@link NetworkTableInstance#loadPersistent(String)} instead. - */ - @Deprecated - public static String[] loadPersistent(String filename) throws PersistentException { - return NetworkTableInstance.getDefault().loadPersistent(filename); - } - - /* - * Deprecated Methods - */ - - /** - * {@inheritDoc} - * - * @deprecated Use {@link #putNumber(String, double)} instead. - */ - @Override - @Deprecated - public boolean putDouble(String key, double value) { - return putNumber(key, value); - } - - /** - * {@inheritDoc} - * - * @deprecated Use {@link #getNumber(String, double)} instead. - */ - @Override - @Deprecated - public double getDouble(String key, double defaultValue) { - return getNumber(key, defaultValue); - } - - /** {@inheritDoc} */ - @Override - public String getPath() { - return path; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (!(o instanceof NetworkTable)) { - return false; - } - NetworkTable other = (NetworkTable) o; - return inst.equals(other.inst) && path.equals(other.path); - } - - @Override - public int hashCode() { - return Objects.hash(inst, path); - } -} 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 deleted file mode 100644 index 508e8812b5..0000000000 --- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemote.java +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.tables; - -/** - * 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 - * - * @param listener the listener to be register - * @param immediateNotify if the listener object should be notified of the current connection - * state - */ - public void addConnectionListener(IRemoteConnectionListener listener, boolean immediateNotify); - - /** - * Unregister a listener from connection events - * - * @param listener the listener to be unregistered - */ - public void removeConnectionListener(IRemoteConnectionListener listener); - - /** - * Get the current state of the objects connection - * - * @return the current connection state - */ - public boolean isConnected(); - - /** - * If the object is acting as a server - * - * @return if the object is a server - */ - public boolean isServer(); -} 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 deleted file mode 100644 index ed5d02b8b6..0000000000 --- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/IRemoteConnectionListener.java +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.tables; - -import edu.wpi.first.networktables.ConnectionInfo; - -/** - * 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 - * - * @param remote the object that connected - */ - public void connected(IRemote remote); - /** - * Called when an IRemote is disconnected - * - * @param remote the object that disconnected - */ - public void disconnected(IRemote remote); - /** - * Extended version of connected called when an IRemote is connected. Contains the connection info - * of the connected remote - * - * @param remote the object that connected - * @param info the connection info for the connected remote - */ - public default void connectedEx(IRemote remote, ConnectionInfo info) { - connected(remote); - } - /** - * Extended version of connected called when an IRemote is disconnected. Contains the connection - * info of the disconnected remote - * - * @param remote the object that disconnected - * @param info the connection info for the disconnected remote - */ - public default void disconnectedEx(IRemote remote, ConnectionInfo info) { - disconnected(remote); - } -} 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 deleted file mode 100644 index 330484a73d..0000000000 --- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITable.java +++ /dev/null @@ -1,513 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.tables; - -import java.nio.ByteBuffer; -import java.util.Set; - -/** - * 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 { - - /** - * 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 - */ - public boolean containsKey(String key); - - /** - * @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 - */ - public boolean containsSubTable(String key); - - /** - * Returns the table at the specified key. If there is no table at the specified key, it will - * create a new table - * - * @param key the name of the table relative to this one - * @return a sub table relative to this one - */ - public ITable getSubTable(String key); - - /** - * Gets all keys in the table (not including sub-tables). - * - * @param types bitmask of types; 0 is treated as a "don't care". - * @return keys currently in the table - */ - public Set getKeys(int types); - - /** - * Gets all keys in the table (not including sub-tables). - * - * @return keys currently in the table - */ - public Set getKeys(); - - /** - * Gets the names of all subtables in the table. - * - * @return subtables currently in the table - */ - public Set getSubTables(); - - /** - * Makes a key's value persistent through program restarts. The key cannot be null. - * - * @param key the key name - */ - public void setPersistent(String key); - - /** - * Stop making a key's value persistent through program restarts. The key cannot be null. - * - * @param key the key name - */ - public void clearPersistent(String key); - - /** - * Returns whether the value is persistent through program restarts. The key cannot be null. - * - * @param key the key name - * @return True if the value is persistent. - */ - public boolean isPersistent(String key); - - /** - * Sets flags on the specified key in this table. The key can not be null. - * - * @param key the key name - * @param flags the flags to set (bitmask) - */ - public void setFlags(String key, int flags); - - /** - * Clears flags on the specified key in this table. The key can not be null. - * - * @param key the key name - * @param flags the flags to clear (bitmask) - */ - public void clearFlags(String key, int flags); - - /** - * Returns the flags for the specified key. - * - * @param key the key name - * @return the flags, or 0 if the key is not defined - */ - public int getFlags(String key); - - /** - * Deletes the specified key in this table. The key can not be null. - * - * @param key the key name - */ - public void delete(String key); - - /** - * Gets the value associated with a key as an object. NOTE: If the value is a double, it will - * return a Double object, not a primitive. To get the primitive, use {@link #getDouble(String, - * double)}. - * - * @param key the key of the value to look up - * @param defaultValue the default value if the key is null - * @return the value associated with the given key - */ - public Object getValue(String key, Object defaultValue); - - /** - * Put a value in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @return False if the table key already exists with a different type - * @throws IllegalArgumentException when the value is not supported by the table - */ - public boolean putValue(String key, Object value) throws IllegalArgumentException; - - /** - * Put a number in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @return False if the table key already exists with a different type - */ - public boolean putNumber(String key, double value); - - /** - * Gets the current value in the table, setting it if it does not exist. - * - * @param key the key - * @param defaultValue the default value to set if key doens't exist. - * @return False if the table key exists with a different type - */ - public boolean setDefaultNumber(String key, double defaultValue); - - /** - * Returns the number the key maps to. If the key does not exist or is of different type, it will - * return the default value. - * - * @param key the key to look up - * @param defaultValue the value to be returned if no value is found - * @return the value associated with the given key or the given default value if there is no value - * associated with the key - */ - public double getNumber(String key, double defaultValue); - - /** - * Put a string in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @return False if the table key already exists with a different type - */ - public boolean putString(String key, String value); - - /** - * Gets the current value in the table, setting it if it does not exist. - * - * @param key the key - * @param defaultValue the default value to set if key doens't exist. - * @return False if the table key exists with a different type - */ - public boolean setDefaultString(String key, String defaultValue); - - /** - * Returns the string the key maps to. If the key does not exist or is of different type, it will - * return the default value. - * - * @param key the key to look up - * @param defaultValue the value to be returned if no value is found - * @return the value associated with the given key or the given default value if there is no value - * associated with the key - */ - public String getString(String key, String defaultValue); - - /** - * Put a boolean in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @return False if the table key already exists with a different type - */ - public boolean putBoolean(String key, boolean value); - - /** - * Gets the current value in the table, setting it if it does not exist. - * - * @param key the key - * @param defaultValue the default value to set if key doens't exist. - * @return False if the table key exists with a different type - */ - public boolean setDefaultBoolean(String key, boolean defaultValue); - - /** - * Returns the boolean the key maps to. If the key does not exist or is of different type, it will - * return the default value. - * - * @param key the key to look up - * @param defaultValue the value to be returned if no value is found - * @return the value associated with the given key or the given default value if there is no value - * associated with the key - */ - public boolean getBoolean(String key, boolean defaultValue); - - /** - * Put a boolean array in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @return False if the table key already exists with a different type - */ - public boolean putBooleanArray(String key, boolean[] value); - - /** - * Gets the current value in the table, setting it if it does not exist. - * - * @param key the key - * @param defaultValue the default value to set if key doens't exist. - * @return False if the table key exists with a different type - */ - public boolean setDefaultBooleanArray(String key, boolean[] defaultValue); - - /** - * Put a boolean array in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @return False if the table key already exists with a different type - */ - public boolean putBooleanArray(String key, Boolean[] value); - - /** - * Gets the current value in the table, setting it if it does not exist. - * - * @param key the key - * @param defaultValue the default value to set if key doens't exist. - * @return False if the table key exists with a different type - */ - public boolean setDefaultBooleanArray(String key, Boolean[] defaultValue); - - /** - * Returns the boolean array the key maps to. If the key does not exist or is of different type, - * it will return the default value. - * - * @param key the key to look up - * @param defaultValue the value to be returned if no value is found - * @return the value associated with the given key or the given default value if there is no value - * associated with the key - */ - public boolean[] getBooleanArray(String key, boolean[] defaultValue); - /** - * Returns the boolean array the key maps to. If the key does not exist or is of different type, - * it will return the default value. - * - * @param key the key to look up - * @param defaultValue the value to be returned if no value is found - * @return the value associated with the given key or the given default value if there is no value - * associated with the key - */ - public Boolean[] getBooleanArray(String key, Boolean[] defaultValue); - - /** - * Put a number array in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @return False if the table key already exists with a different type - */ - public boolean putNumberArray(String key, double[] value); - - /** - * Gets the current value in the table, setting it if it does not exist. - * - * @param key the key - * @param defaultValue the default value to set if key doens't exist. - * @return False if the table key exists with a different type - */ - public boolean setDefaultNumberArray(String key, double[] defaultValue); - - /** - * Put a number array in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @return False if the table key already exists with a different type - */ - public boolean putNumberArray(String key, Double[] value); - - /** - * Gets the current value in the table, setting it if it does not exist. - * - * @param key the key - * @param defaultValue the default value to set if key doens't exist. - * @return False if the table key exists with a different type - */ - public boolean setDefaultNumberArray(String key, Double[] defaultValue); - - /** - * Returns the number array the key maps to. If the key does not exist or is of different type, it - * will return the default value. - * - * @param key the key to look up - * @param defaultValue the value to be returned if no value is found - * @return the value associated with the given key or the given default value if there is no value - * associated with the key - */ - public double[] getNumberArray(String key, double[] defaultValue); - /** - * Returns the number array the key maps to. If the key does not exist or is of different type, it - * will return the default value. - * - * @param key the key to look up - * @param defaultValue the value to be returned if no value is found - * @return the value associated with the given key or the given default value if there is no value - * associated with the key - */ - public Double[] getNumberArray(String key, Double[] defaultValue); - - /** - * Put a string array in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @return False if the table key already exists with a different type - */ - public boolean putStringArray(String key, String[] value); - - /** - * Gets the current value in the table, setting it if it does not exist. - * - * @param key the key - * @param defaultValue the default value to set if key doens't exist. - * @return False if the table key exists with a different type - */ - public boolean setDefaultStringArray(String key, String[] defaultValue); - - /** - * Returns the string array the key maps to. If the key does not exist or is of different type, it - * will return the default value. - * - * @param key the key to look up - * @param defaultValue the value to be returned if no value is found - * @return the value associated with the given key or the given default value if there is no value - * associated with the key - */ - public String[] getStringArray(String key, String[] defaultValue); - - /** - * Put a raw value (byte array) in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @return False if the table key already exists with a different type - */ - public boolean putRaw(String key, byte[] value); - - /** - * Gets the current value in the table, setting it if it does not exist. - * - * @param key the key - * @param defaultValue the default value to set if key doens't exist. - * @return False if the table key exists with a different type - */ - public boolean setDefaultRaw(String key, byte[] defaultValue); - - /** - * Put a raw value (bytes from a byte buffer) in the table - * - * @param key the key to be assigned to - * @param value the value that will be assigned - * @param len the length of the value - * @return False if the table key already exists with a different type - */ - public boolean putRaw(String key, ByteBuffer value, int len); - - /** - * Returns the raw value (byte array) the key maps to. If the key does not exist or is of - * different type, it will return the default value. - * - * @param key the key to look up - * @param defaultValue the value to be returned if no value is found - * @return the value associated with the given key or the given default value if there is no value - * associated with the key - */ - public byte[] getRaw(String key, byte[] defaultValue); - - /** Notifier flag values. */ - public static final int NOTIFY_IMMEDIATE = 0x01; - - public static final int NOTIFY_LOCAL = 0x02; - public static final int NOTIFY_NEW = 0x04; - public static final int NOTIFY_DELETE = 0x08; - public static final int NOTIFY_UPDATE = 0x10; - public static final int NOTIFY_FLAGS = 0x20; - - /** - * Add a listener for changes to the table - * - * @param listener the listener to add - */ - public void addTableListener(ITableListener listener); - /** - * Add a listener for changes to the table - * - * @param listener the listener to add - * @param immediateNotify if true then this listener will be notified of all current entries - * (marked as new) - */ - public void addTableListener(ITableListener listener, boolean immediateNotify); - /** - * Add a listener for changes to the table - * - * @param listener the listener to add - * @param flags bitmask specifying desired notifications - */ - public void addTableListenerEx(ITableListener listener, int flags); - - /** - * Add a listener for changes to a specific key the table - * - * @param key the key to listen for - * @param listener the listener to add - * @param immediateNotify if true then this listener will be notified of all current entries - * (marked as new) - */ - public void addTableListener(String key, ITableListener listener, boolean immediateNotify); - /** - * Add a listener for changes to a specific key the table - * - * @param key the key to listen for - * @param listener the listener to add - * @param flags bitmask specifying desired notifications - */ - public void addTableListenerEx(String key, ITableListener listener, int flags); - /** - * This will immediately notify the listener of all current sub tables - * - * @param listener the listener to notify - */ - public void addSubTableListener(final ITableListener listener); - /** - * This will immediately notify the listener of all current sub tables - * - * @param listener the listener to notify - * @param localNotify if true then this listener will be notified of all local changes in addition - * to all remote changes - */ - public void addSubTableListener(final ITableListener listener, boolean localNotify); - /** - * Remove a listener from receiving table events - * - * @param listener the listener to be removed - */ - public void removeTableListener(ITableListener listener); - - /* - * Deprecated Methods - */ - - /** - * Maps the specified key to the specified value in this table. The key can not be null. The value - * can be retrieved by calling the get method with a key that is equal to the original key. - * - * @param key the key - * @param value the value - * @return False if the table key already exists with a different type - * @throws IllegalArgumentException if key is null - * @deprecated Use {@link #putNumber(String, double)} instead. - */ - @Deprecated - public boolean putDouble(String key, double value); - - /** - * Returns the value at the specified key. - * - * @param key the key - * @param defaultValue the value returned if the key is undefined - * @return the value - * @throws IllegalArgumentException if the value mapped to by the key is not a double - * @throws IllegalArgumentException if the key is null - * @deprecated Use {@link #getNumber(String, double)} instead. - */ - @Deprecated - public double getDouble(String key, double defaultValue); - - /** - * Gets the full path of this table. Does not include the trailing "/". - * - * @return The path to this table (e.g. "", "/foo"). - */ - public String getPath(); -} 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 deleted file mode 100644 index 3ff81f17ec..0000000000 --- a/ntcore/src/main/java/edu/wpi/first/wpilibj/tables/ITableListener.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.tables; - -/** - * 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} - * - * @param source the table the key-value pair exists in - * @param key the key associated with the value that changed - * @param value the new value - * @param isNew true if the key did not previously exist in the table, otherwise it is false - */ - public void valueChanged(ITable source, String key, Object value, boolean isNew); - - /** - * Extended version of valueChanged. Called when a key-value pair is changed in a {@link ITable}. - * The default implementation simply calls valueChanged(). If this is overridden, valueChanged() - * will not be called. - * - * @param source the table the key-value pair exists in - * @param key the key associated with the value that changed - * @param value the new value - * @param flags update flags; for example, NOTIFY_NEW if the key did not previously exist in the - * table - */ - public default void valueChangedEx(ITable source, String key, Object value, int flags) { - // NOTIFY_NEW = 0x04 - valueChanged(source, key, value, (flags & 0x04) != 0); - } -}