List of utility methods to do Object to Boolean
Boolean | asBoolean(Object obj) as Boolean return asBoolean(obj, false);
|
Boolean | asBoolean(Object obj) as Boolean Boolean result = Boolean.FALSE; if (obj != null) { if (obj instanceof Boolean) { result = (Boolean) obj; } else if (obj instanceof String) { result = Boolean.valueOf("true".equalsIgnoreCase((String) obj) || "1".equals((String) obj)); return result; |
Boolean | asBoolean(Object object) return Object value as Boolean if (object == null) { return null; } else if (object instanceof Boolean) { return (Boolean) object; } else if (object instanceof String) { return Boolean.valueOf((String) object); return null; ... |
Boolean | asBoolean(Object value) as Boolean return Boolean.valueOf(asString(value));
|
boolean | asBoolean(Object value) convert a object value to boolean value. if (value instanceof Boolean) return ((Boolean) value).booleanValue(); if (value instanceof Number) { return ((Number) value).intValue() > 0; } else { String boolString = (String) value; return boolString != null && !boolString.equals("") && !boolString.equalsIgnoreCase("false"); |
boolean | asBoolean(Object value) as Boolean if (value == null) throw new NullPointerException("value is null"); if (value instanceof Boolean) { return ((Boolean) value).booleanValue(); throw new IllegalArgumentException("not a boolean"); |
Boolean | castBoolean(Object inObject) cast Boolean return castBoolean(inObject, null);
|
Boolean | castBoolean(Object o) cast Boolean if (o instanceof Boolean) { return (Boolean) o; } else if (o instanceof String) { try { return Boolean.parseBoolean((String) o); } catch (IllegalArgumentException e) { return null; return null; |
Boolean | castBoolean(Object o) cast Boolean if (o == null) { return false; } else if (o instanceof Boolean) { return (Boolean) o; } else if (o instanceof String) { return ((String) o).equalsIgnoreCase("true") ? true : false; } else { return false; ... |
boolean | castBoolean(Object o, boolean defaultValue) cast Boolean boolean booleanValue = defaultValue; if (o != null) { booleanValue = Boolean.parseBoolean(castString(o)); return booleanValue; |