commons-lang pull request: add isNull and isNotNull methods

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

commons-lang pull request: add isNull and isNotNull methods

Turan91
GitHub user otaviojava opened a pull request:

    https://github.com/apache/commons-lang/pull/16

    add isNull and isNotNull methods

    Sugestion to add two simple and useful methods, with tests, on ObjectsUtil to get the code cleaner. isnull and isNotNull. So you can use if (ObjectUtil.isNull(value)) instead of if (value == null) the goal is the code more understandable.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/otaviojava/commons-lang trunk

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/commons-lang/pull/16.patch

----
commit 4f4d5b8eecdc61f22363d9d9883626549c12564a
Author: otaviojava <[hidden email]>
Date:   2014-02-04T19:58:43Z

     add two simple and useful methods, with tests, on ObjectsUtil to get
    the code cleaner. isnull and isNotNull.

----


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: commons-lang pull request: add isNull and isNotNull methods

Adrian Crum-3
Personally, I view this as an anti-pattern. You have a null reference in
your hand, and instead of checking the reference that is in your hand,
you give it to an unrelated class and have that class check to see if it
is a null reference. That just doesn't make any sense to me.

Adrian Crum
Sandglass Software
www.sandglass-software.com

On 2/4/2014 12:02 PM, otaviojava wrote:

> GitHub user otaviojava opened a pull request:
>
>      https://github.com/apache/commons-lang/pull/16
>
>      add isNull and isNotNull methods
>
>      Sugestion to add two simple and useful methods, with tests, on ObjectsUtil to get the code cleaner. isnull and isNotNull. So you can use if (ObjectUtil.isNull(value)) instead of if (value == null) the goal is the code more understandable.
>
>
> You can merge this pull request into a Git repository by running:
>
>      $ git pull https://github.com/otaviojava/commons-lang trunk
>
> Alternatively you can review and apply these changes as the patch at:
>
>      https://github.com/apache/commons-lang/pull/16.patch
>
> ----
> commit 4f4d5b8eecdc61f22363d9d9883626549c12564a
> Author: otaviojava <[hidden email]>
> Date:   2014-02-04T19:58:43Z
>
>       add two simple and useful methods, with tests, on ObjectsUtil to get
>      the code cleaner. isnull and isNotNull.
>
> ----
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: commons-lang pull request: add isNull and isNotNull methods

Bernd Eckenfels
Hello,

I agree, for a simple "isNull(Object)" predicate, this is really an anti
pattern. I can understand validate() methods which throw a application
specific cleaned up exception and do some logging and stuff. But this
is nothing for a external dependency.

This is different from isEmpty(String) because that has more code (check
for null, trim, etc).

Gruss
Bernd


 Am Tue, 04 Feb 2014 12:08:13 -0800
schrieb Adrian Crum <[hidden email]>:

> Personally, I view this as an anti-pattern. You have a null reference
> in your hand, and instead of checking the reference that is in your
> hand, you give it to an unrelated class and have that class check to
> see if it is a null reference. That just doesn't make any sense to me.
>
> Adrian Crum
> Sandglass Software
> www.sandglass-software.com
>
> On 2/4/2014 12:02 PM, otaviojava wrote:
> > GitHub user otaviojava opened a pull request:
> >
> >      https://github.com/apache/commons-lang/pull/16
> >
> >      add isNull and isNotNull methods
> >
> >      Sugestion to add two simple and useful methods, with tests, on
> > ObjectsUtil to get the code cleaner. isnull and isNotNull. So you
> > can use if (ObjectUtil.isNull(value)) instead of if (value == null)
> > the goal is the code more understandable.
> >
> >
> > You can merge this pull request into a Git repository by running:
> >
> >      $ git pull https://github.com/otaviojava/commons-lang trunk
> >
> > Alternatively you can review and apply these changes as the patch
> > at:
> >
> >      https://github.com/apache/commons-lang/pull/16.patch
> >
> > ----
> > commit 4f4d5b8eecdc61f22363d9d9883626549c12564a
> > Author: otaviojava <[hidden email]>
> > Date:   2014-02-04T19:58:43Z
> >
> >       add two simple and useful methods, with tests, on ObjectsUtil
> > to get the code cleaner. isnull and isNotNull.
> >
> > ----
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]