forked from plusone/plusone-commons
perf: 简单优化代码 (#63 @Gitea)
This commit is contained in:
@@ -154,7 +154,7 @@ public final class EnumTools {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static <E extends Enum<?>> Integer checkOrdinalNullable(Class<E> enumType, @Nullable Integer ordinal) {
|
public static <E extends Enum<?>> Integer checkOrdinalNullable(Class<E> enumType, @Nullable Integer ordinal) {
|
||||||
return checkOrdinalOrDefault(enumType, ordinal, (Integer) null);
|
return checkOrdinalOrDefault(enumType, ordinal, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -33,6 +33,7 @@ import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod;
|
|||||||
/**
|
/**
|
||||||
* 枚举类
|
* 枚举类
|
||||||
*
|
*
|
||||||
|
* <p>
|
||||||
* 参考 <a href="https://lostechies.com/jimmybogard/2008/08/12/enumeration-classes/">Enumeration classes</a>
|
* 参考 <a href="https://lostechies.com/jimmybogard/2008/08/12/enumeration-classes/">Enumeration classes</a>
|
||||||
*
|
*
|
||||||
* @author ZhouXY108 <luquanlion@outlook.com>
|
* @author ZhouXY108 <luquanlion@outlook.com>
|
||||||
|
@@ -36,7 +36,7 @@ public final class RandomTools {
|
|||||||
private static final SecureRandom DEFAULT_SECURE_RANDOM;
|
private static final SecureRandom DEFAULT_SECURE_RANDOM;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SecureRandom secureRandom = null;
|
SecureRandom secureRandom;
|
||||||
try {
|
try {
|
||||||
secureRandom = SecureRandom.getInstanceStrong(); // 获取高强度安全随机数生成器
|
secureRandom = SecureRandom.getInstanceStrong(); // 获取高强度安全随机数生成器
|
||||||
}
|
}
|
||||||
|
@@ -363,7 +363,7 @@ public final class RegexTools {
|
|||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Pattern compilePattern() {
|
private Pattern compilePattern() {
|
||||||
return Pattern.compile(regex, flags);
|
return Pattern.compile(regex, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -177,6 +177,9 @@ public class StringTools {
|
|||||||
*/
|
*/
|
||||||
@Beta
|
@Beta
|
||||||
public static boolean isURL(@Nullable final String cs) {
|
public static boolean isURL(@Nullable final String cs) {
|
||||||
|
if (cs == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
new URL(cs);
|
new URL(cs);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
|
Reference in New Issue
Block a user