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.function.BooleanConsumer;
008
009/** NetworkTables Boolean publisher. */
010public interface BooleanPublisher extends Publisher, BooleanConsumer {
011  /**
012   * Get the corresponding topic.
013   *
014   * @return Topic
015   */
016  @Override
017  BooleanTopic getTopic();
018
019  /**
020   * Publish a new value using current NT time.
021   *
022   * @param value value to publish
023   */
024  default void set(boolean value) {
025    set(value, 0);
026  }
027
028  /**
029   * Publish a new value.
030   *
031   * @param value value to publish
032   * @param time timestamp; 0 indicates current NT time should be used
033   */
034  void set(boolean value, long time);
035
036  /**
037   * Publish a default value.
038   * On reconnect, a default value will never be used in preference to a
039   * published value.
040   *
041   * @param value value
042   */
043  void setDefault(boolean value);
044
045  @Override
046  default void accept(boolean value) {
047    set(value);
048  }
049}