Tabnine Logo
ColumnNameMatcher
Code IndexAdd Tabnine to your IDE (free)

How to use
ColumnNameMatcher
in
org.jdbi.v3.core.mapper.reflect

Best Java code snippets using org.jdbi.v3.core.mapper.reflect.ColumnNameMatcher (Showing top 5 results out of 315)

origin: jdbi/jdbi

/**
 * Attempts to find the index of a specified column's mapped parameter in a list of column names
 *
 * @param paramName          the name of the parameter to search for
 * @param columnNames        list of column names to search in
 * @param columnNameMatchers {@link ColumnNameMatcher}s to map {@code paramName} to the column names
 * @param debugName          name of the parameter to use for debugging purposes (ie: when throwing exceptions)
 * @return {@link OptionalInt} with the found index, {@link OptionalInt#empty()} otherwise.
 */
public static OptionalInt findColumnIndex(String paramName, List<String> columnNames, List<ColumnNameMatcher> columnNameMatchers, Supplier<String> debugName) {
  OptionalInt result = OptionalInt.empty();
  for (int i = 0; i < columnNames.size(); i++) {
    String columnName = columnNames.get(i);
    for (ColumnNameMatcher strategy : columnNameMatchers) {
      if (strategy.columnNameMatches(columnName, paramName)) {
        if (result.isPresent()) {
          throw new IllegalArgumentException(String.format(
            "'%s' (%s) matches multiple columns: '%s' (%d) and '%s' (%d)",
            debugName.get(), paramName,
            columnNames.get(result.getAsInt()), result.getAsInt(),
            columnNames.get(i), i));
        }
        result = OptionalInt.of(i);
        break;
      }
    }
  }
  return result;
}
origin: jdbi/jdbi

  /**
   * Returns whether any of the given column names begin with the given prefix, according to the list of column name
   * matchers.
   *
   * @param columnNames the column names to search
   * @param prefix the prefix to search for
   * @param columnNameMatchers list of column name matchers
   * @return whether any of the column names begin with the prefix
   * @since 3.5.0
   */
  public static boolean anyColumnsStartWithPrefix(Collection<String> columnNames, String prefix, List<ColumnNameMatcher> columnNameMatchers) {
    return columnNames.stream().anyMatch(
      columnName -> columnNameMatchers.stream().anyMatch(
        matcher -> matcher.columnNameStartsWith(columnName, prefix)));
  }
}
origin: org.jdbi/jdbi3

private Optional<PropertyDescriptor> descriptorForColumn(String columnName,
                             List<ColumnNameMatcher> columnNameMatchers)
{
  for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
    String paramName = paramName(descriptor);
    for (ColumnNameMatcher strategy : columnNameMatchers) {
      if (strategy.columnNameMatches(columnName, paramName)) {
        return Optional.of(descriptor);
      }
    }
  }
  return Optional.empty();
}
origin: org.jdbi/jdbi3

private Optional<Field> fieldByColumn(String columnName, List<ColumnNameMatcher> columnNameMatchers)
{
  Class<?> aClass = type;
  while(aClass != null) {
    for (Field field : aClass.getDeclaredFields()) {
      String paramName = paramName(field);
      for (ColumnNameMatcher strategy : columnNameMatchers) {
        if (strategy.columnNameMatches(columnName, paramName)) {
          return Optional.of(field);
        }
      }
    }
    aClass = aClass.getSuperclass();
  }
  return Optional.empty();
}
origin: org.jdbi/jdbi3

if (strategy.columnNameMatches(columnName, parameterName)) {
  if (result >= 0) {
    throw new IllegalArgumentException(String.format(
org.jdbi.v3.core.mapper.reflectColumnNameMatcher

Javadoc

Strategy for matching SQL column names to Java property, field, or parameter names.

Most used methods

  • columnNameMatches
    Returns whether the column name fits the given Java identifier name.
  • columnNameStartsWith
    Return whether the column name starts with the given prefix, according to the matching strategy of t

Popular in Java

  • Parsing JSON documents to java classes using gson
  • addToBackStack (FragmentTransaction)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • scheduleAtFixedRate (Timer)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now