Declare @⁠Contract for quote() & getFilename() in StringUtils

This commit declares nullability @⁠Contract annotations for quote() and
getFilename() in StringUtils.

Closes gh-34896


Signed-off-by: Stéphane Nicoll <stephane.nicoll@broadcom.com>
This commit is contained in:
Stéphane Nicoll
2025-05-21 17:43:23 +02:00
committed by GitHub
parent 88ce11abc8
commit 9d3779db49

View File

@@ -516,6 +516,7 @@ public abstract class StringUtils {
* @return the quoted {@code String} (for example, "'myString'"),
* or {@code null} if the input was {@code null}
*/
@Contract("null -> null; !null -> !null")
public static @Nullable String quote(@Nullable String str) {
return (str != null ? "'" + str + "'" : null);
}
@@ -618,6 +619,7 @@ public abstract class StringUtils {
* @param path the file path (may be {@code null})
* @return the extracted filename, or {@code null} if none
*/
@Contract("null -> null; !null -> !null")
public static @Nullable String getFilename(@Nullable String path) {
if (path == null) {
return null;