Deprecate StringUtils.defaultString(String, String) in favor of
Objects.toString(Object, String).
This commit is contained in:
parent
4cea07b48f
commit
fe60dcfd42
|
@ -1562,12 +1562,12 @@ public class StringUtils {
|
||||||
* was {@code null}
|
* was {@code null}
|
||||||
*/
|
*/
|
||||||
public static String defaultString(final String str) {
|
public static String defaultString(final String str) {
|
||||||
return defaultString(str, EMPTY);
|
return Objects.toString(str, EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Returns either the passed in String, or if the String is
|
* Returns either the given String, or if the String is
|
||||||
* {@code null}, the value of {@code defaultStr}.</p>
|
* {@code null}, {@code nullDefault}.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.defaultString(null, "NULL") = "NULL"
|
* StringUtils.defaultString(null, "NULL") = "NULL"
|
||||||
|
@ -1575,15 +1575,17 @@ public class StringUtils {
|
||||||
* StringUtils.defaultString("bat", "NULL") = "bat"
|
* StringUtils.defaultString("bat", "NULL") = "bat"
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @see ObjectUtils#toString(Object,String)
|
* @see Objects#toString(Object, String)
|
||||||
* @see String#valueOf(Object)
|
* @see String#valueOf(Object)
|
||||||
* @param str the String to check, may be null
|
* @param str the String to check, may be null
|
||||||
* @param defaultStr the default String to return
|
* @param nullDefault the default String to return
|
||||||
* if the input is {@code null}, may be null
|
* if the input is {@code null}, may be null
|
||||||
* @return the passed in String, or the default if it was {@code null}
|
* @return the passed in String, or the default if it was {@code null}
|
||||||
|
* @deprecated Use {@link Objects#toString(Object, String)}
|
||||||
*/
|
*/
|
||||||
public static String defaultString(final String str, final String defaultStr) {
|
@Deprecated
|
||||||
return str == null ? defaultStr : str;
|
public static String defaultString(final String str, final String nullDefault) {
|
||||||
|
return Objects.toString(str, nullDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue