This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
The following commit(s) were added to refs/heads/master by this push:
new abb3ebf Reuse StringUtils. Use ternary return.
abb3ebf is described below
commit abb3ebfc449383ed7298a25c7a717e7718c002fa
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jul 4 09:37:03 2020 -0400
Reuse StringUtils. Use ternary return.
---
.../apache/commons/text/matcher/StringMatcherFactory.java | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git
a/src/main/java/org/apache/commons/text/matcher/StringMatcherFactory.java
b/src/main/java/org/apache/commons/text/matcher/StringMatcherFactory.java
index 30e4c77..8e66281 100644
--- a/src/main/java/org/apache/commons/text/matcher/StringMatcherFactory.java
+++ b/src/main/java/org/apache/commons/text/matcher/StringMatcherFactory.java
@@ -18,6 +18,7 @@
package org.apache.commons.text.matcher;
import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
/**
* Provides access to matchers defined in this package.
@@ -123,7 +124,7 @@ public final class StringMatcherFactory {
* @return a new Matcher for the given characters
*/
public StringMatcher charSetMatcher(final String chars) {
- if (chars == null || chars.length() == 0) {
+ if (StringUtils.isEmpty(chars)) {
return NONE_MATCHER;
}
if (chars.length() == 1) {
@@ -204,10 +205,7 @@ public final class StringMatcherFactory {
* @since 1.9
*/
public StringMatcher stringMatcher(final char... chars) {
- if (ArrayUtils.isEmpty(chars)) {
- return NONE_MATCHER;
- }
- return new AbstractStringMatcher.StringMatcher(chars);
+ return ArrayUtils.isEmpty(chars) ? NONE_MATCHER : new
AbstractStringMatcher.StringMatcher(chars);
}
/**
@@ -218,10 +216,7 @@ public final class StringMatcherFactory {
* @return a new Matcher for the given String
*/
public StringMatcher stringMatcher(final String str) {
- if (str == null || str.length() == 0) {
- return NONE_MATCHER;
- }
- return new AbstractStringMatcher.StringMatcher(str);
+ return StringUtils.isEmpty(str) ? NONE_MATCHER : new
AbstractStringMatcher.StringMatcher(str);
}
/**