[ 
https://issues.apache.org/jira/browse/LANG-1404?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16542610#comment-16542610
 ] 

Ruslan Sibgatullin commented on LANG-1404:
------------------------------------------

[~s...@apache.org] whenever there's a nullable Integer to convert into boolean. 
As I wrote in the description - now it's doable but either with 2 if statements 
or with two methods. 

> BooleanUtils.toBoolean(Integer) method added
> --------------------------------------------
>
>                 Key: LANG-1404
>                 URL: https://issues.apache.org/jira/browse/LANG-1404
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>            Reporter: Ruslan Sibgatullin
>            Priority: Minor
>
> Right now to convert an Integer to boolean there is either a null check 
> needed:
> {{final Integer value = 1;}}
>  {{if (value != null) {}}
>  {{    if(BooleanUtils.toBoolean(value)) {}}
> {{        // some code}}
>       }
>  {{}}}
> or two methods call:
>  
> {{final Integer value = 1;}}
>  {{final Boolean b = BooleanUtils.toBooleanObject(value);}}
>  {{if (BooleanUtils.toBoolean(b)) {}}
>  {{    // some code}}
>  {{}}}
> Some code-sugar is added with the help of method that accepts Integer and 
> returns boolean:
> {{final Integer value = 1;}}
>  {{if (BooleanUtils.toBoolean(value)) {}}
>       // some code
>  {{}}}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to