[jira] Created: (COLLECTIONS-280) Add Predicate that failed PredicatedCollection.validate to IllegalArgumentException text

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (COLLECTIONS-280) Add Predicate that failed PredicatedCollection.validate to IllegalArgumentException text

Gilles Sadowski (Jira)
Add Predicate that failed PredicatedCollection.validate to IllegalArgumentException text
----------------------------------------------------------------------------------------

                 Key: COLLECTIONS-280
                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-280
             Project: Commons Collections
          Issue Type: Improvement
          Components: Collection
    Affects Versions: 3.2
         Environment: N/A
            Reporter: Chris Lewis
            Priority: Minor


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.


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (COLLECTIONS-280) Add Predicate that failed PredicatedCollection.validate to IllegalArgumentException text

Gilles Sadowski (Jira)

     [ https://issues.apache.org/jira/browse/COLLECTIONS-280?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated COLLECTIONS-280:
--------------------------------------

    Fix Version/s: 3.3

> Add Predicate that failed PredicatedCollection.validate to IllegalArgumentException text
> ----------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-280
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-280
>             Project: Commons Collections
>          Issue Type: Improvement
>          Components: Collection
>    Affects Versions: 3.2
>         Environment: N/A
>            Reporter: Chris Lewis
>            Priority: Minor
>             Fix For: 3.3
>
>
> 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.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (COLLECTIONS-280) Add Predicate that failed PredicatedCollection.validate to IllegalArgumentException text

Gilles Sadowski (Jira)
In reply to this post by Gilles Sadowski (Jira)

     [ https://issues.apache.org/jira/browse/COLLECTIONS-280?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell closed COLLECTIONS-280.
-------------------------------------

    Resolution: Fixed

 svn ci -m "Adding the predicate to the IllegalArgumentException as per COLLECTIONS-280" src
Sending        src/java/org/apache/commons/collections/collection/PredicatedCollection.java
Transmitting file data .
Committed revision 641165.

> Add Predicate that failed PredicatedCollection.validate to IllegalArgumentException text
> ----------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-280
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-280
>             Project: Commons Collections
>          Issue Type: Improvement
>          Components: Collection
>    Affects Versions: 3.2
>         Environment: N/A
>            Reporter: Chris Lewis
>            Priority: Minor
>             Fix For: 3.3
>
>
> 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.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.