当前位置:网站首页>notBlank 和 notEmpty
notBlank 和 notEmpty
2022-07-01 23:04:00 【叮当的猫猫】
lang 和 lang3 包中的 StringUtils 的区别
public interface CharSequence {
}
public final class String implements java.io.Serializable, Comparable<String>, CharSequence {
}
isEmpty系列
isEmpty
StringUtils.isEmpty(null) = true
StringUtils.isEmpty("") = true
StringUtils.isEmpty(" ") = false //注意这里
StringUtils.isEmpty(“bob”) = false
StringUtils.isEmpty(" bob ") = false
public static boolean isEmpty(final CharSequence cs) {
return cs == null || cs.length() == 0;
}
isNotEmpty()
public static boolean isNotEmpty(final CharSequence cs) {
return !isEmpty(cs);
}
StringUtils.isAnyEmpty()
StringUtils.isAnyEmpty(null) = true
StringUtils.isAnyEmpty(null, “foo”) = true
StringUtils.isAnyEmpty("", “bar”) = true
StringUtils.isAnyEmpty(“bob”, “”) = true
StringUtils.isAnyEmpty(" bob ", null) = true
StringUtils.isAnyEmpty(" ", “bar”) = false
StringUtils.isAnyEmpty(“foo”, “bar”) = false
public static boolean isAnyEmpty(final CharSequence... css) {
if (ArrayUtils.isEmpty(css)) {
return true;
}
for (final CharSequence cs : css){
if (isEmpty(cs)) {
return true;
}
}
return false;
}
isNoneEmpty()
public static boolean isNoneEmpty(final CharSequence... css) {
}
isBank系列
isBlank() 是否为真空值(空格或者空值)
StringUtils.isBlank(null) = true
StringUtils.isBlank("") = true
StringUtils.isBlank(" ") = true //注意这里
StringUtils.isBlank(“bob”) = false
StringUtils.isBlank(" bob ") = false
public static boolean isBlank(final CharSequence cs) {
int strLen;
if (cs == null || (strLen = cs.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if (Character.isWhitespace(cs.charAt(i)) == false) {
return false;
}
}
return true;
}
isNotBlank()
public static boolean isNotBlank(final CharSequence cs) {
return !isBlank(cs);
}
isAnyBlank()
StringUtils.isAnyBlank(null) = true
StringUtils.isAnyBlank(null, “foo”) = true
StringUtils.isAnyBlank(null, null) = true
StringUtils.isAnyBlank("", “bar”) = true
StringUtils.isAnyBlank(“bob”, “”) = true
StringUtils.isAnyBlank(" bob ", null) = true
StringUtils.isAnyBlank(" ", “bar”) = true
StringUtils.isAnyBlank(“foo”, “bar”) = false
public static boolean isAnyBlank(final CharSequence... css) {
if (ArrayUtils.isEmpty(css)) {
return true;
}
for (final CharSequence cs : css){
if (isBlank(cs)) {
return true;
}
}
return false;
}
isNoneBlank()
StringUtils.isNoneBlank(null) = false
StringUtils.isNoneBlank(null, “foo”) = false
StringUtils.isNoneBlank(null, null) = false
StringUtils.isNoneBlank("", “bar”) = false
StringUtils.isNoneBlank(“bob”, “”) = false
StringUtils.isNoneBlank(" bob ", null) = false
StringUtils.isNoneBlank(" ", “bar”) = false
StringUtils.isNoneBlank(“foo”, “bar”) = true
public static boolean isNoneBlank(final CharSequence... css) {
return !isAnyBlank(css);
}
其他方法
边栏推荐
- 2022 crane driver (limited to bridge crane) examination questions and simulation examination
- [LeetCode] 最后一个单词的长度【58】
- Development trend and future direction of neural network Internet of things
- 共享电商的背后: 共创、共生、共享、共富,共赢的共富精神
- What category does the Internet of things application technology major belong to
- 通过Go语言创建CA与签发证书
- from pip._internal.cli.main import main ModuleNotFoundError: No module named ‘pip‘
- STM32F030F4驱动TIM1637数码管芯片
- Redis data types and application scenarios
- from pip._ internal. cli. main import main ModuleNotFoundError: No module named ‘pip‘
猜你喜欢
Glass mosaic
MT manager test skiing Adventure
云信小课堂 | IM及音视频中常见的认知误区
How to display real-time 2D map after rviz is opened
Jielizhi, production line assembly link [chapter]
2022 examination questions and online simulation examination for safety management personnel of hazardous chemical business units
2022 R1 fast opening pressure vessel operation test questions and answers
Current situation and future development trend of Internet of things
物联网开发零基础教程
纪念成为首个DAYUs200三方demo贡献者
随机推荐
[applet] realize the left and right [sliding] list through the scroll view component
上海炒股开户选择手机办理安全吗?
2022 R1 fast opening pressure vessel operation test questions and answers
Daily three questions 6.30
MT manager test skiing Adventure
What is the mosaic tailgate?
ShanDong Multi-University Training #3
有没有一段代码,让你为人类的智慧所折服
Why is PHP called hypertext preprocessor
Oracle中已定义者身份执行函数AUTHID DEFINER与Postgresql行为的异同
Paramètres communs de matplotlib
[micro service sentinel] sentinelresourceaspect details
Current situation and future development trend of Internet of things
Matplotlib常用設置
ShanDong Multi-University Training #3
De PIP. Interne. CLI. Main Import main modulenotfounderror: No module named 'PIP'
Microservice stability management
【微服务|Sentinel】SentinelResourceAspect详解
RPA: Bank digitalization, business process automation "a small step", and loan review efficiency "a big step"
从第三次技术革命看企业应用三大开发趋势