Coerce to a boolean (not a java.lang.Boolean).

@param val
Object to be coerced.
@return The boolean coerced value, or false if none possible.
971226
public boolean toBoolean(Object val) {
    if (val == null) {
      return false;
    }
    else if (val instanceof Boolean) {
      return ((Boolean) val).booleanValue();
    }
    else if (val instanceof Number) {
      double number = toDouble(val);
      return !Double.isNaN(number) && number != 0.d;
    }
    else if (val instanceof String) {
      String strval = val.toString();
      return strval.length() > 0 && !"false".equals(strval);
    }
    else if (val instanceof Collection<?>) {
      Collection<?> collval = (Collection<?>) val;
      return collval.isEmpty();
    }
    return false;
  }
247126
public static boolean getBoolean(
    Object  value)
  {
    if (value == null)
    {
        return false;
    }
    
    if (value instanceof Boolean)
    {
        return ((Boolean) value).booleanValue();
    }

    return Boolean.valueOf(value.toString()).booleanValue();
  }
941932
public boolean getBoolean(String property) {
    return getProperty(property, value -> {
      switch (value.trim().toLowerCase()) {
        case "true":
        case "1":
          return true;
        case "false":
        case "0":
          return false;
        default:
          throw new ConfigurationException("invalid property value: " + property + " must be a boolean");
      }
    });
  }
830417
public Boolean getAsBoolean(String key) {
        Object value = mValues.get(key);
        try {
            return (Boolean) value;
        } catch (ClassCastException e) {
            if (value instanceof CharSequence) {
                return Boolean.valueOf(value.toString());
            } else if (value instanceof Number) {
                return ((Number) value).intValue() != 0;
            } else {
                logger.log(Level.SEVERE, "Cannot cast value for " + key + " to a Boolean: " + value, e);
                return false;
            }
        }
    }
1277444
public static Boolean convertBoolean(JsonNode node) {
        if (node instanceof POJONode) {
            return convertBoolean(DPathUtils.extractValue((POJONode) node));
        }
        boolean value = node.isBoolean() ? node.asBoolean()
                : node.isTextual() ? Boolean.parseBoolean(node.asText()) : false;
        return Boolean.valueOf(value);
    }
823193
public Object bitwiseComplement(Object val) {
    long l = toLong(val);
    return Long.valueOf(~l);
  }
877673
public static boolean toBoolean(Object value, boolean defaultValue) {
		boolean result;// = defaultValue;
		if (value != null) {
			if (value instanceof Boolean) {
				return ((Boolean) value).booleanValue();
			}

			if (value.toString().trim().equals("1") || value.toString().trim().toLowerCase().equals("true")) {
				result = true;
			} else {
				result = false;
			}
		} else {
			result = defaultValue;
		}
		return result;

	}
886680
public String setValue(String val) {
        String oldVal = this.val;
        if (parent != null) {
            oldVal = parent.get(this.key); // trust the container more
            int i = parent.indexOfKey(this.key);
            if (i != Attributes.NotFound)
                parent.vals[i] = val;
        }
        this.val = val;
        return Attributes.checkNotNull(oldVal);
    }
1288075
public boolean getToBoolean() {

        if (m_boolean == null) {
            m_boolean = Boolean.valueOf(Boolean.parseBoolean(getToString()));
        }
        return m_boolean.booleanValue();
    }
506616
private function setRealBoolean(string $val):bool
    {
        if ($val === "true") {
            $val = true;
        } else {
            $val = false;
        }
        return ($val);
    }
789397
public boolean getBoolean(int index, boolean def) {
        Object tmp = mArray.get(index);
        return tmp != null && tmp instanceof Boolean ? ((Boolean) tmp)
                .booleanValue() : def;
    }
593162
public boolean getBooleanValue() throws IOException, SaneException {
    Preconditions.checkState(getValueType() == OptionValueType.BOOLEAN, "option is not a boolean");
    Preconditions.checkState(getValueCount() == 1, "option is a boolean array, not boolean");

    ControlOptionResult result = readOption();
    return SaneWord.fromBytes(result.getValue()).integerValue() != 0;
  }
1194588
protected function Eq( $val )
	{
		if ( ! $val instanceof BoolProxy ) return false;
		return  ( $this->_value instanceof CoreFuncs::$False && $val->getValue() instanceof CoreFuncs::$False ) ||
				( $this->_value instanceof CoreFuncs::$True && $val->getValue() instanceof CoreFuncs::$True ) ||
				( is_bool( $this->_value ) && is_bool( $val->getValue() ) && $this->_value == $val->getValue() );
		// return $this->_value == (bool)$val->_value;
	}
1018745
public static boolean isISODateTime(final String val) throws BadDateException {
    try {
      if (val.length() != 15) {
        return false;
      }
      fromISODateTime(val);
      return true;
    } catch (Throwable t) {
      return false;
    }
  }
1142666
function boolean(value) {
  var parsedBoolean = json(value);

  // handle 0|1 case
  if (typeOf(parsedBoolean) == 'number' && [0, 1].indexOf(parsedBoolean) > -1) {
    parsedBoolean = parsedBoolean === 0 ? false : true;
  }

  // couldn't parse it
  if (typeOf(parsedBoolean) != 'boolean') {
    return throwModifierError('boolean', value, {message: 'Invalid Boolean'});
  }

  return parsedBoolean;
}
168439
def _convert_to_boolean(self, value):
        
        if value.lower() not in self.BOOLEAN_STATES:
            raise ValueError('Not a boolean: %s' % value)
        return self.BOOLEAN_STATES[value.lower()]
788839
protected static boolean isNull(Object val) {
    return (val == null) || STRING_NULL.equals(val) || DOUBLE_NULL.equals(val) || INTEGER_NULL.equals(val);
  }