Class AbstractBaseValidatingInputTable

java.lang.Object
io.deephaven.server.table.inputtables.AbstractBaseValidatingInputTable
All Implemented Interfaces:
InputTableUpdater
Direct Known Subclasses:
DoubleRangeValidatingInputTable, NonEmptyValidatingInputTable, NotNullValidatingInputTable, RangeValidatingInputTable, StringListValidatingInputTable

public abstract class AbstractBaseValidatingInputTable extends Object implements InputTableUpdater
An abstract base class for InputTableUpdater implementations that wrap an existing input table.

This class provides a default implementation for most methods by delegating to the wrapped input table. Subclasses should override getColumnRestrictions(String) and validateAddOrModify(Table) to provide custom validation logic.

  • Field Details

  • Constructor Details

    • AbstractBaseValidatingInputTable

      protected AbstractBaseValidatingInputTable(InputTableUpdater wrapped)
      Construct a new validating input table that wraps the given input table.
      Parameters:
      wrapped - the input table to wrap
  • Method Details

    • wrapUpdater

      protected static Table wrapUpdater(Table input, UnaryOperator<InputTableUpdater> createUpdater)
      Wraps an existing input table updater with a new validating updater created by the provided createUpdater function.
      Parameters:
      input - the input table, must have an InputTableUpdater as its Table.INPUT_TABLE_ATTRIBUTE
      createUpdater - a function that takes the existing input table's updater and returns a new validating updater
      Returns:
      a new input table that validates according to the provided createUpdater function
    • getKeyNames

      public List<String> getKeyNames()
      Description copied from interface: InputTableUpdater
      Gets the names of the key columns.
      Specified by:
      getKeyNames in interface InputTableUpdater
      Returns:
      a list with the names of the key columns of this input table
    • getValueNames

      public List<String> getValueNames()
      Description copied from interface: InputTableUpdater
      Gets the names of the value columns. By default, any column not marked as a key column is a value column.
      Specified by:
      getValueNames in interface InputTableUpdater
      Returns:
      a list with the names of the value columns of this input table
    • getColumnRestrictions

      @Nullable public abstract @Nullable List<com.google.protobuf.Any> getColumnRestrictions(String columnName)
      Description copied from interface: InputTableUpdater
      If there are client-side defined restrictions on this column, return them as a list of protobuf Any messages. These restrictions are used by the client for properly displaying and validating the edit field.

      The restrictions are packed as google.protobuf.Any messages, which allows for different restriction types (e.g., IntegerRangeRestriction, DoubleRangeRestriction, StringListRestriction, etc.) to be sent to the client. The client is responsible for unpacking and interpreting these restrictions.

      Specified by:
      getColumnRestrictions in interface InputTableUpdater
      Parameters:
      columnName - the column name to query
      Returns:
      a list of protobuf Any messages representing the restrictions for this column, or null if no client-side restrictions are supplied for this column
    • getTableDefinition

      public TableDefinition getTableDefinition()
      Description copied from interface: InputTableUpdater
      Get the underlying Table definition (which includes the names and types of all of the columns).
      Specified by:
      getTableDefinition in interface InputTableUpdater
      Returns:
      the TableDefinition for our user-visible table
    • validateAddOrModify

      public abstract void validateAddOrModify(Table tableToApply)
      Description copied from interface: InputTableUpdater
      Helper to check if a table is compatible with this table, so that it could be added as contents.
      Specified by:
      validateAddOrModify in interface InputTableUpdater
      Parameters:
      tableToApply - the table to check if it can used to add or modify this input table
    • validateDelete

      public void validateDelete(Table tableToDelete)
      Description copied from interface: InputTableUpdater
      Validates that the given table definition is suitable to be passed to InputTableUpdater.delete(Table).
      Specified by:
      validateDelete in interface InputTableUpdater
      Parameters:
      tableToDelete - The definition of the table to delete
    • add

      public void add(Table newData) throws IOException
      Description copied from interface: InputTableUpdater
      Write newData to this table. Added rows with keys that match existing rows will instead replace those rows, if supported.

      This method will block until the add is "completed", where the definition of "completed" is implementation dependenent.

      For implementations where "completed" means "visible in the next update graph cycle", this method is not suitable for use from a table listener or any other notification-dispatched callback dispatched by this InputTable's update graph. It may be suitable to delete from another update graph if doing so does not introduce any cycles.

      Specified by:
      add in interface InputTableUpdater
      Parameters:
      newData - The data to write to this table
      Throws:
      IOException - If there is an error writing the data
    • addAsync

      public void addAsync(Table newData, InputTableStatusListener listener)
      Description copied from interface: InputTableUpdater
      Write newData to this table. Added rows with keys that match existing rows replace those rows, if supported.

      The callback to listener will happen when the add has "completed", where the definition of "completed" is implementation dependenent. It's possible that the callback happens immediately on the same thread.

      This method will not block, and can be safely used from a table listener or any other notification-dispatched callback as long as table is already satisfied on the current cycle.

      Specified by:
      addAsync in interface InputTableUpdater
      Parameters:
      newData - The data to write to this table
      listener - The listener for asynchronous results
    • delete

      public void delete(Table table) throws IOException
      Description copied from interface: InputTableUpdater
      Delete the keys contained in table from this input table.

      This method will block until the delete is "completed", where the definition of "completed" is implementation dependenent.

      For implementations where "completed" means "visible in the next update graph cycle", this method is not suitable for use from a table listener or any other notification-dispatched callback dispatched by this InputTable's update graph. It may be suitable to delete from another update graph if doing so does not introduce any cycles.

      Specified by:
      delete in interface InputTableUpdater
      Parameters:
      table - The rows to delete
      Throws:
      IOException - If a problem occurred while deleting the rows.
    • deleteAsync

      public void deleteAsync(Table table, InputTableStatusListener listener)
      Description copied from interface: InputTableUpdater
      Delete the keys contained in table from this input table.

      The callback to listener will happen when the delete has "completed", where the definition of "completed" is implementation dependenent. It's possible that the callback happens immediately on the same thread.

      This method will not block, and can be safely used from a table listener or any other notification-dispatched callback as long as table is already satisfied on the current cycle.

      Specified by:
      deleteAsync in interface InputTableUpdater
      Parameters:
      table - Table containing the rows to delete
    • isKey

      public boolean isKey(String columnName)
      Description copied from interface: InputTableUpdater
      Returns true if the specified column is a key.
      Specified by:
      isKey in interface InputTableUpdater
      Parameters:
      columnName - the column to interrogate
      Returns:
      true if columnName is a key column, false otherwise
    • hasColumn

      public boolean hasColumn(String columnName)
      Description copied from interface: InputTableUpdater
      Returns true if the specified column exists in this InputTable.
      Specified by:
      hasColumn in interface InputTableUpdater
      Parameters:
      columnName - the column to interrogate
      Returns:
      true if columnName exists in this InputTable