You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/07/12 20:21:00 UTC
[jira] [Commented] (LANG-1404) BooleanUtils.toBoolean(Integer)
method added
[ https://issues.apache.org/jira/browse/LANG-1404?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16542167#comment-16542167 ]
ASF GitHub Bot commented on LANG-1404:
--------------------------------------
GitHub user Enigo opened a pull request:
https://github.com/apache/commons-lang/pull/337
LANG-1404 BooleanUtils.toBoolean(Integer) method added
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
}
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/Enigo/commons-lang LANG-1404_boolean_utils
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/commons-lang/pull/337.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #337
----
commit ad5679462ee3751b34122113cd698d05b9545e8b
Author: Ruslan Sibgatullin <be...@...>
Date: 2018-07-12T20:13:31Z
LANG-1404 BooleanUtils.toBoolean(Integer) method added
----
> 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)