You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ruslan Sibgatullin (JIRA)" <ji...@apache.org> on 2018/07/12 20:12:00 UTC

[jira] [Created] (LANG-1404) BooleanUtils.toBoolean(Integer) method added

Ruslan Sibgatullin created LANG-1404:
----------------------------------------

             Summary: 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


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)