Class ArgumentValidations

java.lang.Object
io.deephaven.plot.util.ArgumentValidations

public class ArgumentValidations extends Object
Utilities for validating that plotting arguments are acceptable.
  • Constructor Details

    • ArgumentValidations

      public ArgumentValidations()
  • Method Details

    • assertGreaterThan0

      public static void assertGreaterThan0(double d, String name, PlotInfo plotInfo)
      Requires the input object o to be non-null.
      Parameters:
      d - value
      name - variable name
      plotInfo - source of the exception
      Throws:
      IllegalArgumentException - o is null
    • assertNotNull

      public static void assertNotNull(Object o, String message, PlotInfo plotInfo)
      Requires the input object o to be non-null.
      Parameters:
      o - object
      message - error message
      plotInfo - source of the exception
      Throws:
      IllegalArgumentException - o is null
    • assertNotNullAndNotEmpty

      public static <T> void assertNotNullAndNotEmpty(T[] o, String message, PlotInfo plotInfo)
      Requires the input object o to be non-null.
      Parameters:
      o - object
      message - error message
      plotInfo - source of the exception
      Throws:
      IllegalArgumentException - o is null
    • assertNull

      public static void assertNull(Object o, String message, PlotInfo plotInfo)
    • assertInstance

      public static void assertInstance(Class c1, Class c2, String message, PlotInfo plotInfo)
      Requires Class c1 be an instance of Class c2.
      Parameters:
      c1 - class
      c2 - class
      message - error message
      plotInfo - source of the exception
      Throws:
      NullPointerException - c1 and c2 must not be null
      PlotRuntimeException - c1 is not assignable to c2
      IllegalArgumentException - o is null
    • assertInstance

      public static void assertInstance(Table t, String column, Class c, String message, PlotInfo plotInfo)
      Requires the column of be an instance of Class c.
      Parameters:
      t - table
      column - column
      c - class
      message - error message
      plotInfo - source of the exception
      Throws:
      NullPointerException - t and c must not be null
      PlotRuntimeException - column is not a column of t, or column does not have data type c
    • assertInstance

      public static void assertInstance(TableDefinition t, String column, Class c, String message, PlotInfo plotInfo)
      Requires the column of be an instance of Class c.
      Parameters:
      t - table
      column - column
      c - class
      message - error message
      plotInfo - source of the exception
      Throws:
      NullPointerException - t and c must not be null
      PlotRuntimeException - column is not a column of t, or column does not have data type c
    • assertInstance

      public static void assertInstance(SelectableDataSet sds, String column, Class c, String message, PlotInfo plotInfo)
      Requires the column of be an instance of Class c.
      Parameters:
      sds - swappable data set
      column - column
      c - class
      message - error message
      plotInfo - source of the exception
      Throws:
      NullPointerException - sds and c must not be null
      PlotRuntimeException - column is not a column of t, or column does not have data type c
    • assertIsNumericOrTimeOrCharOrComparableInstance

      public static void assertIsNumericOrTimeOrCharOrComparableInstance(Table t, String column, PlotInfo plotInfo)
      Requires the column of be numeric, or an instance of time, char/Character, or Comparable.
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Throws:
      NullPointerException - t must not be null
      PlotRuntimeException - column is not a column of t, or column does not have the correct data type
    • assertIsNumericOrTimeOrCharOrComparableInstance

      public static void assertIsNumericOrTimeOrCharOrComparableInstance(TableDefinition t, String column, PlotInfo plotInfo)
      Requires the column of be numeric, or an instance of time, char/Character, or Comparable.
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Throws:
      NullPointerException - t must not be null
      PlotRuntimeException - column is not a column of t, or column does not have the correct data type
    • assertIsNumericOrTimeOrCharOrComparableInstance

      public static void assertIsNumericOrTimeOrCharOrComparableInstance(Table t, String column, String message, PlotInfo plotInfo)
      Requires the column of be numeric, or an instance of time, char/Character, or Comparable.
      Parameters:
      t - table
      column - column
      message - error message
      plotInfo - source of the exception
      Throws:
      NullPointerException - t must not be null
      PlotRuntimeException - column is not a column of t, or column does not have the correct data type
    • assertIsNumericOrTimeOrCharOrComparableInstance

      public static void assertIsNumericOrTimeOrCharOrComparableInstance(TableDefinition t, String column, String message, PlotInfo plotInfo)
      Requires the column of be numeric, or an instance of time, char/Character, or Comparable.
      Parameters:
      t - table
      column - column
      message - error message
      plotInfo - source of the exception
      Throws:
      NullPointerException - t must not be null
      PlotRuntimeException - column is not a column of t, or column does not have the correct data type
    • assertSameSize

      public static void assertSameSize(IndexableNumericData[] data, String[] dataNames, PlotInfo plotInfo)
      Requires data and dataNames 1. contain the same number of members. 2. contain no null members All members of data must be the same size.
      Parameters:
      data - array of IndexableNumericData
      dataNames - names for each IndexableNumericData
      plotInfo - source of the exception
      Throws:
      PlotIllegalStateException - data and dataNames are not the same size
      PlotIllegalArgumentException - a member of data or dataNames is null 2+ members of data are not the same size
    • getColumnType

      public static Class getColumnType(Table t, String column, PlotInfo plotInfo)
      Gets the data type of the column.
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Returns:
      data type of column
      Throws:
      PlotRuntimeException - column not in the table
    • getColumnType

      public static Class getColumnType(TableDefinition t, String column, PlotInfo plotInfo)
      Gets the data type of the column.
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Returns:
      data type of column
      Throws:
      PlotRuntimeException - column not in the table
    • getColumnType

      public static Class getColumnType(SelectableDataSet sds, String column, PlotInfo plotInfo)
      Gets the data type of the column.
      Parameters:
      sds - selectable dataset
      column - column
      plotInfo - source of the exception
      Returns:
      data type of column
      Throws:
      PlotRuntimeException - column not in the table
    • isTime

      public static boolean isTime(Class c, PlotInfo plotInfo)
      Whether the class is equal to Date.class or Instant.class
      Parameters:
      c - class
      plotInfo - source of the exception
      Returns:
      true if c equals Date.class or Instant.class, false otherwise
    • isNumericOrTime

      public static boolean isNumericOrTime(Class c)
      Parameters:
      c - class
      Returns:
      true if c is a numeric or time class, false otherwise
    • isNumericOrTime

      public static boolean isNumericOrTime(Class c, PlotInfo plotInfo)
      Parameters:
      c - class
      plotInfo - source of the exception
      Returns:
      true if c is a numeric or time class, false otherwise
    • isTime

      public static boolean isTime(Table t, String column, PlotInfo plotInfo)
      Whether the column's data type equals Date.class or Instant.class
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Returns:
      true if the column's data type equals Date.class or Instant.class, false otherwise
    • isTime

      public static boolean isTime(TableDefinition t, String column, PlotInfo plotInfo)
      Whether the column's data type equals Date.class or Instant.class
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Returns:
      true if the column's data type equals Date.class or Instant.class, false otherwise
    • isTime

      public static boolean isTime(SelectableDataSet sds, String column, PlotInfo plotInfo)
      Whether the column's data type equals Date.class or Instant.class
      Parameters:
      sds - selectable dataset
      column - column
      plotInfo - source of the exception
      Returns:
      true if the column's data type equals Date.class or Instant.class, false otherwise
    • isPrimitiveNumeric

      public static boolean isPrimitiveNumeric(Table t, String column, PlotInfo plotInfo)
      Whether the column's data type NumericTypeUtils.isPrimitiveNumeric(Class).
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Returns:
      true if the column's data type is a numeric primitive, false otherwise
    • isBoxedNumeric

      public static boolean isBoxedNumeric(Table t, String column, PlotInfo plotInfo)
      Whether the column's data type NumericTypeUtils.isBoxedNumeric(Class).
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Returns:
      true if the column's data type is a boxed numeric, false otherwise
    • isNumeric

      public static boolean isNumeric(Table t, String column, PlotInfo plotInfo)
      Whether the column's data type NumericTypeUtils.isNumeric(Class).
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Returns:
      true if the column's data type is numeric, false otherwise
    • isNumeric

      public static boolean isNumeric(TableDefinition t, String column, PlotInfo plotInfo)
      Whether the column's data type NumericTypeUtils.isNumeric(Class).
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Returns:
      true if the column's data type is numeric, false otherwise
    • isNumeric

      public static boolean isNumeric(SelectableDataSet sds, String column, PlotInfo plotInfo)
      Whether the column's data type NumericTypeUtils.isNumeric(Class).
      Parameters:
      sds - selectable dataset
      column - column
      plotInfo - source of the exception
      Returns:
      true if the column's data type is numeric, false otherwise
    • isNumericOrTime

      public static boolean isNumericOrTime(Table t, String column, PlotInfo plotInfo)
      Whether the column's data type isNumericOrTime(Class, PlotInfo).
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Returns:
      true if the column's data type is a numeric or time instance, false otherwise
    • isNumericOrTime

      public static boolean isNumericOrTime(TableDefinition t, String column, PlotInfo plotInfo)
      Whether the column's data type isNumericOrTime(Class, PlotInfo).
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Returns:
      true if the column's data type is a numeric or time instance, false otherwise
    • isNumericOrTime

      public static boolean isNumericOrTime(SelectableDataSet sds, String column, PlotInfo plotInfo)
      Whether the column's data type isNumericOrTime(Class, PlotInfo).
      Parameters:
      sds - selectable dataset
      column - column
      plotInfo - source of the exception
      Returns:
      true if the column's data type is a numeric or time instance, false otherwise
    • assertIsTime

      public static void assertIsTime(Table t, String column, PlotInfo plotInfo)
      Requires the column's data type to be a time instance as defined in isTime(Class, PlotInfo)
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Throws:
      RuntimeException - if the column's data type isn't a time instance
    • assertIsTime

      public static void assertIsTime(TableDefinition t, String column, PlotInfo plotInfo)
      Requires the column's data type to be a time instance as defined in isTime(Class, PlotInfo)
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Throws:
      RuntimeException - if the column's data type isn't a time instance
    • assertIsTime

      public static void assertIsTime(Table t, String column, String message, PlotInfo plotInfo)
      Requires the column's data type to be a time instance as defined in isTime(Class, PlotInfo)
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      message - error message
      Throws:
      RuntimeException - if the column's data type isn't a time instance
    • assertIsTime

      public static void assertIsTime(TableDefinition t, String column, String message, PlotInfo plotInfo)
      Requires the column's data type to be a time instance as defined in isTime(Class, PlotInfo)
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      message - error message
      Throws:
      RuntimeException - if the column's data type isn't a time instance
    • assertIsPrimitiveNumeric

      public static void assertIsPrimitiveNumeric(Table t, String column, PlotInfo plotInfo)
      Requires the column's data type to be a numeric primitive as defined in NumericTypeUtils.isPrimitiveNumeric(Class)
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Throws:
      RuntimeException - if the column's data type isn't a numeric primitive
    • assertIsPrimitiveNumeric

      public static void assertIsPrimitiveNumeric(Table t, String column, String message, PlotInfo plotInfo)
      Requires the column's data type to be a numeric primitive as defined in NumericTypeUtils.isPrimitiveNumeric(Class)
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      message - error message
      Throws:
      RuntimeException - if the column's data type isn't a numeric primitive
    • assertIsBoxedNumeric

      public static void assertIsBoxedNumeric(Table t, String column, PlotInfo plotInfo)
      Requires the column's data type to be an instance of Number as defined in NumericTypeUtils.isBoxedNumeric(Class)
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Throws:
      RuntimeException - if the column's data type isn't an instance of Number
    • assertIsBoxedNumeric

      public static void assertIsBoxedNumeric(Table t, String column, String message, PlotInfo plotInfo)
      Requires the column's data type to be an instance of Number as defined in NumericTypeUtils.isBoxedNumeric(Class)
      Parameters:
      t - table
      column - column
      message - error message
      plotInfo - source of the exception
      Throws:
      RuntimeException - if the column's data type isn't an instance of Number
    • assertIsNumeric

      public static void assertIsNumeric(Table t, String column, PlotInfo plotInfo)
      Requires the column's data type to be a numeric instance as defined in NumericTypeUtils.isNumeric(Class)
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Throws:
      PlotRuntimeException - if the column's data type isn't a numeric instance
    • assertIsNumeric

      public static void assertIsNumeric(TableDefinition t, String column, PlotInfo plotInfo)
      Requires the column's data type to be a numeric instance as defined in NumericTypeUtils.isNumeric(Class)
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Throws:
      PlotRuntimeException - if the column's data type isn't a numeric instance
    • assertIsNumeric

      public static void assertIsNumeric(Table t, String column, String message, PlotInfo plotInfo)
      Requires the column's data type to be a numeric instance as defined in NumericTypeUtils.isNumeric(Class)
      Parameters:
      t - table
      column - column
      message - error message
      plotInfo - source of the exception
      Throws:
      PlotRuntimeException - if the column's data type isn't a numeric instance
    • assertIsNumeric

      public static void assertIsNumeric(TableDefinition t, String column, String message, PlotInfo plotInfo)
      Requires the column's data type to be a numeric instance as defined in NumericTypeUtils.isNumeric(Class)
      Parameters:
      t - table
      column - column
      message - error message
      plotInfo - source of the exception
      Throws:
      PlotRuntimeException - if the column's data type isn't a numeric instance
    • assertIsNumeric

      public static void assertIsNumeric(SelectableDataSet sds, String column, String message, PlotInfo plotInfo)
      Requires the column's data type to be a numeric instance as defined in NumericTypeUtils.isNumeric(Class)
      Parameters:
      sds - selectable dataset
      column - column
      message - error message
      plotInfo - source of the exception
      Throws:
      PlotRuntimeException - if the column's data type isn't a numeric instance
    • assertIsNumericOrTime

      public static void assertIsNumericOrTime(Table t, String column, PlotInfo plotInfo)
      Requires the column's data type to be a numeric or time instance as defined in isNumericOrTime(Class, PlotInfo)
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Throws:
      PlotRuntimeException - if the column's data type isn't a numeric or time instance
    • assertIsNumericOrTime

      public static void assertIsNumericOrTime(TableDefinition t, String column, PlotInfo plotInfo)
      Requires the column's data type to be a numeric or time instance as defined in isNumericOrTime(Class, PlotInfo)
      Parameters:
      t - table
      column - column
      plotInfo - source of the exception
      Throws:
      PlotRuntimeException - if the column's data type isn't a numeric or time instance
    • assertIsNumericOrTime

      public static void assertIsNumericOrTime(SelectableDataSet sds, String column, PlotInfo plotInfo)
      Requires the column's data type to be a numeric or time instance as defined in isNumericOrTime(Class, PlotInfo)
      Parameters:
      sds - selectable dataset
      column - column
      plotInfo - source of the exception
      Throws:
      PlotRuntimeException - if the column's data type isn't a numeric or time instance
    • assertIsNumericOrTime

      public static void assertIsNumericOrTime(Table t, String column, String message, PlotInfo plotInfo)
      Requires the column's data type to be a numeric or time instance as defined in isNumericOrTime(Class, PlotInfo)
      Parameters:
      t - table
      column - column
      message - error message
      plotInfo - source of the exception
      Throws:
      PlotRuntimeException - if the column's data type isn't a numeric or time instance
    • assertIsNumericOrTime

      public static void assertIsNumericOrTime(TableDefinition t, String column, String message, PlotInfo plotInfo)
      Requires the column's data type to be a numeric or time instance as defined in isNumericOrTime(Class, PlotInfo)
      Parameters:
      t - table
      column - column
      message - error message
      plotInfo - source of the exception
      Throws:
      PlotRuntimeException - if the column's data type isn't a numeric or time instance
    • assertIsNumericOrTime

      public static void assertIsNumericOrTime(SelectableDataSet sds, String column, String message, PlotInfo plotInfo)
      Requires the column's data type to be a numeric or time instance as defined in isNumericOrTime(Class, PlotInfo)
      Parameters:
      sds - selectable dataset
      column - column
      message - error message
      plotInfo - source of the exception
      Throws:
      PlotRuntimeException - if the column's data type isn't a numeric or time instance
    • assertColumnsInTable

      public static void assertColumnsInTable(Table t, PlotInfo plotInfo, String... cols)
      Requires all columns in cols be columns in the table.
      Parameters:
      t - table
      plotInfo - source of the exception
      cols - column names
      Throws:
      IllegalArgumentException - if the table does not contain all columns
    • assertColumnsInTable

      public static void assertColumnsInTable(TableDefinition t, PlotInfo plotInfo, String... cols)
      Requires all columns in cols be columns in the table.
      Parameters:
      t - table
      plotInfo - source of the exception
      cols - column names
      Throws:
      IllegalArgumentException - if the table does not contain all columns
    • assertColumnsInTable

      public static void assertColumnsInTable(SelectableDataSet sds, PlotInfo plotInfo, String... cols)
      Requires all columns in cols be columns in the selectable dataset.
      Parameters:
      sds - selectable dataset
      plotInfo - source of the exception
      cols - column names
      Throws:
      IllegalArgumentException - if the table does not contain all columns
    • assertColumnsInTable

      public static void assertColumnsInTable(TableHandle t, PlotInfo plotInfo, String... cols)
      Requires all columns in cols be columns in the table held by the handle.
      Parameters:
      t - table handle
      plotInfo - source of the exception
      cols - column names
      Throws:
      IllegalArgumentException - if the underlying table does not contain all columns
    • nanSafeEquals

      public static boolean nanSafeEquals(double x, double x1)