001package edu.wpi.first.wpilibj.tables;
002
003/**
004 * A listener that listens to changes in values in a {@link ITable}
005 * 
006 * @author Mitchell
007 *
008 */
009@FunctionalInterface
010public interface ITableListener {
011    /**
012     * Called when a key-value pair is changed in a {@link ITable}
013     * @param source the table the key-value pair exists in
014     * @param key the key associated with the value that changed
015     * @param value the new value
016     * @param isNew true if the key did not previously exist in the table, otherwise it is false
017     */
018    public void valueChanged(ITable source, String key, Object value, boolean isNew);
019
020    /**
021     * Extended version of valueChanged.  Called when a key-value pair is
022     * changed in a {@link ITable}.  The default implementation simply calls
023     * valueChanged().  If this is overridden, valueChanged() will not be
024     * called.
025     * @param source the table the key-value pair exists in
026     * @param key the key associated with the value that changed
027     * @param value the new value
028     * @param flags update flags; for example, NOTIFY_NEW if the key did not
029     * previously exist in the table
030     */
031    default public void valueChangedEx(ITable source, String key, Object value, int flags) {
032        // NOTIFY_NEW = 0x04
033        valueChanged(source, key, value, (flags & 0x04) != 0);
034    }
035}