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

Short-circuit operation of firstNonBlank and firstNonEmpty

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.12.0
    • 3.13.0
    • lang.*

    Description

      Sometimes it is not possible to provide an array of strings, but only an array of methods to obtain a string to obtain a string. At this time, you do not need to execute all the methods in the method array, only need to execute until the first method whose result is not an empty string or a blank string. E.g. 

      StringUtil.firstNonBlank(()-> "123", ()-> rpcMethod(), ()->dbQuery())
      

       In the above code, we only need to execute the first method, not the latter two methods, because the latter two methods may be time-consuming.

      Attachments

        Activity

          People

            Unassigned Unassigned
            xuxiao415 Zhengkai Wang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 96h
                96h
                Remaining:
                Remaining Estimate - 96h
                96h
                Logged:
                Time Spent - Not Specified
                Not Specified