package com.de.util;
/**
*
* * @projectName mybatis-demo
* * @title HumpNamedTools
* * @package com.de.util
* * @description 驼峰命名与sql下划线字段之间的转换工具
* * @author IT_CREAT
* * @date 2019 2019/jpicker/14 10:36
* * @version V1.0.0
*
*/
public class HumpNamedUtils {
/**
* 将驼峰式命名的字符串转换为下划线小写方式。如果转换前的驼峰式命名的字符串为空,则返回空字符串。</br>
* 例如:helloWorld->hello_word
*
* @param name 转换前的驼峰式命名的字符串
* @return 转换后下划线小写方式命名的字符串
*/
public static String hump2LowerColumnName(String name) {
StringBuilder result = new StringBuilder();
if (name != null && name.length() > 0) {
// 将第一个字符处理成小写
result.append(name.substring(0, 1).toLowerCase());
// 循环处理字符
for (int i = 1; i < name.length(); i++) {
String s = name.substring(i, i + 1);
// 在大写字母前添加下划线
if (s.equals(s.toUpperCase())
驼峰命名转换工具代码(驼峰命名与下划线(sql命名))互转工具
最新推荐文章于 2025-05-07 23:42:43 发布