forked from plusone/plusone-commons
调整代码。
parent
ef20960480
commit
1b4958f5f6
|
@ -94,7 +94,7 @@ public abstract class Enumeration<T extends Enumeration<T>> implements Comparabl
|
|||
|
||||
@Nonnull
|
||||
public Collection<T> getValues() {
|
||||
return this.values.values();
|
||||
return Objects.requireNonNull(this.values.values());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,16 +26,15 @@ public class RegexUtil {
|
|||
|
||||
private static final Map<String, Pattern> PATTERN_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
@Nonnull
|
||||
public static Pattern getPattern(final String regex) {
|
||||
Objects.requireNonNull(regex);
|
||||
Pattern pattern;
|
||||
if (!PATTERN_CACHE.containsKey(regex)) {
|
||||
Pattern pattern = PATTERN_CACHE.get(regex);
|
||||
if (pattern == null) {
|
||||
pattern = Pattern.compile(regex);
|
||||
PATTERN_CACHE.put(regex, pattern);
|
||||
} else {
|
||||
pattern = PATTERN_CACHE.get(regex);
|
||||
}
|
||||
return pattern;
|
||||
return Objects.requireNonNull(pattern);
|
||||
}
|
||||
|
||||
public static boolean matches(@Nonnull CharSequence input, @Nonnull String regex) {
|
||||
|
@ -49,7 +48,7 @@ public class RegexUtil {
|
|||
public static boolean matchesOr(@Nonnull CharSequence input, String... regexes) {
|
||||
boolean isMatched;
|
||||
for (String regex : regexes) {
|
||||
isMatched = matches(input, regex);
|
||||
isMatched = matches(input, Objects.requireNonNull(regex));
|
||||
if (isMatched) {
|
||||
return true;
|
||||
}
|
||||
|
@ -60,7 +59,7 @@ public class RegexUtil {
|
|||
public static boolean matchesOr(@Nonnull CharSequence input, Pattern... patterns) {
|
||||
boolean isMatched;
|
||||
for (Pattern pattern : patterns) {
|
||||
isMatched = matches(input, pattern);
|
||||
isMatched = matches(input, Objects.requireNonNull(pattern));
|
||||
if (isMatched) {
|
||||
return true;
|
||||
}
|
||||
|
@ -71,7 +70,7 @@ public class RegexUtil {
|
|||
public static boolean matchesAnd(@Nonnull CharSequence input, String... regexes) {
|
||||
boolean isMatched;
|
||||
for (String regex : regexes) {
|
||||
isMatched = matches(input, regex);
|
||||
isMatched = matches(input, Objects.requireNonNull(regex));
|
||||
if (!isMatched) {
|
||||
return false;
|
||||
}
|
||||
|
@ -82,7 +81,7 @@ public class RegexUtil {
|
|||
public static boolean matchesAnd(@Nonnull CharSequence input, Pattern... patterns) {
|
||||
boolean isMatched;
|
||||
for (Pattern pattern : patterns) {
|
||||
isMatched = matches(input, pattern);
|
||||
isMatched = matches(input, Objects.requireNonNull(pattern));
|
||||
if (!isMatched) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package xyz.zhouxy.plusone.commons;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
|
Loading…
Reference in New Issue