Java Boolean From toBoolean(Object value)

Here you can find the source of toBoolean(Object value)

Description

Convert an Object to a Boolean.

License

Apache License

Declaration

public static Boolean toBoolean(Object value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from w  w  w.  j a va2s .c  o  m
     * Convert an Object to a Boolean.
     */
    public static Boolean toBoolean(Object value) {
        if (value == null)
            return false;
        //return null;
        if (value instanceof Boolean)
            return (Boolean) value;

        if ("TRUE".equalsIgnoreCase(value.toString()))
            return Boolean.TRUE;
        if ("".equals(value.toString()))
            return false;
        //return null;

        return Boolean.FALSE;
    }
}

Related

  1. toBoolean(Object val, boolean defValue)
  2. toBoolean(Object value)
  3. toBoolean(Object value)
  4. toBoolean(Object value)
  5. toBoolean(Object value)
  6. toBoolean(Object value)
  7. toBoolean(Object value)
  8. toBoolean(Object value, Boolean defaultValue)
  9. toBoolean(Object value, boolean defaultValue)