commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivan Hristov (JIRA)" <>
Subject [jira] [Commented] (LANG-694) ObjectUtils.defaultIfNotNull
Date Wed, 20 Apr 2011 15:26:10 GMT


Ivan Hristov commented on LANG-694:

Yes, you are right it does not make much sense. I admit that I did not structure issue's description
well. Please, accept my apologize for the time taken. I was looking for a way to execute given
method on an object if it's not null without having to check each time if the object is null.
If the object is null, simply return null otherwise return the result of the executed method.
I am going to close the issue.

> ObjectUtils.defaultIfNotNull
> ----------------------------
>                 Key: LANG-694
>                 URL:
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>         Environment: all
>            Reporter: Ivan Hristov
>            Priority: Minor
>   Original Estimate: 10m
>  Remaining Estimate: 10m
> Currently there is a defaultIfNull method in ObjectUtils, which is a great one, but it
will be nice to have an additional method called defaultIfNotNull which returns null if the
first parameter is null or the second parameter if the object is not null. 
> ObjectUtils.defaultIfNotNull(object1, anotherObject);
> For the moment I have to perform a null comparison on my own,e.g., 
> if (object1 == null) {
> return null;
> }
> return anotherObject;

This message is automatically generated by JIRA.
For more information on JIRA, see:

View raw message