add null check

This commit is contained in:
Looly
2025-09-19 20:33:14 +08:00
parent 365c56b2f8
commit abda118f72

View File

@@ -126,12 +126,12 @@ public class PinyinUtil {
/**
* 将输入字符串转为拼音首字母,其它字符原样返回
*
* @param str 任意字符,汉字返回拼音,非汉字原样返回
* @param str 任意字符,汉字返回拼音,非汉字原样返回{@code null}返回{@code null}
* @param separator 分隔符
* @return 汉字返回拼音,非汉字原样返回
* @return 汉字返回拼音,非汉字原样返回str为{@code null}返回{@code null}
*/
public static String getFirstLetter(final String str, final String separator) {
return getEngine().getFirstLetter(str, separator);
return (str == null) ? null :getEngine().getFirstLetter(str, separator);
}
/**