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
007/** NetworkTables Entry information. */
008public final class EntryInfo {
009  /** Entry handle. */
010  @SuppressWarnings("MemberName")
011  public final int entry;
012
013  /** Entry name. */
014  @SuppressWarnings("MemberName")
015  public final String name;
016
017  /** Entry type. */
018  @SuppressWarnings("MemberName")
019  public final NetworkTableType type;
020
021  /** Entry flags. */
022  @SuppressWarnings("MemberName")
023  public final int flags;
024
025  /** Timestamp of last change to entry (type or value). */
026  @SuppressWarnings("MemberName")
027  public final long last_change;
028
029  /**
030   * Constructor. This should generally only be used internally to NetworkTables.
031   *
032   * @param inst Instance
033   * @param entry Entry handle
034   * @param name Name
035   * @param type Type (integer version of {@link NetworkTableType})
036   * @param flags Flags
037   * @param lastChange Timestamp of last change
038   */
039  public EntryInfo(
040      NetworkTableInstance inst, int entry, String name, int type, int flags, long lastChange) {
041    this.m_inst = inst;
042    this.entry = entry;
043    this.name = name;
044    this.type = NetworkTableType.getFromInt(type);
045    this.flags = flags;
046    this.last_change = lastChange;
047  }
048
049  /* Network table instance. */
050  private final NetworkTableInstance m_inst;
051
052  /* Cached entry object. */
053  private NetworkTableEntry m_entryObject;
054
055  /**
056   * Get the entry as an object.
057   *
058   * @return NetworkTableEntry for this entry.
059   */
060  NetworkTableEntry getEntry() {
061    if (m_entryObject == null) {
062      m_entryObject = new NetworkTableEntry(m_inst, entry);
063    }
064    return m_entryObject;
065  }
066}