From 22687605b230fea7faf9fdf3e5358c954d7af13e Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Tue, 16 Apr 2024 21:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xyz/zhouxy/plusone/commons/util/RegexTools.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/RegexTools.java b/src/main/java/xyz/zhouxy/plusone/commons/util/RegexTools.java index a13f2fb..7bde241 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/RegexTools.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/RegexTools.java @@ -291,7 +291,6 @@ public final class RegexTools { * @param cachePattern 是否缓存 {@link Pattern} 实例 * @return {@link Pattern} 实例 */ - @SuppressWarnings("null") @Nonnull private static Pattern getAndCachePatternInternal(@Nonnull final String pattern) { if (PATTERN_CACHE.size() < MAX_CACHE_SIZE) { @@ -310,7 +309,6 @@ public final class RegexTools { * @param pattern 正则表达式 * @return {@link Pattern} 实例 */ - @SuppressWarnings("null") @Nonnull private static Pattern getPatternInternal(@Nonnull final String pattern) { Pattern result = PATTERN_CACHE.get(pattern); @@ -326,7 +324,6 @@ public final class RegexTools { * @param patterns 正则表达式 * @return {@link Pattern} 实例数组 */ - @SuppressWarnings("null") @Nonnull private static Pattern[] getAndCachePatternsInternal(@Nonnull final String[] patterns) { return Arrays.stream(patterns) @@ -340,7 +337,6 @@ public final class RegexTools { * @param patterns 正则表达式 * @return {@link Pattern} 实例数组 */ - @SuppressWarnings("null") @Nonnull private static Pattern[] getPatternsInternal(@Nonnull final String[] patterns) { return Arrays.stream(patterns) @@ -359,26 +355,24 @@ public final class RegexTools { return input != null && pattern.matcher(input).matches(); } - @SuppressWarnings("null") private static boolean matchesOneInternal(@Nullable final CharSequence input, @Nonnull final Pattern[] patterns) { if (input == null) { return false; } for (Pattern pattern : patterns) { - if (matchesInternal(input, pattern)) { + if (matchesInternal(input, Objects.requireNonNull(pattern))) { return true; } } return false; } - @SuppressWarnings("null") - private static boolean matchesAllInternal(final CharSequence input, final Pattern[] patterns) { + private static boolean matchesAllInternal(@Nullable final CharSequence input, @Nonnull final Pattern[] patterns) { if (input == null) { return false; } for (Pattern pattern : patterns) { - if (!matchesInternal(input, pattern)) { + if (!matchesInternal(input, Objects.requireNonNull(pattern))) { return false; } }