Java Object to Boolean castBoolean(Object o)

Here you can find the source of castBoolean(Object o)

Description

cast Boolean

License

Open Source License

Declaration

public static Boolean castBoolean(Object o) 

Method Source Code

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

public class Main {
    public static Boolean castBoolean(Object o) {
        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 {//from w  w  w. j  a v  a 2 s .  c  om
            return false;
        }
    }
}

Related

  1. asBoolean(Object value)
  2. asBoolean(Object value)
  3. asBoolean(Object value)
  4. castBoolean(Object inObject)
  5. castBoolean(Object o)
  6. castBoolean(Object o, boolean defaultValue)
  7. castBoolean(Object obj)
  8. castToBoolean(Object value)
  9. castToBoolean(Object value)