Objects.nonNull()

Bruce Chapman brucechapman at paradise.net.nz
Sat Jan 22 07:35:20 UTC 2011


On 15/01/2011 12:30 a.m., Stephen Colebourne wrote:
snip
> 5) Now
> *** If you are time-pressured, I'd recommend removing this method from v7. ***
>
> A "defaultIfNull" method would be much more useful in this class:
>      public static Object defaultIfNull(Object object, Object defaultValue) {
>          return object != null ? object : defaultValue;
>      }

More useful as a generic method

<T> T defaultIfNull(T object, T default) {

         return object != null ? object : defaultValue;

}


- snip-
> Stephen
>
>
-snip-



More information about the core-libs-dev mailing list