mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-10 10:36:21 +00:00
introduce hudson.Util#fixNull(value, defaultValue)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
1 file changed
+12
-6
@@ -1195,8 +1195,14 @@ public class Util {
|
||||
*/
|
||||
@Nonnull
|
||||
public static String fixNull(@CheckForNull String s) {
|
||||
if(s==null) return "";
|
||||
else return s;
|
||||
return fixNull(s, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert null to defaultValue.
|
||||
*/
|
||||
public static <T> T fixNull(@CheckForNull T s, T defaultValue) {
|
||||
return s != null ? s : defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1221,22 +1227,22 @@ public class Util {
|
||||
|
||||
@Nonnull
|
||||
public static <T> List<T> fixNull(@CheckForNull List<T> l) {
|
||||
return l!=null ? l : Collections.<T>emptyList();
|
||||
return fixNull(l, Collections.<T>emptyList());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static <T> Set<T> fixNull(@CheckForNull Set<T> l) {
|
||||
return l!=null ? l : Collections.<T>emptySet();
|
||||
return fixNull(l, Collections.<T>emptySet());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static <T> Collection<T> fixNull(@CheckForNull Collection<T> l) {
|
||||
return l!=null ? l : Collections.<T>emptySet();
|
||||
return fixNull(l, Collections.<T>emptySet());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static <T> Iterable<T> fixNull(@CheckForNull Iterable<T> l) {
|
||||
return l!=null ? l : Collections.<T>emptySet();
|
||||
return fixNull(l, Collections.<T>emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user