@Test public void testGetKeyedBoolean() { assertEquals(true, ParameterMap.getKeyedBoolean(m_map, "keyedBoolean", false)); assertEquals(true, ParameterMap.getKeyedBoolean(m_map, "keyedBooleanString", false)); assertEquals(false, ParameterMap.getKeyedBoolean(m_map, "noSuchKey", false)); assertEquals(false, ParameterMap.getKeyedBoolean(null, "keyedBoolean", false)); }
@SuppressWarnings("unchecked") public static boolean getKeyedBoolean(@SuppressWarnings("rawtypes") final Map map, final String key, final boolean defValue) { if (map == null) return defValue; boolean value = defValue; Object oValue = map.get(key); if (oValue != null && oValue instanceof String) { oValue = Boolean.valueOf((String) oValue); } if (oValue != null && oValue instanceof Boolean) { try { value = ((Boolean) oValue).booleanValue(); } catch (NumberFormatException ne) { value = defValue; LogUtils.infof(ParameterMap.class, ne, "getKeyedBoolean: Failed to convert value %s for key %s", oValue, key); } map.put(key, Boolean.valueOf(value)); } else if (oValue != null) { value = ((Boolean) oValue).booleanValue(); } return value; }
ParameterMap { @SuppressWarnings("unchecked") public static boolean getKeyedBoolean(@SuppressWarnings("rawtypes") final Map map, final String key, final boolean defValue) { if (map == null) return defValue; boolean value = defValue; Object oValue = map.get(key); if (oValue != null && oValue instanceof String) { oValue = Boolean.valueOf((String) oValue); } if (oValue != null && oValue instanceof Boolean) { try { value = ((Boolean) oValue).booleanValue(); } catch (NumberFormatException ne) { value = defValue; LogUtils.infof(ParameterMap.class, ne, "getKeyedBoolean: Failed to convert value %s for key %s", oValue, key); } map.put(key, Boolean.valueOf(value)); } else if (oValue != null) { value = ((Boolean) oValue).booleanValue(); } return value; } }
ParameterMap { @SuppressWarnings("unchecked") public static boolean getKeyedBoolean(@SuppressWarnings("rawtypes") final Map map, final String key, final boolean defValue) { if (map == null) return defValue; boolean value = defValue; Object oValue = map.get(key); if (oValue != null && oValue instanceof String) { oValue = Boolean.valueOf((String) oValue); } if (oValue != null && oValue instanceof Boolean) { try { value = ((Boolean) oValue).booleanValue(); } catch (NumberFormatException ne) { value = defValue; LogUtils.infof(ParameterMap.class, ne, "getKeyedBoolean: Failed to convert value %s for key %s", oValue, key); } map.put(key, Boolean.valueOf(value)); } else if (oValue != null) { value = ((Boolean) oValue).booleanValue(); } return value; }  }
ParameterMap { @SuppressWarnings("unchecked") public static boolean getKeyedBoolean(@SuppressWarnings("rawtypes") final Map map, final String key, final boolean defValue) { if (map == null) return defValue; boolean value = defValue; Object oValue = map.get(key); if (oValue != null && oValue instanceof String) { oValue = Boolean.valueOf((String) oValue); } if (oValue != null && oValue instanceof Boolean) { try { value = ((Boolean) oValue).booleanValue(); } catch (NumberFormatException ne) { value = defValue; LogUtils.infof(ParameterMap.class, ne, "getKeyedBoolean: Failed to convert value %s for key %s", oValue, key); } map.put(key, Boolean.valueOf(value)); } else if (oValue != null) { value = ((Boolean) oValue).booleanValue(); } return value; }  @SuppressWarnings("unchecked") static long getKeyedLong(@SuppressWarnings("rawtypes") final Map map, final String key, final long defValue); static int getKeyedInteger(@SuppressWarnings("rawtypes") final Map map, final String key, final int defValue); @SuppressWarnings("unchecked") final static int[] getKeyedIntegerArray(@SuppressWarnings("rawtypes") final Map map, final String key, final int[] defValues); @SuppressWarnings("unchecked") static String getKeyedString(@SuppressWarnings("rawtypes") final Map map, final String key, final String defValue); @SuppressWarnings("unchecked") static boolean getKeyedBoolean(@SuppressWarnings("rawtypes") final Map map, final String key, final boolean defValue); static T getKeyedValue(final Map<String,T> map, final String key, final T defValue); }
ParameterMap { @SuppressWarnings("unchecked") public static boolean getKeyedBoolean(@SuppressWarnings("rawtypes") final Map map, final String key, final boolean defValue) { if (map == null) return defValue; boolean value = defValue; Object oValue = map.get(key); if (oValue != null && oValue instanceof String) { oValue = Boolean.valueOf((String) oValue); } if (oValue != null && oValue instanceof Boolean) { try { value = ((Boolean) oValue).booleanValue(); } catch (NumberFormatException ne) { value = defValue; LogUtils.infof(ParameterMap.class, ne, "getKeyedBoolean: Failed to convert value %s for key %s", oValue, key); } map.put(key, Boolean.valueOf(value)); } else if (oValue != null) { value = ((Boolean) oValue).booleanValue(); } return value; }  @SuppressWarnings("unchecked") static long getKeyedLong(@SuppressWarnings("rawtypes") final Map map, final String key, final long defValue); static int getKeyedInteger(@SuppressWarnings("rawtypes") final Map map, final String key, final int defValue); @SuppressWarnings("unchecked") final static int[] getKeyedIntegerArray(@SuppressWarnings("rawtypes") final Map map, final String key, final int[] defValues); @SuppressWarnings("unchecked") static String getKeyedString(@SuppressWarnings("rawtypes") final Map map, final String key, final String defValue); @SuppressWarnings("unchecked") static boolean getKeyedBoolean(@SuppressWarnings("rawtypes") final Map map, final String key, final boolean defValue); static T getKeyedValue(final Map<String,T> map, final String key, final T defValue);  }