MCPcopy Create free account
hub / github.com/grpc/grpc-java / getObject

Method getObject

core/src/main/java/io/grpc/internal/JsonUtil.java:83–96  ·  view source on GitHub ↗

Gets an object from an object for the given key. If the key is not present, this returns null. If the value is not a Map, throws an exception.

(Map<String, ?> obj, String key)

Source from the content-addressed store, hash-verified

81 * If the value is not a Map, throws an exception.
82 */
83 @SuppressWarnings("unchecked")
84 @Nullable
85 public static Map<String, ?> getObject(Map<String, ?> obj, String key) {
86 assert key != null;
87 if (!obj.containsKey(key)) {
88 return null;
89 }
90 Object value = obj.get(key);
91 if (!(value instanceof Map)) {
92 throw new ClassCastException(
93 String.format("value '%s' for key '%s' in '%s' is not object", value, key, obj));
94 }
95 return (Map<String, ?>) value;
96 }
97
98 /**
99 * Gets a number from an object for the given key. If the key is not present, this returns null.

Calls 2

containsKeyMethod · 0.80
getMethod · 0.65