cn.hutool.core.util.StrUtil.addPrefixIfNot()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(220)

本文整理了Java中cn.hutool.core.util.StrUtil.addPrefixIfNot()方法的一些代码示例,展示了StrUtil.addPrefixIfNot()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StrUtil.addPrefixIfNot()方法的具体详情如下:
包路径:cn.hutool.core.util.StrUtil
类名称:StrUtil
方法名:addPrefixIfNot

StrUtil.addPrefixIfNot介绍

[英]如果给定字符串不是以prefix开头的,在开头补充 prefix
[中]

代码示例

代码示例来源:origin: looly/hutool

@Override
  protected DataSource createDataSource(String jdbcUrl, String driver, String user, String pass, Setting poolSetting) {
    final DruidDataSource ds = new DruidDataSource();

    ds.setUrl(jdbcUrl);
    ds.setDriverClassName(driver);
    ds.setUsername(user);
    ds.setPassword(pass);

    // 规范化属性名
    Properties druidProps = new Properties();
    String keyStr;
    for (Entry<String, String> entry : poolSetting.entrySet()) {
      keyStr = StrUtil.addPrefixIfNot(entry.getKey(), "druid.");
      druidProps.put(keyStr, entry.getValue());
    }
    // 连接池信息
    ds.configFromPropety(druidProps);

    // 检查关联配置,在用户未设置某项配置时,
    if (null == ds.getValidationQuery()) {
      // 在validationQuery未设置的情况下,以下三项设置都将无效
      ds.setTestOnBorrow(false);
      ds.setTestOnReturn(false);
      ds.setTestWhileIdle(false);
    }

    return ds;
  }
}

代码示例来源:origin: looly/hutool

@Override
  protected DataSource createDataSource(String jdbcUrl, String driver, String user, String pass, Setting poolSetting) {
    final DruidDataSource ds = new DruidDataSource();

    ds.setUrl(jdbcUrl);
    ds.setDriverClassName(driver);
    ds.setUsername(user);
    ds.setPassword(pass);

    // 规范化属性名
    Properties druidProps = new Properties();
    String keyStr;
    for (Entry<String, String> entry : poolSetting.entrySet()) {
      keyStr = StrUtil.addPrefixIfNot(entry.getKey(), "druid.");
      druidProps.put(keyStr, entry.getValue());
    }
    // 连接池信息
    ds.configFromPropety(druidProps);

    // 检查关联配置,在用户未设置某项配置时,
    if (null == ds.getValidationQuery()) {
      // 在validationQuery未设置的情况下,以下三项设置都将无效
      ds.setTestOnBorrow(false);
      ds.setTestOnReturn(false);
      ds.setTestWhileIdle(false);
    }

    return ds;
  }
}

代码示例来源:origin: cn.hutool/hutool-all

@Override
  protected DataSource createDataSource(String jdbcUrl, String driver, String user, String pass, Setting poolSetting) {
    final DruidDataSource ds = new DruidDataSource();

    ds.setUrl(jdbcUrl);
    ds.setDriverClassName(driver);
    ds.setUsername(user);
    ds.setPassword(pass);

    // 规范化属性名
    Properties druidProps = new Properties();
    String keyStr;
    for (Entry<String, String> entry : poolSetting.entrySet()) {
      keyStr = StrUtil.addPrefixIfNot(entry.getKey(), "druid.");
      druidProps.put(keyStr, entry.getValue());
    }
    // 连接池信息
    ds.configFromPropety(druidProps);

    // 检查关联配置,在用户未设置某项配置时,
    if (null == ds.getValidationQuery()) {
      // 在validationQuery未设置的情况下,以下三项设置都将无效
      ds.setTestOnBorrow(false);
      ds.setTestOnReturn(false);
      ds.setTestWhileIdle(false);
    }

    return ds;
  }
}

代码示例来源:origin: cn.hutool/hutool-db

@Override
  protected DataSource createDataSource(String jdbcUrl, String driver, String user, String pass, Setting poolSetting) {
    final DruidDataSource ds = new DruidDataSource();

    ds.setUrl(jdbcUrl);
    ds.setDriverClassName(driver);
    ds.setUsername(user);
    ds.setPassword(pass);

    // 规范化属性名
    Properties druidProps = new Properties();
    String keyStr;
    for (Entry<String, String> entry : poolSetting.entrySet()) {
      keyStr = StrUtil.addPrefixIfNot(entry.getKey(), "druid.");
      druidProps.put(keyStr, entry.getValue());
    }
    // 连接池信息
    ds.configFromPropety(druidProps);

    // 检查关联配置,在用户未设置某项配置时,
    if (null == ds.getValidationQuery()) {
      // 在validationQuery未设置的情况下,以下三项设置都将无效
      ds.setTestOnBorrow(false);
      ds.setTestOnReturn(false);
      ds.setTestWhileIdle(false);
    }

    return ds;
  }
}

相关文章

微信公众号

最新文章

更多

StrUtil类方法