PropertiesUtil { public static boolean toBoolean(Object propValue, boolean defaultValue) { propValue = toObject(propValue); if (propValue instanceof Boolean) { return (Boolean) propValue; } else if (propValue != null) { return Boolean.parseBoolean(String.valueOf(propValue)); } return defaultValue; } private  PropertiesUtil(); static boolean toBoolean(Object propValue, boolean defaultValue); static String toString(Object propValue, String defaultValue); static long toLong(Object propValue, long defaultValue); static int toInteger(Object propValue, int defaultValue); static double toDouble(Object propValue, double defaultValue); static Object toObject(Object propValue); static String[] toStringArray(Object propValue); static String[] toStringArray(Object propValue, String[] defaultArray); @SuppressWarnings("unchecked") static void populate(Object instance, Map<String,?> config, boolean validate);  }
@Test public void testToBoolean() { assertEquals(true, PropertiesUtil.toBoolean(null, true)); assertEquals(false, PropertiesUtil.toBoolean(1.0, true)); assertEquals(false, PropertiesUtil.toBoolean(false, true)); assertEquals(false, PropertiesUtil.toBoolean("false", true)); assertEquals(false, PropertiesUtil.toBoolean("abc", true)); }