增加isNotEmpty方法

This commit is contained in:
redkale
2023-06-06 15:00:18 +08:00
parent d63d8ff836
commit 2e6ec01711

View File

@@ -473,6 +473,51 @@ public final class Utility {
});
}
/**
* 是否为数字字符串
*
* @param str 字符串
*
* @return 是否为数字字符串
*
*/
public static boolean isNumeric(String str) {
if (str == null || str.isEmpty()) {
return false;
}
int size = str.length();
for (int i = 0; i < size; i++) {
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}
/**
* 是否为空白
*
* @param str 字符串
*
* @return 是否为空白
*
*/
public static boolean isBlank(String str) {
return str == null || str.isEmpty() || str.isBlank();
}
/**
* 是否不为空白
*
* @param str 字符串
*
* @return 是否不为空白
*
*/
public static boolean isNotBlank(String str) {
return str != null && !str.isEmpty() && !str.isBlank();
}
/**
* 是否为空
*
@@ -497,6 +542,54 @@ public final class Utility {
return str != null && str.length() > 0;
}
/**
* 是否为空
*
* @param map Map
*
* @return 是否为空
*
*/
public static boolean isEmpty(Map map) {
return map == null || map.isEmpty();
}
/**
* 是否不为空
*
* @param map Map
*
* @return 是否不为空
*
*/
public static boolean isNotEmpty(Map map) {
return map != null && !map.isEmpty();
}
/**
* 是否为空
*
* @param collection Collection
*
* @return 是否为空
*
*/
public static boolean isEmpty(Collection collection) {
return collection == null || collection.isEmpty();
}
/**
* 是否不为空
*
* @param collection Collection
*
* @return 是否不为空
*
*/
public static boolean isNotEmpty(Collection collection) {
return collection != null && !collection.isEmpty();
}
/**
* 将字符串首字母大写
*