some comments(#9741)

This commit is contained in:
levis9527 2022-03-15 12:04:00 +08:00 committed by GitHub
parent 71d821d2a3
commit bc546c84f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 5 deletions

View File

@ -515,8 +515,10 @@ public final class StringUtils {
}
/**
* @param s1
* @param s2
* if s1 is null and s2 is null, then return true
*
* @param s1 str1
* @param s2 str2
* @return equals
*/
public static boolean isEquals(String s1, String s2) {
@ -530,19 +532,31 @@ public final class StringUtils {
}
/**
* is integer string.
* is positive integer or zero string.
*
* @param str
* @return is integer
* @param str a string
* @return is positive integer or zero
*/
public static boolean isNumber(String str) {
return isNotEmpty(str) && NUM_PATTERN.matcher(str).matches();
}
/**
* parse str to Integer(if str is not number or n < 0, then return 0)
*
* @param str a number str
* @return positive integer or zero
*/
public static int parseInteger(String str) {
return isNumber(str) ? Integer.parseInt(str) : 0;
}
/**
* parse str to Long(if str is not number or n < 0, then return 0)
*
* @param str a number str
* @return positive long or zero
*/
public static long parseLong(String str) {
return isNumber(str) ? Long.parseLong(str) : 0;
}