On reflection, my patch isn't what you were asking for. I created:
+ public static <T> T defaultIfNull(T array, T defaultValue)
+ return array != null ? array : defaultValue;
Thinking that that allows you to set a default value if array is null. I'm not sure you were asking for that - feels more that you were asking for:
+ public static <T> T defaultIfEmpty(T array, T defaultValue)
+ return (array != null && array.length != 0) ? array : defaultValue;
Which you would call as: array = defaultIfEmpty(array, null)
That seems a little odd to me. To consider an empty array to be bad and want to override it with something else (such as null as you're suggesting above). Am I understanding correctly what you wanted?