commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedikt Ritter (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-922) Add isOneTrue(booleans...) to BooleanUtils to preserve old behavior of BooleanUtils.xor(booleans...)
Date Sun, 20 Oct 2013 14:27:42 GMT

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

Benedikt Ritter commented on LANG-922:
--------------------------------------

{quote}
Thus old BooleanUtils.xor(args) would now be ArrayUtils.count(true, args) == 1.
{quote}

IMHO we should not change BooleanUtils.xor(boolean...) back the old behavior (which was counting
true values), because it was simply wrong :-) You can have a boolean array with more than
one true value and still the result of XOR can be true:

{code}
   true ^ true ^ true
= false ^ true
= true
{code}

So the first thing to do was fixing this bug. Now we need to decide if we want to preserve
the old behavior and possibly add other convenience methods like isAnyTrue, isExactlyOneFalse
and the like.

> Add isOneTrue(booleans...) to BooleanUtils to preserve old behavior of BooleanUtils.xor(booleans...)
> ----------------------------------------------------------------------------------------------------
>
>                 Key: LANG-922
>                 URL: https://issues.apache.org/jira/browse/LANG-922
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>            Reporter: Benedikt Ritter
>            Assignee: Benedikt Ritter
>             Fix For: 3.2, Discussion
>
>
> The old implementation (prior to r1532476) of BooleanUtils.xor(boolean...) checked if
the provided array contained exactly one boolean with value true. This was changed because
it is not the correct behavior for an XOR operation. To preserve the behavior we should add
BooleanUtils.isOneTrue(boolean...) and BooleanUtils.isOneTrue(Boolean...) (and possibly the
equivalents for isOneFalse).



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message