Java Utililty Methods Object to Boolean

List of utility methods to do Object to Boolean

Description

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

Method

booleancastBoolean(Object obj)
cast Boolean
return castBoolean(obj, false);
BooleancastToBoolean(Object value)
cast To Boolean
if (value == null) {
    return null;
if (value instanceof Boolean) {
    return (Boolean) value;
if (value instanceof Number) {
    return ((Number) value).intValue() > 0;
...
BooleancastToBoolean(Object value)
cast To Boolean
return (Boolean) value;
booleancastToBoolean(String fieldValue)
Cast a string representation of a boolean value to a boolean primitive.
String lowerField = fieldValue.toLowerCase();
switch (lowerField) {
case "y":
    return true;
case "n":
    return false;
case "true":
    return true;
...
booleanobjectToBoolean(Object o)
object To Boolean
return o != null ? Boolean.valueOf(o.toString()).booleanValue() : false;
booleanobjectToBoolean(Object o)
object To Boolean
if (o instanceof String) {
    return Boolean.parseBoolean((String) o);
} else if (o instanceof Boolean) {
    return ((Boolean) o).booleanValue();
} else {
    throw new Exception("Invalid option value " + o);
booleanobjectToBoolean(Object Obj)
object To Boolean
String CadBooleana = objectToString(Obj);
Boolean booleano = new Boolean(CadBooleana);
return booleano;
booleanobjectToBoolean(Object p1)
object To Boolean
if (p1 == null) {
    return false;
return (boolean) (Boolean) p1;
BooleantoBoolean(Object object)
to Boolean
if (null == object) {
    throw new IllegalArgumentException("object can't be null/empty!");
return Boolean.parseBoolean(object.toString());
booleantoBoolean(Object propValue, boolean defaultValue)
to Boolean
propValue = toObject(propValue);
if (propValue instanceof Boolean)
    return (Boolean) propValue;
if (propValue != null)
    return Boolean.valueOf(String.valueOf(propValue));
else
    return defaultValue;