Objects.firstNonNull

Mike Duigou mike.duigou at oracle.com
Wed Mar 20 13:24:33 PDT 2013


As I recall Guava's low usage metrics for Objects.firstNonNull() were why this method was not brought in when Objects.requireNonNull was added.

Mike

On Mar 20 2013, at 12:12 , Kevin Bourrillion wrote:

> Just for some perspective: at Google Objects.firstNonNull() is used only a
> small fraction as often as, say, Optional is, despite being far older.
> 
> 
> 
> On Wed, Mar 20, 2013 at 12:04 PM, Brian Goetz <brian.goetz at oracle.com>wrote:
> 
>> My point was: with 10M Java developers, there are likely to be millions
>> of commonly used idioms.  Should we put them all in the JDK?  And if we
>> did, could users find any of them?  The bar needs to be higher than
>> "I've found it useful."
>> 
>> We're far better off putting our energy into doing things that users
>> can't do themselves in two lines, like supporting parallel map-reduce on
>> non-thread-safe ArrayList.
>> 
>> On 3/20/2013 2:55 PM, Michael Nascimento wrote:
>>> Of course I could, but as in Map.getOrDefault, this is a very much
>>> commonly used idiom.
>>> 
>>> Regards,
>>> Michael
>>> 
>>> On Wed, Mar 20, 2013 at 3:51 PM, Brian Goetz <brian.goetz at oracle.com>
>> wrote:
>>>> Or you could write your own in two lines.
>>>> 
>>>> 
>>>> On 3/20/2013 2:33 PM, Michael Nascimento wrote:
>>>>> 
>>>>> Hi guys,
>>>>> 
>>>>> Since Map.getOrDefault has been added (yes!!!), couldn't a
>>>>> Objects.firstNonNull that works like Guava's one:
>>>>> 
>>>>> 
>>>>> 
>> http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/Objects.html#firstNonNull(T
>> ,
>>>>> T)
>>>>> 
>>>>> Then all uses of Objects.firstNonNull would be gone from my code base.
>>>>> 
>>>>> Regards,
>>>>> Michael
>>>>> 
>>>> 
>> 
>> 
> 
> 
> -- 
> Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com
> 



More information about the lambda-dev mailing list