Skip to content

Commit

Permalink
[MNG-7729] deprecate questionable IsEmpty/IsNotEmpty methods (#136)
Browse files Browse the repository at this point in the history
* deprecate questionable utility methods
  • Loading branch information
elharo committed Apr 28, 2023
1 parent 020cc01 commit 259b796
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/java/org/apache/maven/shared/utils/xml/Xpp3Dom.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,17 +354,27 @@ private PrettyPrintXMLWriter getPrettyPrintXMLWriter(StringWriter writer) {
}

/**
* @param str The string to be checked.
* @return true if the string is not empty (length &gt; 0) and not <code>null</code>.
* Warning: this is not the reverse of {@link #isEmpty}.
* Whitespace only strings are both empty and not empty.
*
* @param str the string to be checked
* @return true if the string is not empty (length &gt; 0) and not <code>null</code>
* @deprecated use <code>str != null &amp;&amp; !str.isEmpty()</code>
*/
@Deprecated
public static boolean isNotEmpty(String str) {
return str != null && str.length() > 0;
}

/**
* @param str The string to be checked.
* @return true if the string is empty or <code>null</code>.
* Warning: this is not the reverse of {@link #isNotEmpty}.
* Whitespace only strings are both empty and not empty.
*
* @param str the string to be checked
* @return true if the string only contains whitespace or is <code>null</code>
* @deprecated use <code>str == null || str.trim().isEmpty()</code>
*/
@Deprecated
public static boolean isEmpty(String str) {
return str == null || str.trim().length() == 0;
}
Expand Down

0 comments on commit 259b796

Please sign in to comment.