@Test public void testGetKeyedLong() { assertEquals(7L, ParameterMap.getKeyedLong(m_map, "keyedLong", 3L)); assertEquals(7L, ParameterMap.getKeyedLong(m_map, "keyedLongString", 3L)); assertEquals(3L, ParameterMap.getKeyedLong(m_map, "noSuchKey", 3L)); assertEquals(3L, ParameterMap.getKeyedLong(null, "keyedLong", 3L)); }
@SuppressWarnings("unchecked") public static long getKeyedLong(@SuppressWarnings("rawtypes") final Map map, final String key, final long defValue) { if (map == null) return defValue; long value = defValue; Object oValue = map.get(key); if (oValue != null && oValue instanceof String) { try { value = Long.parseLong((String) oValue); } catch (NumberFormatException ne) { value = defValue; LogUtils.infof(ParameterMap.class, ne, "getKeyedLong: Failed to convert value %s for key %s", oValue , key); } map.put(key, new Long(value)); } else if (oValue != null) { value = ((Number) oValue).longValue(); } return value; }
ParameterMap { @SuppressWarnings("unchecked") public static long getKeyedLong(@SuppressWarnings("rawtypes") final Map map, final String key, final long defValue) { if (map == null) return defValue; long value = defValue; Object oValue = map.get(key); if (oValue != null && oValue instanceof String) { try { value = Long.parseLong((String) oValue); } catch (NumberFormatException ne) { value = defValue; LogUtils.infof(ParameterMap.class, ne, "getKeyedLong: Failed to convert value %s for key %s", oValue , key); } map.put(key, new Long(value)); } else if (oValue != null) { value = ((Number) oValue).longValue(); } return value; } }
ParameterMap { @SuppressWarnings("unchecked") public static long getKeyedLong(@SuppressWarnings("rawtypes") final Map map, final String key, final long defValue) { if (map == null) return defValue; long value = defValue; Object oValue = map.get(key); if (oValue != null && oValue instanceof String) { try { value = Long.parseLong((String) oValue); } catch (NumberFormatException ne) { value = defValue; LogUtils.infof(ParameterMap.class, ne, "getKeyedLong: Failed to convert value %s for key %s", oValue , key); } map.put(key, new Long(value)); } else if (oValue != null) { value = ((Number) oValue).longValue(); } return value; }  }
ParameterMap { @SuppressWarnings("unchecked") public static long getKeyedLong(@SuppressWarnings("rawtypes") final Map map, final String key, final long defValue) { if (map == null) return defValue; long value = defValue; Object oValue = map.get(key); if (oValue != null && oValue instanceof String) { try { value = Long.parseLong((String) oValue); } catch (NumberFormatException ne) { value = defValue; LogUtils.infof(ParameterMap.class, ne, "getKeyedLong: Failed to convert value %s for key %s", oValue , key); } map.put(key, new Long(value)); } else if (oValue != null) { value = ((Number) oValue).longValue(); } 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 long getKeyedLong(@SuppressWarnings("rawtypes") final Map map, final String key, final long defValue) { if (map == null) return defValue; long value = defValue; Object oValue = map.get(key); if (oValue != null && oValue instanceof String) { try { value = Long.parseLong((String) oValue); } catch (NumberFormatException ne) { value = defValue; LogUtils.infof(ParameterMap.class, ne, "getKeyedLong: Failed to convert value %s for key %s", oValue , key); } map.put(key, new Long(value)); } else if (oValue != null) { value = ((Number) oValue).longValue(); } 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);  }