feiyu02
2023-11-23 e2392116cd6f875cdc2f46bc04b04d5305f21b56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.flightfeather.monitor.utils
 
/**
 * 文本工具
 */
object StringUtil {
 
    /**
     * 驼峰命名法文本转下划线文本
     * @param t
     * @return
     */
    fun camelCaseToUnderline(t: String?): String? {
        t ?: return null
 
        val result = StringBuilder()
        t.forEach {
            if (it.isUpperCase()) {
                result.append('_')
                result.append(it.lowercaseChar())
            } else {
                result.append(it)
            }
        }
        return result.toString()
    }
}