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 notification. */ 008public final class EntryNotification { 009 /** Listener that was triggered. */ 010 @SuppressWarnings("MemberName") 011 public final int listener; 012 013 /** Entry handle. */ 014 @SuppressWarnings("MemberName") 015 public final int entry; 016 017 /** Entry name. */ 018 @SuppressWarnings("MemberName") 019 public final String name; 020 021 /** The new value. */ 022 @SuppressWarnings("MemberName") 023 public final NetworkTableValue value; 024 025 /** 026 * Update flags. For example, {@link EntryListenerFlags#kNew} if the key did not previously exist. 027 */ 028 @SuppressWarnings("MemberName") 029 public final int flags; 030 031 /** 032 * Constructor. This should generally only be used internally to NetworkTables. 033 * 034 * @param inst Instance 035 * @param listener Listener that was triggered 036 * @param entry Entry handle 037 * @param name Entry name 038 * @param value The new value 039 * @param flags Update flags 040 */ 041 public EntryNotification( 042 NetworkTableInstance inst, 043 int listener, 044 int entry, 045 String name, 046 NetworkTableValue value, 047 int flags) { 048 this.m_inst = inst; 049 this.listener = listener; 050 this.entry = entry; 051 this.name = name; 052 this.value = value; 053 this.flags = flags; 054 } 055 056 /* Network table instance. */ 057 private final NetworkTableInstance m_inst; 058 059 /* Cached entry object. */ 060 NetworkTableEntry m_entryObject; 061 062 /** 063 * Get the entry as an object. 064 * 065 * @return NetworkTableEntry for this entry. 066 */ 067 public NetworkTableEntry getEntry() { 068 if (m_entryObject == null) { 069 m_entryObject = new NetworkTableEntry(m_inst, entry); 070 } 071 return m_entryObject; 072 } 073}