Feels like the new method is a more general Array one. Not sure if we have
it already.

ArrayUtils.countMatching(array, value) == 1

Note also that 'isOneTrue' doesn't mean the same as 'isOnlyOneTrue'.

Hen

On Tuesday, October 15, 2013, Benedikt Ritter wrote:

> I have created LANG-921 and am currently working on this. I prefer to make
> the behavior correct as Hen has suggested and add two new method isOneTrue
> and isOneFalse.
>
>
> 2013/10/15 Matt Benson <gudnabr...@gmail.com>
>
> > Another alternative:  preserve the current #xor() method with
> > documentation, and implement the ^ analogue as #binaryXor().
> >
> > Matt
> >
> >
> > On Tue, Oct 15, 2013 at 9:05 AM, Matt Benson <gudnabr...@gmail.com>
> wrote:
> >
> > > In this case we should perhaps provide a #oneTrue(boolean...) method to
> > > preserve the availability of the current behavior, which may also
> > > occasionally have its place.
> > >
> > > Matt
> > >
> > >
> > > On Mon, Oct 14, 2013 at 11:10 PM, Henri Yandell <flame...@gmail.com
> > >wrote:
> > >
> > >> I think we treat it as a bug and fix. The code is fine for the
> explained
> > >> use of an array of length 2, but fails when you move to larger chains.
> > >> Given the common meaning of the name, I think people would have
> noticed
> > if
> > >> they'd needed xor to work for arrays > 2 and it didn't. So a) I think
> we
> > >> can fix and b) I suspect it's not a highly used method.
> > >>
> > >> So rather than the note, I'm +1 to fixing the code.
> > >>
> > >> Hen
> > >>
> > >>
> > >> On Mon, Oct 14, 2013 at 12:22 PM, Benedikt Ritter <brit...@apache.org
> > >> >wrote:
> > >>
> > >> > Thoughts? Maybe this should be renamed to "isOneTrue(boolean...)" in
> > the
> > >> > next major release?!
> > >> >
> > >> > ---------- Forwarded message ----------
> > >> > From: <brit...@apache.org>
> > >> > Date: 2013/10/14
> > >> > Subject: svn commit: r1532031 -
> > >> >
> > >> >
> > >>
> >
> /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java
> > >> > To: comm...@commons.apache.org
> > >> >
> > >> >
> > >> > Author: britter
> > >> > Date: Mon Oct 14 19:21:02 2013
> > >> > New Revision: 1532031
> > >> >
> > >> > URL: http://svn.apache.org/r1532031
> > >> > Log:
> > >> > Document (wrong?) behavior of xor methods
> > >> >
> > >> > Modified:
> > >> >
> > >> >
> > >> >
> > >>
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java
> > >> >
> > >> > Modified:
> > >> >
> > >> >
> > >>
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java
> > >> > URL:
> > >> >
> > >> >
> > >>
> >
> http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java?rev=1532031&r1=1532030&r2=1532031&view=diff
> > >> >
> > >> >
> > >>
> >
> ==============================================================================
> > >> > ---
> > >> >
> > >> >
> > >>
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java
> > >> > (original)
> > >> > +++
> > >> >
> > >> >
> > >>
> >
> commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/BooleanUtils.java
> > >> > Mon Oct 14 19:21:02 2013
> > >> > @@ -1028,6 +1028,14 @@ public class BooleanUtils {
> > >> >       *   BooleanUtils.xor(true, false)  = true
> > >> >       * </pre>
> > >> >       *
> > >

Reply via email to