Java Object to Boolean asBoolean(Object value)

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

Description

as Boolean

License

Open Source License

Declaration

public static boolean asBoolean(Object value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static boolean asBoolean(Object value) {
        if (value == null)
            throw new NullPointerException("value is null");
        if (value instanceof Boolean) {
            return ((Boolean) value).booleanValue();
        }//ww w .  j  a  v a 2 s  . c o m
        throw new IllegalArgumentException("not a boolean");
    }

    public static boolean asBoolean(Object value, boolean def) {
        if (value == null)
            return def;
        if (value instanceof Boolean) {
            return ((Boolean) value).booleanValue();
        }
        throw new IllegalArgumentException("not a boolean");
    }
}

Related

  1. asBoolean(Object obj)
  2. asBoolean(Object obj)
  3. asBoolean(Object object)
  4. asBoolean(Object value)
  5. asBoolean(Object value)
  6. castBoolean(Object inObject)
  7. castBoolean(Object o)
  8. castBoolean(Object o)