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

Method close

src/main/java/com/google/gson/stream/JsonWriter.java:273–286  ·  view source on GitHub ↗

Closes the current scope by appending any necessary whitespace and the given bracket.

(JsonScope empty, JsonScope nonempty, String closeBracket)

Source from the content-addressed store, hash-verified

271 * given bracket.
272 */
273 private JsonWriter close(JsonScope empty, JsonScope nonempty, String closeBracket)
274 throws IOException {
275 JsonScope context = peek();
276 if (context != nonempty && context != empty) {
277 throw new IllegalStateException("Nesting problem: " + stack);
278 }
279
280 stack.remove(stack.size() - 1);
281 if (context == nonempty) {
282 newline();
283 }
284 out.write(closeBracket);
285 return this;
286 }
287
288 /**
289 * Returns the value on the top of the stack.

Callers 6

testWriteClosedMethod · 0.95
testDoublesMethod · 0.95
testLongsMethod · 0.95
testNumbersMethod · 0.95
endArrayMethod · 0.95
endObjectMethod · 0.95

Calls 5

peekMethod · 0.95
newlineMethod · 0.95
sizeMethod · 0.80
removeMethod · 0.45
writeMethod · 0.45

Tested by 4

testWriteClosedMethod · 0.76
testDoublesMethod · 0.76
testLongsMethod · 0.76
testNumbersMethod · 0.76