当前位置:网站首页>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);
}
其他方法


边栏推荐
- 建模和影视后期有什么关联?
- [micro service sentinel] sentinel integrates openfeign
- 认识线程
- Zhongang Mining: it has inherent advantages to develop the characteristic chemical industry dominated by fluorine chemical industry
- 【微服务|Sentinel】@SentinelResource详解
- [applet] realize the left and right [sliding] list through the scroll view component
- Is it safe to choose mobile phone for stock trading account opening in Shanghai?
- [swoole Series 1] what will you learn in the world of swoole?
- plain framework的实际应用和扩展
- dat. GUI
猜你喜欢

MT manager test skiing Adventure

Airserver latest win64 bit personal screen projection software

硅谷产品实战学习感触

CADD course learning (3) -- target drug interaction
![[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing](/img/08/9ecfd53a04e147022dde3449aec132.png)
[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing

SWT / anr problem - SWT causes kernel fuse deadlock

神经网络物联网的未来趋势与发展

How to display real-time 2D map after rviz is opened

flutter Unable to load asset: assets/images/888.png

会声会影2022智能、快速、简单的视频剪辑软件
随机推荐
通过Go语言创建CA与签发证书
mysql ---- Oracle中的rownum转换成MySQL
Daily three questions 6.29
Jielizhi Bluetooth headset quality control and production skills [chapter]
Jerry's burning of upper version materials requires [chapter]
Understanding threads
Openresty load balancing
What category does the Internet of things application technology major belong to
Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification
什么是马赛克?
想请教股票开户要认识谁?在线开户是安全么?
有没有一段代码,让你为人类的智慧所折服
Matplotlib common charts
ShanDong Multi-University Training #3
dat.GUI
Behind sharing e-commerce: the spirit of CO creation, symbiosis, sharing, CO prosperity and win-win
from pip._internal.cli.main import main ModuleNotFoundError: No module named ‘pip‘
How to display real-time 2D map after rviz is opened
2022 R1 fast opening pressure vessel operation test questions and answers
Huisheng Huiying 2022 intelligent, fast and simple video editing software