You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Bernhard Bonigl (Jira)" <ji...@apache.org> on 2020/01/08 08:15:00 UTC

[jira] [Commented] (LANG-1513) ObjectUtils: Get first non-null supplier value

    [ https://issues.apache.org/jira/browse/LANG-1513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17010455#comment-17010455 ] 

Bernhard Bonigl commented on LANG-1513:
---------------------------------------

Verified it, thanks!

> ObjectUtils: Get first non-null supplier value
> ----------------------------------------------
>
>                 Key: LANG-1513
>                 URL: https://issues.apache.org/jira/browse/LANG-1513
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>            Reporter: Bernhard Bonigl
>            Priority: Major
>             Fix For: 3.10
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Add {{org.apache.commons.lang3.ObjectUtils.getFirstNonNull(Supplier<T>...)}}
> ----
> {{\ObjectUtils.firstNonNull}} takes values, and returns the first non null. This is often used when multiple options have to be tried one after another.
> When each option is expensive to compute, you don't want to calculate them all beforehand, but only evaluate them when needed. For this I propose {{firstNonNullLazy}}, which takes a Supplier and only evaluates the value if it needs to be checked.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)