001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.networktables;
006
007import edu.wpi.first.util.sendable.SendableBuilder;
008import java.util.function.Consumer;
009import java.util.function.Supplier;
010
011public interface NTSendableBuilder extends SendableBuilder {
012  /**
013   * Set the function that should be called to update the network table for things other than
014   * properties. Note this function is not passed the network table object; instead it should use
015   * the entry handles returned by getEntry().
016   *
017   * @param func function
018   */
019  void setUpdateTable(Runnable func);
020
021  /**
022   * Add a property without getters or setters. This can be used to get entry handles for the
023   * function called by setUpdateTable().
024   *
025   * @param key property name
026   * @return Network table entry
027   */
028  NetworkTableEntry getEntry(String key);
029
030  /**
031   * Add a NetworkTableValue property.
032   *
033   * @param key property name
034   * @param getter getter function (returns current value)
035   * @param setter setter function (sets new value)
036   */
037  void addValueProperty(
038      String key, Supplier<NetworkTableValue> getter, Consumer<NetworkTableValue> setter);
039
040  /**
041   * Get the network table.
042   *
043   * @return The network table
044   */
045  NetworkTable getTable();
046
047  @Override
048  default BackendKind getBackendKind() {
049    return BackendKind.kNetworkTables;
050  }
051}