Java Optional orElseThrow with empty collection

后端 未结 3 1545
情深已故
情深已故 2021-01-14 05:03

I\'m implementing a stream in which I use a collection listOfFoo to get ids of all items in that list and use them to get values of Bar instances.

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-14 05:11

    The book Effective Java mentions the following:

    Container types, including collections, maps, streams, arrays, and optionals should not be wrapped in optionals. (P.252)

提交回复
热议问题