Java Object to Boolean castBoolean(Object o, boolean defaultValue)

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

Description

cast Boolean

License

Apache License

Declaration

public static boolean castBoolean(Object o, boolean defaultValue) 

Method Source Code

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

public class Main {

    public static boolean castBoolean(Object o) {
        return castBoolean(o, false);
    }/* w  w w.  j  ava2 s.  c o m*/

    public static boolean castBoolean(Object o, boolean defaultValue) {
        boolean booleanValue = defaultValue;
        if (o != null) {
            booleanValue = Boolean.parseBoolean(castString(o));
        }
        return booleanValue;
    }

    public static String castString(Object o) {
        return castString(o, "");
    }

    public static String castString(Object o, String defaultValue) {
        return o == null ? defaultValue : String.valueOf(o);
    }
}

Related

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