Here you can find the source of castBoolean(Object obj)
public static boolean castBoolean(Object obj)
//package com.java2s; //License from project: Apache License public class Main { public static boolean castBoolean(Object obj, boolean defaultValue) { boolean booleanValue = defaultValue; if (obj != null) { booleanValue = Boolean.parseBoolean(castString(obj)); }/*from www . ja va2s. c o m*/ return booleanValue; } public static boolean castBoolean(Object obj) { return castBoolean(obj, false); } public static String castString(Object obj, String defaultValue) { return obj != null ? String.valueOf(obj) : defaultValue; } public static String castString(Object obj) { return castString(obj, ""); } }