Skip to content

Commit 19ea1a8

Browse files
[MNG-6829] Replace StringUtils#isEmpty(String) and #isNotEmpty(String) (#205)
Continuation of https://issues.apache.org/jira/browse/MNG-6829 Review requested of @elharo Use this link to re-run the recipe: https://public.moderne.io/recipes/org.openrewrite.java.migrate.apache.commons.lang.IsNotEmptyToJdk?organizationId=QXBhY2hlIE1hdmVu Co-authored-by: Moderne <team@moderne.io>
1 parent 6f72300 commit 19ea1a8

File tree

6 files changed

+93
-96
lines changed

6 files changed

+93
-96
lines changed

src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,9 @@ protected String getArtifactType(MavenProject p) {
478478
* @return the list of source paths for the given project.
479479
*/
480480
protected List<String> getProjectSourceRoots(MavenProject p) {
481-
return (p.getCompileSourceRoots() == null
481+
return p.getCompileSourceRoots() == null
482482
? Collections.<String>emptyList()
483-
: new LinkedList<>(p.getCompileSourceRoots()));
483+
: new LinkedList<>(p.getCompileSourceRoots());
484484
}
485485

486486
/**
@@ -490,9 +490,9 @@ protected List<String> getProjectSourceRoots(MavenProject p) {
490490
* if any
491491
*/
492492
protected List<String> getCompileClasspathElements(MavenProject p) throws DependencyResolutionRequiredException {
493-
return (p.getCompileClasspathElements() == null
493+
return p.getCompileClasspathElements() == null
494494
? Collections.<String>emptyList()
495-
: new LinkedList<>(p.getCompileClasspathElements()));
495+
: new LinkedList<>(p.getCompileClasspathElements());
496496
}
497497

498498
/**
@@ -512,7 +512,7 @@ protected static String getJavaMethodAsString(JavaExecutable javaExecutable) {
512512
*/
513513
private void init() {
514514
// defaultAuthor
515-
if (StringUtils.isEmpty(defaultAuthor)) {
515+
if (defaultAuthor == null || defaultAuthor.isEmpty()) {
516516
defaultAuthor = System.getProperty("user.name");
517517
}
518518

@@ -550,7 +550,7 @@ private void init() {
550550
fixTagsSplitted = StringUtils.split(fixTags, ",");
551551

552552
// encoding
553-
if (StringUtils.isEmpty(encoding)) {
553+
if (encoding == null || encoding.isEmpty()) {
554554
if (getLog().isWarnEnabled()) {
555555
getLog().warn("File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
556556
+ ", i.e. build is platform dependent!");
@@ -1027,7 +1027,7 @@ private void takeCareSingleComment(
10271027

10281028
String javadocComment = trimRight(extractOriginalJavadoc(originalContent, entity));
10291029
String extraComment = javadocComment.substring(javadocComment.indexOf(END_JAVADOC) + END_JAVADOC.length());
1030-
if (StringUtils.isNotEmpty(extraComment)) {
1030+
if (extraComment != null && !extraComment.isEmpty()) {
10311031
if (extraComment.contains(EOL)) {
10321032
stringWriter.write(extraComment.substring(extraComment.indexOf(EOL) + EOL.length()));
10331033
} else {
@@ -1082,7 +1082,7 @@ private boolean isInLevel(List<String> modifiers) {
10821082
}
10831083

10841084
if (LEVEL_PROTECTED.equalsIgnoreCase(level.trim())) {
1085-
return (modifiers.contains(LEVEL_PUBLIC) || modifiers.contains(LEVEL_PROTECTED));
1085+
return modifiers.contains(LEVEL_PUBLIC) || modifiers.contains(LEVEL_PROTECTED);
10861086
}
10871087

10881088
if (LEVEL_PACKAGE.equalsIgnoreCase(level.trim())) {
@@ -1887,7 +1887,7 @@ private void writeReturnTag(
18871887
return;
18881888
}
18891889

1890-
if (StringUtils.isNotEmpty(originalJavadocTag)
1890+
if ((originalJavadocTag != null && !originalJavadocTag.isEmpty())
18911891
&& javaMethod.getReturns() != null
18921892
&& !javaMethod.getReturns().isVoid()) {
18931893
sb.append(originalJavadocTag);
@@ -3044,7 +3044,7 @@ private static String alignIndentationJavadocLines(final String content, final S
30443044
* @return the indentation for the given line.
30453045
*/
30463046
private static String autodetectIndentation(final String line) {
3047-
if (StringUtils.isEmpty(line)) {
3047+
if (line == null || line.isEmpty()) {
30483048
return "";
30493049
}
30503050

@@ -3084,7 +3084,7 @@ private static String[] getLines(final String content) throws IOException {
30843084
* @return the text trimmed on left side or empty if text is null.
30853085
*/
30863086
private static String trimLeft(final String text) {
3087-
if (StringUtils.isEmpty(text) || StringUtils.isEmpty(text.trim())) {
3087+
if ((text == null || text.isEmpty()) || StringUtils.isEmpty(text.trim())) {
30883088
return "";
30893089
}
30903090

@@ -3106,7 +3106,7 @@ private static String trimLeft(final String text) {
31063106
* @return the text trimmed on tight side or empty if text is null.
31073107
*/
31083108
private static String trimRight(final String text) {
3109-
if (StringUtils.isEmpty(text) || StringUtils.isEmpty(text.trim())) {
3109+
if ((text == null || text.isEmpty()) || StringUtils.isEmpty(text.trim())) {
31103110
return "";
31113111
}
31123112

0 commit comments

Comments
 (0)