/** * Returns an Boolean from the defaults. If the value for {@code key} is not * a {@code boolean}, {@code false} is returned. * * @param key * an {@code Object} specifying the Boolean * @return the {@code boolean} * @throws NullPointerException * if {@code key} is {@code null} */ public static boolean getBoolean(Object key) { return getBoolean(key, null); }
/** * Returns an Boolean from the defaults. If the value for {@code key} is not * a {@code boolean}, {@code false} is returned. * * @param key * an {@code Object} specifying the Boolean * @return the {@code boolean} * @throws NullPointerException * if {@code key} is {@code null} */ public static boolean getBoolean(Object key) { return getBoolean(key, null); }
/** * Returns an Boolean from the defaults. If the value for {@code key} is not * a {@code boolean}, {@code false} is returned. * * @param key * an {@code Object} specifying the Boolean * @return the {@code boolean} * @throws NullPointerException * if {@code key} is {@code null} */ public static boolean getBoolean(Object key) { return getBoolean(key, null); }
/** * Returns an Boolean from the defaults. If the value for {@code key} is not * a {@code boolean}, {@code false} is returned. * * @param key * an {@code Object} specifying the Boolean * @return the {@code boolean} * @throws NullPointerException * if {@code key} is {@code null} */ public static boolean getBoolean(Object key) { return getBoolean(key, null); }
/** * test that the getBoolean doesn't choke on non-Booleans */ @Test public void testGetBooleanLenientWithUnparseable() { String key = "badBoolean"; Locale locale = JComponent.getDefaultLocale(); String columnString = UIManagerExt.getString(key, locale); if (columnString == null) { LOG.info("cant run test - no resource found for key: " + key); return; } UIManagerExt.getBoolean(key, locale); }
/** * test that we get a boolean from the localized resource. */ @Test public void testGetBooleanFromResource() { String key = "goodBoolean"; Locale locale = JComponent.getDefaultLocale(); String columnString = UIManagerExt.getString(key, locale); if (columnString == null) { LOG.info("cant run test - no resource found for key: " + key); return; } Object value = UIManagerExt.getBoolean(key, locale); assertNotNull(value); assertEquals(Boolean.valueOf(columnString), value); }
/** * test that a value in the UIManager is not overwritten. */ @Test public void testGetBooleanUIManagerFirst() { String key = "goodBoolean"; Locale locale = JComponent.getDefaultLocale(); String columnString = UIManagerExt.getString(key, locale); if (columnString == null) { LOG.info("cant run test - no resource found for key: " + key); return; } try { Boolean temp = true; UIManager.put(key, temp); Object value = UIManagerExt.getBoolean(key, locale); assertNotNull(value); assertEquals(temp, value); } finally { // restore uimanager UIManager.put(key, null); } }