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(byte[] bytes, int offset)
to Boolean
if (offset >= bytes.length) {
    throw new RuntimeException("Cannot decode boolean from the buffer");
return bytes[offset] != (byte) 0;
booleantoBoolean(byte[] data, int offset)
to Boolean
return (data[offset] == 1);
booleantoBoolean(byte[] value)
byte[] -> boolean
return (value == null || value.length == 0) ? false : value[0] != 0x00;
BooleantoBoolean(char c)
convert 'y', or 'n' to boolean
switch (c) {
case 'y':
    return true;
case 'n':
    return false;
default:
    return null;
booleantoBoolean(double value)
to Boolean
return value != 0.0;
booleantoBoolean(final Boolean bool)
Method to convert Boolean object to boolean primitive
return bool != null && bool.booleanValue();
booleantoBoolean(final Boolean bool)

Converts a Boolean to a boolean handling null by returning false .

return bool != null && bool.booleanValue();
booleantoBoolean(final byte[] b)
Reverses #toBytes(boolean)
if (b.length != 1) {
    throw new IllegalArgumentException("Array has wrong size: " + b.length);
return b[0] != (byte) 0;
booleantoBoolean(final Object obj, final boolean defaultValue)
to Boolean
boolean result = defaultValue;
if (obj != null) {
    if (obj instanceof Boolean) {
        result = ((Boolean) obj).booleanValue();
    } else {
        result = Boolean.valueOf(String.valueOf(obj));
return result;
booleantoBoolean(final Object value)
To boolean.
boolean result = false;
if (value != null) {
    if (value.toString().trim().equals("1") || value.toString().trim().toLowerCase().equals("true")) {
        result = true;
    } else {
        result = false;
} else {
...