Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-600

Make CollectionUtils (in particular isEqualCollection) null-safe

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.1
    • Fix Version/s: None
    • Component/s: Collection
    • Labels:
      None

      Description

      Other Commons *Utils classes as StringUtils etc. feature null-safe methods. Why doesn't for example CollectionUtils#isEqualCollection include a null check, like this?

          public static boolean isEqualCollection(final Collection<?> a, final Collection<?> b) {
              if(a == null || b == null) {
                  return false;
              }
              if(a.size() != b.size()) {
                  return false;
              }
              final CardinalityHelper<Object> helper = new CardinalityHelper<Object>(a, b);
              if(helper.cardinalityA.size() != helper.cardinalityB.size()) {
                  return false;
              }
              for( final Object obj : helper.cardinalityA.keySet()) {
                  if(helper.freqA(obj) != helper.freqB(obj)) {
                      return false;
                  }
              }
              return true;
          }
      

      I considered filing a Pull Request but wanted to ask here first.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jholtkamp Jonas Holtkamp
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: