MCPcopy Index your code
hub / github.com/Tencent/APIJSON / getLong

Method getLong

APIJSONORM/src/main/java/apijson/JSON.java:427–446  ·  view source on GitHub ↗

Get an int value from a Map @param map Source map @param key The key @return The int value @throws IllegalArgumentException If value cannot be converted to int

(Map<String, Object> map, String key)

Source from the content-addressed store, hash-verified

425 * @throws IllegalArgumentException If value cannot be converted to int
426 */
427 public static Long getLong(Map<String, Object> map, String key) throws IllegalArgumentException {
428 Object value = map == null || key == null ? null : map.get(key);
429 if (value == null) {
430 return null;
431 }
432
433 if (value instanceof Number) {
434 return ((Number) value).longValue();
435 }
436
437 if (value instanceof String) {
438 try {
439 return Long.parseLong((String) value);
440 } catch (NumberFormatException e) {
441 throw new IllegalArgumentException("Cannot convert String value '" + value + "' to int: " + e.getMessage());
442 }
443 }
444
445 throw new IllegalArgumentException("Cannot convert value of type " + value.getClass().getName() + " to int");
446 }
447
448 /**
449 * Get a long value from a Map

Callers 2

executeMethod · 0.80
executeUpdateMethod · 0.80

Calls 2

getMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected