Class BooleanUtils
- java.lang.Object
-
- org.apache.commons.lang.BooleanUtils
-
@Deprecated(since="2021-04-30") public class BooleanUtils extends java.lang.Object
Deprecated.Commons Lang 2 is in maintenance mode. Commons Lang 3 should be used instead.Operations on boolean primitives and Boolean objects.
This class tries to handle
null
input gracefully. An exception will not be thrown for anull
input. Each method documents its behaviour in more detail.#ThreadSafe#
- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description BooleanUtils()
Deprecated.BooleanUtils
instances should NOT be constructed in standard programming.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static boolean
isFalse(java.lang.Boolean bool)
Deprecated.Checks if aBoolean
value isfalse
, handlingnull
by returningfalse
.static boolean
isNotFalse(java.lang.Boolean bool)
Deprecated.Checks if aBoolean
value is notfalse
, handlingnull
by returningtrue
.static boolean
isNotTrue(java.lang.Boolean bool)
Deprecated.Checks if aBoolean
value is nottrue
, handlingnull
by returningtrue
.static boolean
isTrue(java.lang.Boolean bool)
Deprecated.Checks if aBoolean
value istrue
, handlingnull
by returningfalse
.static java.lang.Boolean
negate(java.lang.Boolean bool)
Deprecated.Negates the specified boolean.static boolean
toBoolean(int value)
Deprecated.Converts an int to a boolean using the convention thatzero
isfalse
.static boolean
toBoolean(int value, int trueValue, int falseValue)
Deprecated.Converts an int to a boolean specifying the conversion values.static boolean
toBoolean(java.lang.Boolean bool)
Deprecated.Converts a Boolean to a boolean handlingnull
by returningfalse
.static boolean
toBoolean(java.lang.Integer value, java.lang.Integer trueValue, java.lang.Integer falseValue)
Deprecated.Converts an Integer to a boolean specifying the conversion values.static boolean
toBoolean(java.lang.String str)
Deprecated.Converts a String to a boolean (optimised for performance).static boolean
toBoolean(java.lang.String str, java.lang.String trueString, java.lang.String falseString)
Deprecated.Converts a String to a Boolean throwing an exception if no match found.static boolean
toBooleanDefaultIfNull(java.lang.Boolean bool, boolean valueIfNull)
Deprecated.Converts a Boolean to a boolean handlingnull
.static java.lang.Boolean
toBooleanObject(boolean bool)
Deprecated.Boolean factory that avoids creating new Boolean objecs all the time.static java.lang.Boolean
toBooleanObject(int value)
Deprecated.Converts an int to a Boolean using the convention thatzero
isfalse
.static java.lang.Boolean
toBooleanObject(int value, int trueValue, int falseValue, int nullValue)
Deprecated.Converts an int to a Boolean specifying the conversion values.static java.lang.Boolean
toBooleanObject(java.lang.Integer value)
Deprecated.Converts an Integer to a Boolean using the convention thatzero
isfalse
.static java.lang.Boolean
toBooleanObject(java.lang.Integer value, java.lang.Integer trueValue, java.lang.Integer falseValue, java.lang.Integer nullValue)
Deprecated.Converts an Integer to a Boolean specifying the conversion values.static java.lang.Boolean
toBooleanObject(java.lang.String str)
Deprecated.Converts a String to a Boolean.static java.lang.Boolean
toBooleanObject(java.lang.String str, java.lang.String trueString, java.lang.String falseString, java.lang.String nullString)
Deprecated.Converts a String to a Boolean throwing an exception if no match.static int
toInteger(boolean bool)
Deprecated.Converts a boolean to an int using the convention thatzero
isfalse
.static int
toInteger(boolean bool, int trueValue, int falseValue)
Deprecated.Converts a boolean to an int specifying the conversion values.static int
toInteger(java.lang.Boolean bool, int trueValue, int falseValue, int nullValue)
Deprecated.Converts a Boolean to an int specifying the conversion values.static java.lang.Integer
toIntegerObject(boolean bool)
Deprecated.Converts a boolean to an Integer using the convention thatzero
isfalse
.static java.lang.Integer
toIntegerObject(boolean bool, java.lang.Integer trueValue, java.lang.Integer falseValue)
Deprecated.Converts a boolean to an Integer specifying the conversion values.static java.lang.Integer
toIntegerObject(java.lang.Boolean bool)
Deprecated.Converts a Boolean to a Integer using the convention thatzero
isfalse
.static java.lang.Integer
toIntegerObject(java.lang.Boolean bool, java.lang.Integer trueValue, java.lang.Integer falseValue, java.lang.Integer nullValue)
Deprecated.Converts a Boolean to an Integer specifying the conversion values.static java.lang.String
toString(boolean bool, java.lang.String trueString, java.lang.String falseString)
Deprecated.Converts a boolean to a String returning one of the input Strings.static java.lang.String
toString(java.lang.Boolean bool, java.lang.String trueString, java.lang.String falseString, java.lang.String nullString)
Deprecated.Converts a Boolean to a String returning one of the input Strings.static java.lang.String
toStringOnOff(boolean bool)
Deprecated.Converts a boolean to a String returning'on'
or'off'
.static java.lang.String
toStringOnOff(java.lang.Boolean bool)
Deprecated.Converts a Boolean to a String returning'on'
,'off'
, ornull
.static java.lang.String
toStringTrueFalse(boolean bool)
Deprecated.Converts a boolean to a String returning'true'
or'false'
.static java.lang.String
toStringTrueFalse(java.lang.Boolean bool)
Deprecated.Converts a Boolean to a String returning'true'
,'false'
, ornull
.static java.lang.String
toStringYesNo(boolean bool)
Deprecated.Converts a boolean to a String returning'yes'
or'no'
.static java.lang.String
toStringYesNo(java.lang.Boolean bool)
Deprecated.Converts a Boolean to a String returning'yes'
,'no'
, ornull
.static boolean
xor(boolean[] array)
Deprecated.Performs an xor on a set of booleans.static java.lang.Boolean
xor(java.lang.Boolean[] array)
Deprecated.Performs an xor on an array of Booleans.
-
-
-
Constructor Detail
-
BooleanUtils
public BooleanUtils()
Deprecated.BooleanUtils
instances should NOT be constructed in standard programming. Instead, the class should be used asBooleanUtils.toBooleanObject(true);
.This constructor is public to permit tools that require a JavaBean instance to operate.
-
-
Method Detail
-
negate
public static java.lang.Boolean negate(java.lang.Boolean bool)
Deprecated.Negates the specified boolean.
If
null
is passed in,null
will be returned.BooleanUtils.negate(Boolean.TRUE) = Boolean.FALSE; BooleanUtils.negate(Boolean.FALSE) = Boolean.TRUE; BooleanUtils.negate(null) = null;
- Parameters:
bool
- the Boolean to negate, may be null- Returns:
- the negated Boolean, or
null
ifnull
input
-
isTrue
public static boolean isTrue(java.lang.Boolean bool)
Deprecated.Checks if a
Boolean
value istrue
, handlingnull
by returningfalse
.BooleanUtils.isTrue(Boolean.TRUE) = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null) = false
- Parameters:
bool
- the boolean to check, null returnsfalse
- Returns:
true
only if the input is non-null and true- Since:
- 2.1
-
isNotTrue
public static boolean isNotTrue(java.lang.Boolean bool)
Deprecated.Checks if a
Boolean
value is nottrue
, handlingnull
by returningtrue
.BooleanUtils.isNotTrue(Boolean.TRUE) = false BooleanUtils.isNotTrue(Boolean.FALSE) = true BooleanUtils.isNotTrue(null) = true
- Parameters:
bool
- the boolean to check, null returnstrue
- Returns:
true
if the input is null or false- Since:
- 2.3
-
isFalse
public static boolean isFalse(java.lang.Boolean bool)
Deprecated.Checks if a
Boolean
value isfalse
, handlingnull
by returningfalse
.BooleanUtils.isFalse(Boolean.TRUE) = false BooleanUtils.isFalse(Boolean.FALSE) = true BooleanUtils.isFalse(null) = false
- Parameters:
bool
- the boolean to check, null returnsfalse
- Returns:
true
only if the input is non-null and false- Since:
- 2.1
-
isNotFalse
public static boolean isNotFalse(java.lang.Boolean bool)
Deprecated.Checks if a
Boolean
value is notfalse
, handlingnull
by returningtrue
.BooleanUtils.isNotFalse(Boolean.TRUE) = true BooleanUtils.isNotFalse(Boolean.FALSE) = false BooleanUtils.isNotFalse(null) = true
- Parameters:
bool
- the boolean to check, null returnstrue
- Returns:
true
if the input is null or true- Since:
- 2.3
-
toBooleanObject
public static java.lang.Boolean toBooleanObject(boolean bool)
Deprecated.Boolean factory that avoids creating new Boolean objecs all the time.
This method was added to JDK1.4 but is available here for earlier JDKs.
BooleanUtils.toBooleanObject(false) = Boolean.FALSE BooleanUtils.toBooleanObject(true) = Boolean.TRUE
- Parameters:
bool
- the boolean to convert- Returns:
- Boolean.TRUE or Boolean.FALSE as appropriate
-
toBoolean
public static boolean toBoolean(java.lang.Boolean bool)
Deprecated.Converts a Boolean to a boolean handling
null
by returningfalse
.BooleanUtils.toBoolean(Boolean.TRUE) = true BooleanUtils.toBoolean(Boolean.FALSE) = false BooleanUtils.toBoolean(null) = false
- Parameters:
bool
- the boolean to convert- Returns:
true
orfalse
,null
returnsfalse
-
toBooleanDefaultIfNull
public static boolean toBooleanDefaultIfNull(java.lang.Boolean bool, boolean valueIfNull)
Deprecated.Converts a Boolean to a boolean handling
null
.BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, false) = true BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, true) = false BooleanUtils.toBooleanDefaultIfNull(null, true) = true
- Parameters:
bool
- the boolean to convertvalueIfNull
- the boolean value to return ifnull
- Returns:
true
orfalse
-
toBoolean
public static boolean toBoolean(int value)
Deprecated.Converts an int to a boolean using the convention that
zero
isfalse
.BooleanUtils.toBoolean(0) = false BooleanUtils.toBoolean(1) = true BooleanUtils.toBoolean(2) = true
- Parameters:
value
- the int to convert- Returns:
true
if non-zero,false
if zero
-
toBooleanObject
public static java.lang.Boolean toBooleanObject(int value)
Deprecated.Converts an int to a Boolean using the convention that
zero
isfalse
.BooleanUtils.toBoolean(0) = Boolean.FALSE BooleanUtils.toBoolean(1) = Boolean.TRUE BooleanUtils.toBoolean(2) = Boolean.TRUE
- Parameters:
value
- the int to convert- Returns:
- Boolean.TRUE if non-zero, Boolean.FALSE if zero,
null
ifnull
-
toBooleanObject
public static java.lang.Boolean toBooleanObject(java.lang.Integer value)
Deprecated.Converts an Integer to a Boolean using the convention that
zero
isfalse
.null
will be converted tonull
.BooleanUtils.toBoolean(new Integer(0)) = Boolean.FALSE BooleanUtils.toBoolean(new Integer(1)) = Boolean.TRUE BooleanUtils.toBoolean(new Integer(null)) = null
- Parameters:
value
- the Integer to convert- Returns:
- Boolean.TRUE if non-zero, Boolean.FALSE if zero,
null
ifnull
input
-
toBoolean
public static boolean toBoolean(int value, int trueValue, int falseValue)
Deprecated.Converts an int to a boolean specifying the conversion values.
BooleanUtils.toBoolean(0, 1, 0) = false BooleanUtils.toBoolean(1, 1, 0) = true BooleanUtils.toBoolean(2, 1, 2) = false BooleanUtils.toBoolean(2, 2, 0) = true
- Parameters:
value
- the Integer to converttrueValue
- the value to match fortrue
falseValue
- the value to match forfalse
- Returns:
true
orfalse
- Throws:
java.lang.IllegalArgumentException
- if no match
-
toBoolean
public static boolean toBoolean(java.lang.Integer value, java.lang.Integer trueValue, java.lang.Integer falseValue)
Deprecated.Converts an Integer to a boolean specifying the conversion values.
BooleanUtils.toBoolean(new Integer(0), new Integer(1), new Integer(0)) = false BooleanUtils.toBoolean(new Integer(1), new Integer(1), new Integer(0)) = true BooleanUtils.toBoolean(new Integer(2), new Integer(1), new Integer(2)) = false BooleanUtils.toBoolean(new Integer(2), new Integer(2), new Integer(0)) = true BooleanUtils.toBoolean(null, null, new Integer(0)) = true
- Parameters:
value
- the Integer to converttrueValue
- the value to match fortrue
, may benull
falseValue
- the value to match forfalse
, may benull
- Returns:
true
orfalse
- Throws:
java.lang.IllegalArgumentException
- if no match
-
toBooleanObject
public static java.lang.Boolean toBooleanObject(int value, int trueValue, int falseValue, int nullValue)
Deprecated.Converts an int to a Boolean specifying the conversion values.
BooleanUtils.toBooleanObject(0, 0, 2, 3) = Boolean.TRUE BooleanUtils.toBooleanObject(2, 1, 2, 3) = Boolean.FALSE BooleanUtils.toBooleanObject(3, 1, 2, 3) = null
- Parameters:
value
- the Integer to converttrueValue
- the value to match fortrue
falseValue
- the value to match forfalse
nullValue
- the value to to match fornull
- Returns:
- Boolean.TRUE, Boolean.FALSE, or
null
- Throws:
java.lang.IllegalArgumentException
- if no match
-
toBooleanObject
public static java.lang.Boolean toBooleanObject(java.lang.Integer value, java.lang.Integer trueValue, java.lang.Integer falseValue, java.lang.Integer nullValue)
Deprecated.Converts an Integer to a Boolean specifying the conversion values.
BooleanUtils.toBooleanObject(new Integer(0), new Integer(0), new Integer(2), new Integer(3)) = Boolean.TRUE BooleanUtils.toBooleanObject(new Integer(2), new Integer(1), new Integer(2), new Integer(3)) = Boolean.FALSE BooleanUtils.toBooleanObject(new Integer(3), new Integer(1), new Integer(2), new Integer(3)) = null
- Parameters:
value
- the Integer to converttrueValue
- the value to match fortrue
, may benull
falseValue
- the value to match forfalse
, may benull
nullValue
- the value to to match fornull
, may benull
- Returns:
- Boolean.TRUE, Boolean.FALSE, or
null
- Throws:
java.lang.IllegalArgumentException
- if no match
-
toInteger
public static int toInteger(boolean bool)
Deprecated.Converts a boolean to an int using the convention that
zero
isfalse
.BooleanUtils.toInteger(true) = 1 BooleanUtils.toInteger(false) = 0
- Parameters:
bool
- the boolean to convert- Returns:
- one if
true
, zero iffalse
-
toIntegerObject
public static java.lang.Integer toIntegerObject(boolean bool)
Deprecated.Converts a boolean to an Integer using the convention that
zero
isfalse
.BooleanUtils.toIntegerObject(true) = new Integer(1) BooleanUtils.toIntegerObject(false) = new Integer(0)
- Parameters:
bool
- the boolean to convert- Returns:
- one if
true
, zero iffalse
-
toIntegerObject
public static java.lang.Integer toIntegerObject(java.lang.Boolean bool)
Deprecated.Converts a Boolean to a Integer using the convention that
zero
isfalse
.null
will be converted tonull
.BooleanUtils.toIntegerObject(Boolean.TRUE) = new Integer(1) BooleanUtils.toIntegerObject(Boolean.FALSE) = new Integer(0)
- Parameters:
bool
- the Boolean to convert- Returns:
- one if Boolean.TRUE, zero if Boolean.FALSE,
null
ifnull
-
toInteger
public static int toInteger(boolean bool, int trueValue, int falseValue)
Deprecated.Converts a boolean to an int specifying the conversion values.
BooleanUtils.toInteger(true, 1, 0) = 1 BooleanUtils.toInteger(false, 1, 0) = 0
- Parameters:
bool
- the to converttrueValue
- the value to return iftrue
falseValue
- the value to return iffalse
- Returns:
- the appropriate value
-
toInteger
public static int toInteger(java.lang.Boolean bool, int trueValue, int falseValue, int nullValue)
Deprecated.Converts a Boolean to an int specifying the conversion values.
BooleanUtils.toInteger(Boolean.TRUE, 1, 0, 2) = 1 BooleanUtils.toInteger(Boolean.FALSE, 1, 0, 2) = 0 BooleanUtils.toInteger(null, 1, 0, 2) = 2
- Parameters:
bool
- the Boolean to converttrueValue
- the value to return iftrue
falseValue
- the value to return iffalse
nullValue
- the value to return ifnull
- Returns:
- the appropriate value
-
toIntegerObject
public static java.lang.Integer toIntegerObject(boolean bool, java.lang.Integer trueValue, java.lang.Integer falseValue)
Deprecated.Converts a boolean to an Integer specifying the conversion values.
BooleanUtils.toIntegerObject(true, new Integer(1), new Integer(0)) = new Integer(1) BooleanUtils.toIntegerObject(false, new Integer(1), new Integer(0)) = new Integer(0)
- Parameters:
bool
- the to converttrueValue
- the value to return iftrue
, may benull
falseValue
- the value to return iffalse
, may benull
- Returns:
- the appropriate value
-
toIntegerObject
public static java.lang.Integer toIntegerObject(java.lang.Boolean bool, java.lang.Integer trueValue, java.lang.Integer falseValue, java.lang.Integer nullValue)
Deprecated.Converts a Boolean to an Integer specifying the conversion values.
BooleanUtils.toIntegerObject(Boolean.TRUE, new Integer(1), new Integer(0), new Integer(2)) = new Integer(1) BooleanUtils.toIntegerObject(Boolean.FALSE, new Integer(1), new Integer(0), new Integer(2)) = new Integer(0) BooleanUtils.toIntegerObject(null, new Integer(1), new Integer(0), new Integer(2)) = new Integer(2)
- Parameters:
bool
- the Boolean to converttrueValue
- the value to return iftrue
, may benull
falseValue
- the value to return iffalse
, may benull
nullValue
- the value to return ifnull
, may benull
- Returns:
- the appropriate value
-
toBooleanObject
public static java.lang.Boolean toBooleanObject(java.lang.String str)
Deprecated.Converts a String to a Boolean.
'true'
,'on'
or'yes'
(case insensitive) will returntrue
.'false'
,'off'
or'no'
(case insensitive) will returnfalse
. Otherwise,null
is returned.BooleanUtils.toBooleanObject(null) = null BooleanUtils.toBooleanObject("true") = Boolean.TRUE BooleanUtils.toBooleanObject("false") = Boolean.FALSE BooleanUtils.toBooleanObject("on") = Boolean.TRUE BooleanUtils.toBooleanObject("ON") = Boolean.TRUE BooleanUtils.toBooleanObject("off") = Boolean.FALSE BooleanUtils.toBooleanObject("oFf") = Boolean.FALSE BooleanUtils.toBooleanObject("blue") = null
- Parameters:
str
- the String to check- Returns:
- the Boolean value of the string,
null
if no match ornull
input
-
toBooleanObject
public static java.lang.Boolean toBooleanObject(java.lang.String str, java.lang.String trueString, java.lang.String falseString, java.lang.String nullString)
Deprecated.Converts a String to a Boolean throwing an exception if no match.
BooleanUtils.toBooleanObject("true", "true", "false", "null") = Boolean.TRUE BooleanUtils.toBooleanObject("false", "true", "false", "null") = Boolean.FALSE BooleanUtils.toBooleanObject("null", "true", "false", "null") = null
- Parameters:
str
- the String to checktrueString
- the String to match fortrue
(case sensitive), may benull
falseString
- the String to match forfalse
(case sensitive), may benull
nullString
- the String to match fornull
(case sensitive), may benull
- Returns:
- the Boolean value of the string,
null
if either the String matchesnullString
or ifnull
input andnullString
isnull
- Throws:
java.lang.IllegalArgumentException
- if the String doesn't match
-
toBoolean
public static boolean toBoolean(java.lang.String str)
Deprecated.Converts a String to a boolean (optimised for performance).
'true'
,'on'
or'yes'
(case insensitive) will returntrue
. Otherwise,false
is returned.This method performs 4 times faster (JDK1.4) than
Boolean.valueOf(String)
. However, this method accepts 'on' and 'yes' as true values.BooleanUtils.toBoolean(null) = false BooleanUtils.toBoolean("true") = true BooleanUtils.toBoolean("TRUE") = true BooleanUtils.toBoolean("tRUe") = true BooleanUtils.toBoolean("on") = true BooleanUtils.toBoolean("yes") = true BooleanUtils.toBoolean("false") = false BooleanUtils.toBoolean("x gti") = false
- Parameters:
str
- the String to check- Returns:
- the boolean value of the string,
false
if no match or the String is null
-
toBoolean
public static boolean toBoolean(java.lang.String str, java.lang.String trueString, java.lang.String falseString)
Deprecated.Converts a String to a Boolean throwing an exception if no match found.
null is returned if there is no match.
BooleanUtils.toBoolean("true", "true", "false") = true BooleanUtils.toBoolean("false", "true", "false") = false
- Parameters:
str
- the String to checktrueString
- the String to match fortrue
(case sensitive), may benull
falseString
- the String to match forfalse
(case sensitive), may benull
- Returns:
- the boolean value of the string
- Throws:
java.lang.IllegalArgumentException
- if the String doesn't match
-
toStringTrueFalse
public static java.lang.String toStringTrueFalse(java.lang.Boolean bool)
Deprecated.Converts a Boolean to a String returning
'true'
,'false'
, ornull
.BooleanUtils.toStringTrueFalse(Boolean.TRUE) = "true" BooleanUtils.toStringTrueFalse(Boolean.FALSE) = "false" BooleanUtils.toStringTrueFalse(null) = null;
- Parameters:
bool
- the Boolean to check- Returns:
'true'
,'false'
, ornull
-
toStringOnOff
public static java.lang.String toStringOnOff(java.lang.Boolean bool)
Deprecated.Converts a Boolean to a String returning
'on'
,'off'
, ornull
.BooleanUtils.toStringOnOff(Boolean.TRUE) = "on" BooleanUtils.toStringOnOff(Boolean.FALSE) = "off" BooleanUtils.toStringOnOff(null) = null;
- Parameters:
bool
- the Boolean to check- Returns:
'on'
,'off'
, ornull
-
toStringYesNo
public static java.lang.String toStringYesNo(java.lang.Boolean bool)
Deprecated.Converts a Boolean to a String returning
'yes'
,'no'
, ornull
.BooleanUtils.toStringYesNo(Boolean.TRUE) = "yes" BooleanUtils.toStringYesNo(Boolean.FALSE) = "no" BooleanUtils.toStringYesNo(null) = null;
- Parameters:
bool
- the Boolean to check- Returns:
'yes'
,'no'
, ornull
-
toString
public static java.lang.String toString(java.lang.Boolean bool, java.lang.String trueString, java.lang.String falseString, java.lang.String nullString)
Deprecated.Converts a Boolean to a String returning one of the input Strings.
BooleanUtils.toString(Boolean.TRUE, "true", "false", null) = "true" BooleanUtils.toString(Boolean.FALSE, "true", "false", null) = "false" BooleanUtils.toString(null, "true", "false", null) = null;
- Parameters:
bool
- the Boolean to checktrueString
- the String to return iftrue
, may benull
falseString
- the String to return iffalse
, may benull
nullString
- the String to return ifnull
, may benull
- Returns:
- one of the three input Strings
-
toStringTrueFalse
public static java.lang.String toStringTrueFalse(boolean bool)
Deprecated.Converts a boolean to a String returning
'true'
or'false'
.BooleanUtils.toStringTrueFalse(true) = "true" BooleanUtils.toStringTrueFalse(false) = "false"
- Parameters:
bool
- the Boolean to check- Returns:
'true'
,'false'
, ornull
-
toStringOnOff
public static java.lang.String toStringOnOff(boolean bool)
Deprecated.Converts a boolean to a String returning
'on'
or'off'
.BooleanUtils.toStringOnOff(true) = "on" BooleanUtils.toStringOnOff(false) = "off"
- Parameters:
bool
- the Boolean to check- Returns:
'on'
,'off'
, ornull
-
toStringYesNo
public static java.lang.String toStringYesNo(boolean bool)
Deprecated.Converts a boolean to a String returning
'yes'
or'no'
.BooleanUtils.toStringYesNo(true) = "yes" BooleanUtils.toStringYesNo(false) = "no"
- Parameters:
bool
- the Boolean to check- Returns:
'yes'
,'no'
, ornull
-
toString
public static java.lang.String toString(boolean bool, java.lang.String trueString, java.lang.String falseString)
Deprecated.Converts a boolean to a String returning one of the input Strings.
BooleanUtils.toString(true, "true", "false") = "true" BooleanUtils.toString(false, "true", "false") = "false"
- Parameters:
bool
- the Boolean to checktrueString
- the String to return iftrue
, may benull
falseString
- the String to return iffalse
, may benull
- Returns:
- one of the two input Strings
-
xor
public static boolean xor(boolean[] array)
Deprecated.Performs an xor on a set of booleans.
BooleanUtils.xor(new boolean[] { true, true }) = false BooleanUtils.xor(new boolean[] { false, false }) = false BooleanUtils.xor(new boolean[] { true, false }) = true
- Parameters:
array
- an array ofboolean
s
- Returns:
true
if the xor is successful.- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty.
-
xor
public static java.lang.Boolean xor(java.lang.Boolean[] array)
Deprecated.Performs an xor on an array of Booleans.
BooleanUtils.xor(new Boolean[] { Boolean.TRUE, Boolean.TRUE }) = Boolean.FALSE BooleanUtils.xor(new Boolean[] { Boolean.FALSE, Boolean.FALSE }) = Boolean.FALSE BooleanUtils.xor(new Boolean[] { Boolean.TRUE, Boolean.FALSE }) = Boolean.TRUE
- Parameters:
array
- an array ofBoolean
s
- Returns:
true
if the xor is successful.- Throws:
java.lang.IllegalArgumentException
- ifarray
isnull
java.lang.IllegalArgumentException
- ifarray
is empty.java.lang.IllegalArgumentException
- ifarray
contains anull
-
-