Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSHARED-918] deprecate equals in favor of Objects.equals() #50

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions src/main/java/org/apache/maven/shared/utils/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ public static boolean isNotBlank( @Nullable String str )
* @return <code>true</code> if the Strings are equal, case sensitive, or
* both <code>null</code>
* @see java.lang.String#equals(Object)
* @deprecated use {@code java.lang.Objects.equals()}
*/
@Deprecated
public static boolean equals( @Nullable String str1, @Nullable String str2 )
{
return ( str1 == null ? str2 == null : str1.equals( str2 ) );
Expand Down Expand Up @@ -315,7 +317,7 @@ public static int lastIndexOfAny( String str, String... searchStrs )

/**
* <p>Gets a substring from the specified string avoiding exceptions.</p>
* <p/>
*
* <p>A negative start position can be used to start <code>n</code>
* characters from the end of the String.</p>
*
Expand Down Expand Up @@ -351,7 +353,7 @@ public static String substring( String str, int start )

/**
* <p>Gets a substring from the specified String avoiding exceptions.</p>
* <p/>
*
* <p>A negative start position can be used to start/end <code>n</code>
* characters from the end of the String.</p>
*
Expand All @@ -360,7 +362,7 @@ public static String substring( String str, int start )
* count back from the end of the string by this many characters
* @param end the position to end at (exclusive), negative means
* count back from the end of the String by this many characters
* @return substring from start position to end positon
* @return substring from start position to end position
*/
public static String substring( String str, int start, int end )
{
Expand Down Expand Up @@ -406,7 +408,7 @@ public static String substring( String str, int start, int end )

/**
* <p>Gets the leftmost <code>n</code> characters of a String.</p>
* <p/>
*
* <p>If <code>n</code> characters are not available, or the
* String is <code>null</code>, the String will be returned without
* an exception.</p>
Expand Down Expand Up @@ -434,7 +436,7 @@ public static String left( String str, int len )

/**
* <p>Gets the rightmost <code>n</code> characters of a String.</p>
* <p/>
*
* <p>If <code>n</code> characters are not available, or the String
* is <code>null</code>, the String will be returned without an
* exception.</p>
Expand Down Expand Up @@ -462,7 +464,7 @@ public static String right( String str, int len )

/**
* <p>Gets <code>n</code> characters from the middle of a String.</p>
* <p/>
*
* <p>If <code>n</code> characters are not available, the remainder
* of the String will be returned without an exception. If the
* String is <code>null</code>, <code>null</code> will be returned.</p>
Expand Down Expand Up @@ -504,7 +506,7 @@ public static String mid( String str, int pos, int len )
/**
* <p>Splits the provided text into a array, using whitespace as the
* separator.</p>
* <p/>
*
* <p>The separator is not included in the returned String array.</p>
*
* @param str the String to parse
Expand All @@ -516,9 +518,9 @@ public static String mid( String str, int pos, int len )
}

/**
* @param text The text to be split.
* @param separator The separator at which the text will be split.
* @return The resulting array.
* @param text the text to be split
* @param separator the separator at which the text will be split
* @return the resulting array
* @see #split(String, String, int)
*/
@Nonnull public static String[] split( @Nonnull String text, @Nullable String separator )
Expand All @@ -528,19 +530,19 @@ public static String mid( String str, int pos, int len )

/**
* <p>Splits the provided text into a array, based on a given separator.</p>
* <p/>
*
* <p>The separator is not included in the returned String array. The
* maximum number of splits to perform can be controlled. A <code>null</code>
* separator causes splitting on whitespace.</p>
* <p/>
*
* <p>This is useful for quickly splitting a String into
* an array of tokens, instead of an enumeration of tokens (as
* <code>StringTokenizer</code> does).</p>
*
* @param str The string to parse.
* @param separator Characters used as the delimiters. If
* @param str the string to parse
* @param separatorcCharacters used as the delimiters. If
* <code>null</code>, splits on whitespace.
* @param max The maximum number of elements to include in the
* @param max the maximum number of elements to include in the
* array. A zero or negative value implies no limit.
* @return an array of parsed Strings
*/
Expand Down Expand Up @@ -2375,11 +2377,10 @@ public static String escape( @Nullable String source, @Nonnull final char[] esca
}

/**
* Remove all duplicate whitespace characters and line terminators are replaced with a single
* space.
* Remove all duplicate whitespace characters and replace line terminators with a single space.
*
* @param s a not null String
* @return a string with unique whitespace.
* @return a string with unique whitespace
*
*/
@Nonnull public static String removeDuplicateWhitespace( @Nonnull String s )
Expand Down