Package org.jdbi.v3.core.mapper.reflect
Class ReflectionMapperUtil
java.lang.Object
org.jdbi.v3.core.mapper.reflect.ReflectionMapperUtil
Utilities for reflective mappers. This is an internal helper class that should have been package private but as the mappers are spread across the reflect and
reflect.internal package, they are not. Any method in here may change at any time.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddPropertyNamePrefix(String prefix, String name) Add a prefix separated with '.' to a java bean property name.static booleananyColumnsStartWithPrefix(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.static OptionalIntfindColumnIndex(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 namesDeprecated.getColumnNames(ResultSet rs, UnaryOperator<String> caseStrategy) Returns the name of all the columns present in the specifiedResultSet.
-
Method Details
-
getColumnNames
Deprecated.UsegetColumnNames(ResultSet, UnaryOperator)andCaseStrategyto control name capitalizationReturns the name of all the columns present in the specifiedResultSet. All column names are lowercased using the system locale.
For new code, use thegetColumnNames(ResultSet, UnaryOperator)method, which allows configuring the case modification strategy.- Parameters:
rs- theResultSetto 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- SeeResultSet.getMetaData(),ResultSetMetaData.getColumnCount(), andResultSetMetaData.getColumnLabel(int)- See Also:
-
getColumnNames
public static List<String> getColumnNames(ResultSet rs, UnaryOperator<String> caseStrategy) throws SQLException Returns the name of all the columns present in the specifiedResultSet. The caseStrategy operator is applied to all column names to align upper/lower case etc.- Parameters:
rs- theResultSetto get the column names ofcaseStrategy- Apply a specific case strategy to the column names.- Returns:
- list of all the column names in
rs(will contain duplicates if multiple columns have the same name) - Throws:
SQLException- SeeResultSet.getMetaData(),ResultSetMetaData.getColumnCount(), andResultSetMetaData.getColumnLabel(int)- See Also:
-
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 forcolumnNames- list of column names to search incolumnNameMatchers-ColumnNameMatchers to mapparamNameto the column namesdebugName- name of the parameter to use for debugging purposes (ie: when throwing exceptions)- Returns:
OptionalIntwith 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 searchprefix- the prefix to search forcolumnNameMatchers- list of column name matchers- Returns:
- whether any of the column names begin with the prefix
- Since:
- 3.5.0
-
addPropertyNamePrefix
Add a prefix separated with '.' to a java bean property name. If the prefix is empty, return the name itself.- Parameters:
prefix- The prefix to add to the property name. The empty string is ignored.name- A property name.- Returns:
- The prefixed name.
-
getColumnNames(ResultSet, UnaryOperator)andCaseStrategyto control name capitalization