apache.common.lang3中的StringUtils
/*判断字符数组中存在至少一个数据为空的情况,即为null或者长度为0*/
/*Checks if any one of the CharSequences are empty ("") or null*/
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;
}
/*说明1:参数CharSequence... css是Java新特性,可变程度数据*/
/*说明2:被final修饰的形式参数CharSequence... css的实际参数是不可改变的*/
ArrayUtils.isEmpty
public static boolean isEmpty(final Object[] array) {
return array == null || array.length == 0;
}
//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
/*判断字符串数组中任何数据都不为""或者null.都不为空返回true,否则返回false*/
/*Checks if none of the CharSequences are empty ("") or null*/
public static boolean isNoneEmpty(final CharSequence... css) {
return !isAnyEmpty(css);
}
/*判断字符数组中存在至少一个数据为空的情况,即为null或者长度为0*/
/*Checks if any one of the CharSequences are empty ("") or null*/
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;
}
/*说明1:参数CharSequence... css是Java新特性,可变程度数据*/
/*说明2:被final修饰的形式参数CharSequence... css的实际参数是不可改变的*/
ArrayUtils.isEmpty
public static boolean isEmpty(final Object[] array) {
return array == null || array.length == 0;
}
//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
/*判断字符串数组中任何数据都不为""或者null.都不为空返回true,否则返回false*/
/*Checks if none of the CharSequences are empty ("") or null*/
public static boolean isNoneEmpty(final CharSequence... css) {
return !isAnyEmpty(css);
}