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

Method getFloat

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

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

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

Source from the content-addressed store, hash-verified

481 * @throws IllegalArgumentException If value cannot be converted to double
482 */
483 public static Float getFloat(Map<String, Object> map, String key) throws IllegalArgumentException {
484 Object value = map == null || key == null ? null : map.get(key);
485 if (value == null) {
486 return null;
487 }
488
489 if (value instanceof Number) {
490 return ((Number) value).floatValue();
491 }
492
493 if (value instanceof String) {
494 try {
495 return Float.parseFloat((String) value);
496 } catch (NumberFormatException e) {
497 throw new IllegalArgumentException("Cannot convert String value '" + value + "' to double: " + e.getMessage());
498 }
499 }
500
501 throw new IllegalArgumentException("Cannot convert value of type " + value.getClass().getName() + " to double");
502 }
503
504 /**
505 * Get a double value from a Map

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected