package com.sundot.airport.common.utils;

/**
 * 字段名称工具类
 */
public class NameUtils {

    /**
     * 驼峰转下划线
     * @param name
     * @return
     */
    public static String camelToUnderscore(String name) {
        if (name == null || name.isEmpty()) {
            return name;
        }
        StringBuilder sb = new StringBuilder();
        for (char c : name.toCharArray()) {
            if (Character.isUpperCase(c)) {
                sb.append("_").append(Character.toLowerCase(c));
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }

}
