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

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

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

StrUtil.toUnderlineCase介绍

[英]将驼峰式命名的字符串转换为下划线方式。如果转换前的驼峰式命名的字符串为空,则返回空字符串。
例如:

HelloWorld=》hello_world 
Hello_World=》hello_world 
HelloWorld_test=》hello_world_test

[中]将驼峰式命名的字符串转换为下划线方式。如果转换前的驼峰式命名的字符串为空,则返回空字符串。
例如:

HelloWorld=》hello_world 
Hello_World=》hello_world 
HelloWorld_test=》hello_world_test

代码示例

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

@Override
  public String edit(String key) {
    return isToUnderlineCase ? StrUtil.toUnderlineCase(key) : key;
  }
});

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

@Override
  public String edit(String key) {
    return isToUnderlineCase ? StrUtil.toUnderlineCase(key) : key;
  }
});

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

@Override
public boolean containsKey(String key) {
  if(map.containsKey(key)) {
    return true;
  }else if(map.containsKey(StrUtil.toUnderlineCase(key))) {
    //检查下划线模式
    return true;
  }
  return false;
}

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

@Override
public boolean containsKey(String key) {
  if(map.containsKey(key)) {
    return true;
  }else if(map.containsKey(StrUtil.toUnderlineCase(key))) {
    //检查下划线模式
    return true;
  }
  return false;
}

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

@Override
public Object value(String key, Type valueType) {
  Object value = map.get(key);
  if(null == value) {
    //检查下划线模式
    value = map.get(StrUtil.toUnderlineCase(key));
  }
  return Convert.convert(valueType, value);
}

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

@Override
public Object value(String key, Type valueType) {
  Object value = map.get(key);
  if(null == value) {
    //检查下划线模式
    value = map.get(StrUtil.toUnderlineCase(key));
  }
  return Convert.convert(valueType, value);
}

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

/**
 * 将值对象转换为Entity<br>
 * 类名会被当作表名,小写第一个字母
 *
 * @param <T> Bean对象类型
 * @param bean Bean对象
 * @param isToUnderlineCase 是否转换为下划线模式
 * @param ignoreNullValue 是否忽略值为空的字段
 * @return 自己
 */
@Override
public <T> Entity parseBean(T bean, boolean isToUnderlineCase, boolean ignoreNullValue) {
  if (StrUtil.isBlank(this.tableName)) {
    String simpleName = bean.getClass().getSimpleName();
    this.setTableName(isToUnderlineCase ? StrUtil.toUnderlineCase(simpleName) : StrUtil.lowerFirst(simpleName));
  }
  return (Entity) super.parseBean(bean, isToUnderlineCase, ignoreNullValue);
}

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

/**
 * 将值对象转换为Entity<br>
 * 类名会被当作表名,小写第一个字母
 *
 * @param <T> Bean对象类型
 * @param bean Bean对象
 * @param isToUnderlineCase 是否转换为下划线模式
 * @param ignoreNullValue 是否忽略值为空的字段
 * @return 自己
 */
@Override
public <T> Entity parseBean(T bean, boolean isToUnderlineCase, boolean ignoreNullValue) {
  if (StrUtil.isBlank(this.tableName)) {
    String simpleName = bean.getClass().getSimpleName();
    this.setTableName(isToUnderlineCase ? StrUtil.toUnderlineCase(simpleName) : StrUtil.lowerFirst(simpleName));
  }
  return (Entity) super.parseBean(bean, isToUnderlineCase, ignoreNullValue);
}

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

@Override
  public String edit(String key) {
    return isToUnderlineCase ? StrUtil.toUnderlineCase(key) : key;
  }
});

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

@Override
public boolean containsKey(String key) {
  if(map.containsKey(key)) {
    return true;
  }else if(map.containsKey(StrUtil.toUnderlineCase(key))) {
    //检查下划线模式
    return true;
  }
  return false;
}

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

@Override
public Object value(String key, Type valueType) {
  Object value = map.get(key);
  if(null == value) {
    //检查下划线模式
    value = map.get(StrUtil.toUnderlineCase(key));
  }
  return Convert.convert(valueType, value);
}

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

/**
 * 将值对象转换为Entity<br>
 * 类名会被当作表名,小写第一个字母
 *
 * @param <T> Bean对象类型
 * @param bean Bean对象
 * @param isToUnderlineCase 是否转换为下划线模式
 * @param ignoreNullValue 是否忽略值为空的字段
 * @return 自己
 */
@Override
public <T> Entity parseBean(T bean, boolean isToUnderlineCase, boolean ignoreNullValue) {
  if (StrUtil.isBlank(this.tableName)) {
    String simpleName = bean.getClass().getSimpleName();
    this.setTableName(isToUnderlineCase ? StrUtil.toUnderlineCase(simpleName) : StrUtil.lowerFirst(simpleName));
  }
  return (Entity) super.parseBean(bean, isToUnderlineCase, ignoreNullValue);
}

代码示例来源:origin: cn.stylefeng.roses/kernel-scanner

@Override
public synchronized void registerDefinition(List<ResourceDefinition> apiResource) {
  if (apiResource != null || apiResource.size() > 0) {
    for (ResourceDefinition resourceDefinition : apiResource) {
      ResourceDefinition alreadyFlag = resourceDefinitions.get(resourceDefinition.getCode());
      if (alreadyFlag != null) {
        throw new RuntimeException("资源扫描过程中存在重复资源!\n已存在资源:" + alreadyFlag + "\n新资源为: " + resourceDefinition);
      }
      resourceDefinitions.put(resourceDefinition.getCode(), resourceDefinition);
      urlDefineResources.put(resourceDefinition.getUrl(), resourceDefinition);
      //store modularResourceDefinitions
      Map<String, ResourceDefinition> modularResources = modularResourceDefinitions.get(StrUtil.toUnderlineCase(resourceDefinition.getModularCode()));
      if (modularResources == null) {
        modularResources = new HashMap<>();
        modularResources.put(resourceDefinition.getCode(), resourceDefinition);
        modularResourceDefinitions.put(StrUtil.toUnderlineCase(resourceDefinition.getModularCode()), modularResources);
      } else {
        modularResources.put(resourceDefinition.getCode(), resourceDefinition);
      }
      //添加资源code-中文名称字典
      this.bindResourceName(resourceDefinition.getCode(), resourceDefinition.getName());
    }
  }
}

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

/**
 * 将值对象转换为Entity<br>
 * 类名会被当作表名,小写第一个字母
 *
 * @param <T> Bean对象类型
 * @param bean Bean对象
 * @param isToUnderlineCase 是否转换为下划线模式
 * @param ignoreNullValue 是否忽略值为空的字段
 * @return 自己
 */
@Override
public <T> Entity parseBean(T bean, boolean isToUnderlineCase, boolean ignoreNullValue) {
  if (StrUtil.isBlank(this.tableName)) {
    String simpleName = bean.getClass().getSimpleName();
    this.setTableName(isToUnderlineCase ? StrUtil.toUnderlineCase(simpleName) : StrUtil.lowerFirst(simpleName));
  }
  return (Entity) super.parseBean(bean, isToUnderlineCase, ignoreNullValue);
}

代码示例来源:origin: cn.stylefeng.roses/kernel-scanner

this.apiResourceFactory.bindResourceName(StrUtil.toUnderlineCase(code), classApiAnnotation.name());
} else {
  this.apiResourceFactory.bindResourceName(StrUtil.toUnderlineCase(classApiAnnotation.code()), classApiAnnotation.name());

代码示例来源:origin: cn.stylefeng.roses/kernel-scanner

resourceDefinition.setCode(resourceDefinition.getAppCode() + scannerProperties.getLinkSymbol() + StrUtil.toUnderlineCase(modular) + scannerProperties.getLinkSymbol() + StrUtil.toUnderlineCase(method.getName()));
} else {
  resourceDefinition.setCode(resourceDefinition.getAppCode() + scannerProperties.getLinkSymbol() + StrUtil.toUnderlineCase(modular) + scannerProperties.getLinkSymbol() + StrUtil.toUnderlineCase(code));

相关文章

微信公众号

最新文章

更多

StrUtil类方法