Class ReflectionMapperUtil

java.lang.Object
org.jdbi.v3.core.mapper.reflect.ReflectionMapperUtil

public class ReflectionMapperUtil extends Object
Utilities for reflective mappers.
  • Method Details

    • getColumnNames

      public static List<String> getColumnNames(ResultSet rs) throws SQLException
      Returns the name of all the columns present in the specified ResultSet
      Parameters:
      rs - the ResultSet to get the column names of
      Returns:
      list of all the column names in rs (will contain duplicates if multiple columns have the same name)
      Throws:
      SQLException - See ResultSet.getMetaData(), ResultSetMetaData.getColumnCount(), and ResultSetMetaData.getColumnLabel(int)
    • findColumnIndex

      public static OptionalInt findColumnIndex(String paramName, List<String> columnNames, List<ColumnNameMatcher> columnNameMatchers, Supplier<String> debugName)
      Attempts to find the index of a specified column's mapped parameter in a list of column names
      Parameters:
      paramName - the name of the parameter to search for
      columnNames - list of column names to search in
      columnNameMatchers - ColumnNameMatchers to map paramName to the column names
      debugName - name of the parameter to use for debugging purposes (ie: when throwing exceptions)
      Returns:
      OptionalInt with the found index, OptionalInt.empty() otherwise.
    • anyColumnsStartWithPrefix

      public static boolean anyColumnsStartWithPrefix(Collection<String> columnNames, String prefix, List<ColumnNameMatcher> columnNameMatchers)
      Returns whether any of the given column names begin with the given prefix, according to the list of column name matchers.
      Parameters:
      columnNames - the column names to search
      prefix - the prefix to search for
      columnNameMatchers - list of column name matchers
      Returns:
      whether any of the column names begin with the prefix
      Since:
      3.5.0