插件开发工具库,推荐依赖该工具库。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.8 KiB

package com.fanruan.api.util;
import com.fr.stable.StringUtils;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-16
* 字符串工具类
*/
public class StringKit {
public static final String EMPTY = "";
public static final String BLANK = " ";
/**
* <p>检查一个字符串是否是空字符串</p>
* <p/>
* <pre>
* StringKit.isEmpty(null) = true
* StringKit.isEmpty("") = true
* StringKit.isEmpty(" ") = false
* StringKit.isEmpty("bob") = false
* StringKit.isEmpty(" bob ") = false
* </pre>
* <p/>
*
* @param text 被检查的字符串可能为null
* @return 如果字符串为空或者是null则返回true否则返回false
*/
public static boolean isEmpty(String text) {
return StringUtils.isEmpty(text);
}
/**
* <p>检查一个字符串是否不为空字符串</p>
* <p/>
* <pre>
* StringKit.isNotEmpty(null) = false
* StringKit.isNotEmpty("") = false
* StringKit.isNotEmpty(" ") = true
* StringKit.isNotEmpty("bob") = true
* StringKit.isNotEmpty(" bob ") = true
* </pre>
*
* @param text 被检查的字符串可能是null
* @return 如果字符串不为空且不是null则返回true否则返回false
*/
public static boolean isNotEmpty(String text) {
return StringUtils.isNotEmpty(text);
}
/**
* <p>检查一个字符串是否为空白字符串</p>
* <p/>
* <pre>
* StringKit.isBlank(null) = true
* StringKit.isBlank("") = true
* StringKit.isBlank(" ") = true
* StringKit.isBlank("bob") = false
* StringKit.isBlank(" bob ") = false
* </pre>
*
* @param text 被检查的字符串
* @return 如果字符串为空空格符或者null那么返回true否则返回false
*/
public static boolean isBlank(String text) {
return StringUtils.isBlank(text);
}
/**
* <p>检查一个字符串是否不是空白字符串</p>
* <p/>
* <pre>
* StringKit.isNotBlank(null) = false
* StringKit.isNotBlank("") = false
* StringKit.isNotBlank(" ") = false
* StringKit.isNotBlank("bob") = true
* StringKit.isNotBlank(" bob ") = true
* </pre>
*
* @param text 被检查的字符串
* @return 如果字符串不是空字符串空格符以及null那么就返回true否则返回false
*/
public static boolean isNotBlank(String text) {
return StringUtils.isNotBlank(text);
}
/**
* 对字符串做trim操作
*
* @param string 源字符串
* @return 返回操作后的字符串
*/
public static String trim(String string) {
return StringUtils.trim(string);
}
}