Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-11064

Use Groovy Truth instead of UtilValidate Class in Groovy

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Implemented
    • Affects Version/s: Trunk
    • Fix Version/s: Upcoming Branch
    • Component/s: ALL COMPONENTS
    • Labels:
      None

      Description

      As we all know, Groovy is a powerful language with great built-in functions. Groovy Truth[1] is one of them, which is not used properly in our code base. We have used UtilValidate Class to validate arguments for Empty or NotEmpty, which can easily be done in groovy with built-in functionality.
       
      Current Code: if (UtilValidate.isNotEmpty(locations)) { ... }
       
      Groovy Built-in Code: if (locations) { ... }
       
      IMO, We should use this Groovy Truth feature instead of UtilValidate Class. Please let me know your thoughts on this. Thanks!
      [1]http://groovy-lang.org/semantics.html#Groovy-Truth
       
      We need to careful for some points while we change this:
      Like:
      maxRetry = 0
      if (!maxRetry)

      {  // Not set, use a default  maxRetry = -1 }

      Because groovy evaluates zero to be false, it wouldn't be possible to set
      maxRetry to zero.  So it's best not to use groovy truth for null-checks on
      numbers in some cases. 
       

        Attachments

        1. OFBIZ-11064-plugins.patch
          10 kB
          Pawan Verma
        2. OFBIZ-11064.patch
          24 kB
          Pawan Verma
        3. OFBIZ-11064.patch
          24 kB
          Pawan Verma

          Activity

            People

            • Assignee:
              jacques.le.roux Jacques Le Roux
              Reporter:
              pawan.verma Pawan Verma
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: