// 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.

// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY

package org.wpilib.networktables;

/** NetworkTables {{ TypeName }} topic. */
public final class {{ TypeName }}Topic extends Topic {
{%- if TypeString %}
  /** The default type string for this topic type. */
  public static final String TYPE_STRING = {{ TypeString }};
{% endif %}
  /**
   * Construct from a generic topic.
   *
   * @param topic Topic
   */
  public {{ TypeName }}Topic(Topic topic) {
    super(topic.m_inst, topic.m_handle);
  }

  /**
   * Constructor; use NetworkTableInstance.get{{TypeName}}Topic() instead.
   *
   * @param inst Instance
   * @param handle Native handle
   */
  public {{ TypeName }}Topic(NetworkTableInstance inst, int handle) {
    super(inst, handle);
  }

  /**
   * Create a new subscriber to the topic.
   *
   * <p>The subscriber is only active as long as the returned object
   * is not closed.
   *
   * <p>Subscribers that do not match the published data type do not return
   * any values. To determine if the data type matches, use the appropriate
   * Topic functions.
   *
{%- if not TypeString %}
   * @param typeString type string
{% endif %}
   * @param defaultValue default value used when a default is not provided to a
   *        getter function
   * @param options subscribe options
   * @return subscriber
   */
  public {{ TypeName }}Subscriber subscribe(
{%- if not TypeString %}
      String typeString,
{% endif %}
      {{ java.ValueType }} defaultValue,
      PubSubOption... options) {
    return new {{ TypeName }}EntryImpl(
        this,
        NetworkTablesJNI.subscribe(
            m_handle, NetworkTableType.{{ TYPE_NAME }}.getValue(),
            {{ TypeString|default('typeString') }}, options),
        defaultValue);
  }
{% if TypeString %}
  /**
   * Create a new subscriber to the topic, with specified type string.
   *
   * <p>The subscriber is only active as long as the returned object
   * is not closed.
   *
   * <p>Subscribers that do not match the published data type do not return
   * any values. To determine if the data type matches, use the appropriate
   * Topic functions.
   *
   * @param typeString type string
   * @param defaultValue default value used when a default is not provided to a
   *        getter function
   * @param options subscribe options
   * @return subscriber
   */
  public {{ TypeName }}Subscriber subscribeEx(
      String typeString,
      {{ java.ValueType }} defaultValue,
      PubSubOption... options) {
    return new {{ TypeName }}EntryImpl(
        this,
        NetworkTablesJNI.subscribe(
            m_handle, NetworkTableType.{{ TYPE_NAME }}.getValue(),
            typeString, options),
        defaultValue);
  }
{% endif %}
  /**
   * Create a new publisher to the topic.
   *
   * <p>The publisher is only active as long as the returned object
   * is not closed.
   *
   * <p>It is not possible to publish two different data types to the same
   * topic. Conflicts between publishers are typically resolved by the server on
   * a first-come, first-served basis. Any published values that do not match
   * the topic's data type are dropped (ignored). To determine if the data type
   * matches, use the appropriate Topic functions.
   *
{%- if not TypeString %}
   * @param typeString type string
{% endif %}
   * @param options publish options
   * @return publisher
   */
  public {{ TypeName }}Publisher publish(
{%- if not TypeString %}
      String typeString,
{% endif %}
      PubSubOption... options) {
    return new {{ TypeName }}EntryImpl(
        this,
        NetworkTablesJNI.publish(
            m_handle, NetworkTableType.{{ TYPE_NAME }}.getValue(),
            {{ TypeString|default('typeString') }}, options),
        {{ java.EmptyValue }});
  }

  /**
   * Create a new publisher to the topic, with type string and initial properties.
   *
   * <p>The publisher is only active as long as the returned object
   * is not closed.
   *
   * <p>It is not possible to publish two different data types to the same
   * topic. Conflicts between publishers are typically resolved by the server on
   * a first-come, first-served basis. Any published values that do not match
   * the topic's data type are dropped (ignored). To determine if the data type
   * matches, use the appropriate Topic functions.
   *
   * @param typeString type string
   * @param properties JSON properties
   * @param options publish options
   * @return publisher
   * @throws IllegalArgumentException if properties is not a JSON object
   */
  public {{ TypeName }}Publisher publishEx(
      String typeString,
      String properties,
      PubSubOption... options) {
    return new {{ TypeName }}EntryImpl(
        this,
        NetworkTablesJNI.publishEx(
            m_handle, NetworkTableType.{{ TYPE_NAME }}.getValue(),
            typeString, properties, options),
        {{ java.EmptyValue }});
  }

  /**
   * Create a new entry for the topic.
   *
   * <p>Entries act as a combination of a subscriber and a weak publisher. The
   * subscriber is active as long as the entry is not closed. The publisher is
   * created when the entry is first written to, and remains active until either
   * unpublish() is called or the entry is closed.
   *
   * <p>It is not possible to use two different data types with the same
   * topic. Conflicts between publishers are typically resolved by the server on
   * a first-come, first-served basis. Any published values that do not match
   * the topic's data type are dropped (ignored), and the entry will show no new
   * values if the data type does not match. To determine if the data type
   * matches, use the appropriate Topic functions.
   *
{%- if not TypeString %}
   * @param typeString type string
{% endif %}
   * @param defaultValue default value used when a default is not provided to a
   *        getter function
   * @param options publish and/or subscribe options
   * @return entry
   */
  public {{ TypeName }}Entry getEntry(
{%- if not TypeString %}
      String typeString,
{% endif %}
      {{ java.ValueType }} defaultValue,
      PubSubOption... options) {
    return new {{ TypeName }}EntryImpl(
        this,
        NetworkTablesJNI.getEntry(
            m_handle, NetworkTableType.{{ TYPE_NAME }}.getValue(),
            {{ TypeString|default('typeString') }}, options),
        defaultValue);
  }
{% if TypeString %}
  /**
   * Create a new entry for the topic, with specified type string.
   *
   * <p>Entries act as a combination of a subscriber and a weak publisher. The
   * subscriber is active as long as the entry is not closed. The publisher is
   * created when the entry is first written to, and remains active until either
   * unpublish() is called or the entry is closed.
   *
   * <p>It is not possible to use two different data types with the same
   * topic. Conflicts between publishers are typically resolved by the server on
   * a first-come, first-served basis. Any published values that do not match
   * the topic's data type are dropped (ignored), and the entry will show no new
   * values if the data type does not match. To determine if the data type
   * matches, use the appropriate Topic functions.
   *
   * @param typeString type string
   * @param defaultValue default value used when a default is not provided to a
   *        getter function
   * @param options publish and/or subscribe options
   * @return entry
   */
  public {{ TypeName }}Entry getEntryEx(
      String typeString,
      {{ java.ValueType }} defaultValue,
      PubSubOption... options) {
    return new {{ TypeName }}EntryImpl(
        this,
        NetworkTablesJNI.getEntry(
            m_handle, NetworkTableType.{{ TYPE_NAME }}.getValue(),
            typeString, options),
        defaultValue);
  }
{% endif %}
}

