You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Adrian Crum (JIRA)" <ji...@apache.org> on 2010/04/14 21:40:49 UTC

[jira] Created: (LANG-618) Add an Assert class to simplify programming.

Add an Assert class to simplify programming.
--------------------------------------------

                 Key: LANG-618
                 URL: https://issues.apache.org/jira/browse/LANG-618
             Project: Commons Lang
          Issue Type: New Feature
          Components: lang.*
    Affects Versions: 3.1
            Reporter: Adrian Crum
            Priority: Minor




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (LANG-618) Add an Assert class to simplify programming.

Posted by "Adrian Crum (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12857111#action_12857111 ] 

Adrian Crum commented on LANG-618:
----------------------------------

I prefer my syntax though:

Assert.argumentsNotNull("foo", foo, "bar", bar, ...);

There is no way to do that with Validate.


> Add an Assert class to simplify programming.
> --------------------------------------------
>
>                 Key: LANG-618
>                 URL: https://issues.apache.org/jira/browse/LANG-618
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: LANG-618.patch
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (LANG-618) Add an Assert class to simplify programming.

Posted by "Adrian Crum (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12857317#action_12857317 ] 

Adrian Crum commented on LANG-618:
----------------------------------

If I use the wrapper method, then I end up with this:

Assert.argumentsNotNull("Argument \"foo\" cannot be null.", foo, "Argument \"bar\" cannot be null.", bar, ...);

and I still get a NullPointerException instead of an IllegalArgumentException.

The bottom line is, I would be trying to use Validate for something it wasn't designed for. It just isn't a good fit.

The idea behind Assert was to make argument checking convenient - so that it will be done more often, and to make the exceptions it throws meaningful to developers.


> Add an Assert class to simplify programming.
> --------------------------------------------
>
>                 Key: LANG-618
>                 URL: https://issues.apache.org/jira/browse/LANG-618
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: LANG-618.patch
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Closed: (LANG-618) Add an Assert class to simplify programming.

Posted by "Adrian Crum (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-618?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adrian Crum closed LANG-618.
----------------------------

    Resolution: Fixed

Thanks! I didn't notice that.


> Add an Assert class to simplify programming.
> --------------------------------------------
>
>                 Key: LANG-618
>                 URL: https://issues.apache.org/jira/browse/LANG-618
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: LANG-618.patch
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (LANG-618) Add an Assert class to simplify programming.

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12857311#action_12857311 ] 

James Carman commented on LANG-618:
-----------------------------------

You could also use  aspects and annotations to do what you are looking to do.

> Add an Assert class to simplify programming.
> --------------------------------------------
>
>                 Key: LANG-618
>                 URL: https://issues.apache.org/jira/browse/LANG-618
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: LANG-618.patch
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (LANG-618) Add an Assert class to simplify programming.

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12857050#action_12857050 ] 

James Carman commented on LANG-618:
-----------------------------------

Have you looked at the Validate class?

http://commons.apache.org/lang/api-release/org/apache/commons/lang/Validate.html


> Add an Assert class to simplify programming.
> --------------------------------------------
>
>                 Key: LANG-618
>                 URL: https://issues.apache.org/jira/browse/LANG-618
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: LANG-618.patch
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (LANG-618) Add an Assert class to simplify programming.

Posted by "Adrian Crum (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12857304#action_12857304 ] 

Adrian Crum commented on LANG-618:
----------------------------------

A wrapper won't work. Let's say the bar argument is null. The Assert.argumentsNotNull method will throw an IllegalArgumentException with the message "bar cannot be null." If I have a wrapper that calls Validate.notNull, the argument name gets discarded and a NullPointerException is thrown with the message "The validated object is null." Which object was null? Foo or bar? The Assert class gives the developer more information.

I'm not trying to push this btw. I'm just explaining why I prefer it.


> Add an Assert class to simplify programming.
> --------------------------------------------
>
>                 Key: LANG-618
>                 URL: https://issues.apache.org/jira/browse/LANG-618
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: LANG-618.patch
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (LANG-618) Add an Assert class to simplify programming.

Posted by "Adrian Crum (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-618?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adrian Crum updated LANG-618:
-----------------------------

    Attachment: LANG-618.patch

> Add an Assert class to simplify programming.
> --------------------------------------------
>
>                 Key: LANG-618
>                 URL: https://issues.apache.org/jira/browse/LANG-618
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: LANG-618.patch
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (LANG-618) Add an Assert class to simplify programming.

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12857276#action_12857276 ] 

James Carman commented on LANG-618:
-----------------------------------

Wrapper method?

> Add an Assert class to simplify programming.
> --------------------------------------------
>
>                 Key: LANG-618
>                 URL: https://issues.apache.org/jira/browse/LANG-618
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: LANG-618.patch
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (LANG-618) Add an Assert class to simplify programming.

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12857310#action_12857310 ] 

James Carman commented on LANG-618:
-----------------------------------

What's wrong with:

Validate.notNull(foo, "Argument \"foo\" cannot be null.");
Validate.notNull(bar, "Argument \"bar\" cannot be null.");

> Add an Assert class to simplify programming.
> --------------------------------------------
>
>                 Key: LANG-618
>                 URL: https://issues.apache.org/jira/browse/LANG-618
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Adrian Crum
>            Priority: Minor
>         Attachments: LANG-618.patch
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira