MCPcopy
hub / github.com/google/gson / nextBoolean

Method nextBoolean

src/main/java/com/google/gson/stream/JsonReader.java:477–494  ·  view source on GitHub ↗

Returns the JsonToken#BOOLEAN boolean value of the next token, consuming it. @throws IllegalStateException if the next token is not a boolean or if this reader is closed.

()

Source from the content-addressed store, hash-verified

475 * this reader is closed.
476 */
477 public boolean nextBoolean() throws IOException {
478 quickPeek();
479 if (value == null || token == JsonToken.STRING) {
480 throw new IllegalStateException("Expected a boolean but was " + peek());
481 }
482
483 boolean result;
484 if (value.equalsIgnoreCase("true")) {
485 result = true;
486 } else if (value.equalsIgnoreCase("false")) {
487 result = false;
488 } else {
489 throw new IllegalStateException("Not a boolean: " + value);
490 }
491
492 advance();
493 return result;
494 }
495
496 /**
497 * Consumes the next token from the JSON stream and asserts that it is a

Callers 15

testReadArrayMethod · 0.95
testHelloWorldMethod · 0.95
testBooleansMethod · 0.95
testMixedCaseLiteralsMethod · 0.95
testPrematurelyClosedMethod · 0.95
testStrictCommentsMethod · 0.95
testLenientCommentsMethod · 0.95

Calls 3

quickPeekMethod · 0.95
peekMethod · 0.95
advanceMethod · 0.95

Tested by 15

testReadArrayMethod · 0.76
testHelloWorldMethod · 0.76
testBooleansMethod · 0.76
testMixedCaseLiteralsMethod · 0.76
testPrematurelyClosedMethod · 0.76
testStrictCommentsMethod · 0.76
testLenientCommentsMethod · 0.76