Here you can find the source of toBoolean(Object propValue, boolean defaultValue)
public static boolean toBoolean(Object propValue, boolean defaultValue)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static boolean toBoolean(Object propValue, boolean defaultValue) { propValue = toObject(propValue); if (propValue instanceof Boolean) return (Boolean) propValue; if (propValue != null) return Boolean.valueOf(String.valueOf(propValue)); else/*from w ww . j a v a2s. c om*/ return defaultValue; } public static Object toObject(Object propValue) { if (propValue == null) { return null; } if (propValue.getClass().isArray()) { Object prop[] = (Object[]) propValue; return prop.length <= 0 ? null : prop[0]; } if (propValue instanceof Collection) { Collection prop = (Collection) propValue; return prop.isEmpty() ? null : prop.iterator().next(); } else { return propValue; } } }