Here you can find the source of castBoolean(Object o, boolean defaultValue)
public static boolean castBoolean(Object o, boolean defaultValue)
//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); } }