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

Refactor Validate.java to eliminate code redundancy

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 3.0
    • lang.*
    • None
    • software

    Description

      I am using Validate.java since long and find it difficult to use when I just want to validate collections or string.
      With current interface, I go like this:

      while(cnt < list.size()) {
      List list1 = list.get(cnt);
      try

      { Validate.notEmpty(list1); }

      catch(IllegalArgumentException e)

      { continue; }
      }

      much better approach is:

      while(cnt < list.size()) {
      List list1 = list.get(cnt);
      try {
      if(! Validate.notEmpty(list1)) { continue; }

      }

      If you all agree with this change, I am willing to submit a patch for this.

      Attachments

        1. validate_test_diff.txt
          3 kB
          Viraj Turakhia
        2. vaidate_diff.txt
          7 kB
          Viraj Turakhia

        Activity

          People

            Unassigned Unassigned
            virajturakhia Viraj Turakhia
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: