Java Utililty Methods Boolean From

List of utility methods to do Boolean From

Description

The list of methods to do Boolean From are organized into topic(s).

Method

booleantoBoolean(final String value)
To boolean.
return toBoolean(value, DEFAULT_VALUE);
booleantoBoolean(final String value)
Helper method.
return value.equalsIgnoreCase(STRING_TRUE) || value.equalsIgnoreCase(STRING_YES)
        || value.equalsIgnoreCase(STRING_ENABLED);
booleantoBoolean(final String value, final boolean def)
to Boolean
if (isEmpty(value)) {
    return def;
return Boolean.parseBoolean(value);
booleantoBoolean(int i)
Converts a primitive integer to a boolean by using it's value as a marker for the boolean value.
return i > 0;
booleantoBoolean(int value)
Converts a int to a boolean.
return value != 0;
booleantoBoolean(Integer value, Integer trueValue, Integer falseValue)

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 
if (value == null) {
    if (trueValue == null) {
        return true;
    } else if (falseValue == null) {
        return false;
} else if (value.equals(trueValue)) {
    return true;
...
booleantoBoolean(Number value)
to Boolean
return value.intValue() != 0;
BooleantoBoolean(Object anObj)
Converts parameter to Boolean.
Boolean tmpResult = null;
if (anObj == null) {
} else if (anObj instanceof Boolean) {
    tmpResult = (Boolean) anObj;
} else {
    final String tmpStr = toString(anObj);
    if ("true".equalsIgnoreCase(tmpStr) || "yes".equalsIgnoreCase(tmpStr)
            || "on".equalsIgnoreCase(tmpStr)) {
...
booleantoBoolean(Object bool)
to Boolean
if (bool == null)
    return false;
if (bool instanceof Boolean) {
    boolean b = ((Boolean) bool).booleanValue();
    return b;
bool = bool.toString();
if (bool.equals("true") || bool.equals("y") || bool.equals("on") || bool.equals("1"))
...
BooleantoBoolean(Object o)
to Boolean
if (o == null)
    return null;
if (o.getClass() == Boolean.class)
    return (Boolean) o;
if (o.getClass() == Byte.class)
    return byteToBoolean(((Byte) o));
if (o.getClass() == Character.class)
    return charToBoolean(((Character) o));
...