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

Method getString

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

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

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

Source from the content-addressed store, hash-verified

215 * If the value is not a String, throws an exception.
216 */
217 @Nullable
218 public static String getString(Map<String, ?> obj, String key) {
219 assert key != null;
220 if (!obj.containsKey(key)) {
221 return null;
222 }
223 Object value = obj.get(key);
224 if (!(value instanceof String)) {
225 throw new ClassCastException(
226 String.format("value '%s' for key '%s' in '%s' is not String", value, key, obj));
227 }
228 return (String) value;
229 }
230
231 /**
232 * Gets a string from an object for the given key, parsed as a duration (defined by protobuf). If

Callers 15

doForwardMethod · 0.95
convertMethod · 0.95
checkJwkEntryMethod · 0.95
getServiceFromNameMethod · 0.95
getMethodFromNameMethod · 0.95
getStringAsDurationMethod · 0.95
parseHeaderMethod · 0.95
parseRulesMethod · 0.95

Calls 2

containsKeyMethod · 0.80
getMethod · 0.65

Tested by 6

setUpMethod · 0.64
setUpMethod · 0.64