Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1513

ObjectUtils: Get first non-null supplier value

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.10
    • lang.*
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bonii-xx Bernhard Bonigl
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m