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

Add Predicate that failed PredicatedCollection.validate to IllegalArgumentException text

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2
    • 4.0-alpha1, 4.0
    • Collection
    • None
    • N/A

    Description

      In a project I'm working on at the moment, I decorate some of my sets with multiple Predicates. In the event that validation fails, it would be nice to know which predicate caused the failure.

      I'd suggest changing the validate method in PredicatedCollection to:

      protected void validate(Object object) {
      if (predicate.evaluate(object) == false)

      { throw new IllegalArgumentException("Cannot add Object '" + object + "' - Predicate '" + predicate + "' rejected it"); }

      }

      Then, the user can provide a toString method with relevant information about the Predicate and why it might cause the validation to fail if they choose.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ctl271 Chris Lewis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: