MCPcopy Create free account
hub / github.com/antlr/codebuff / isEmpty

Method isEmpty

corpus/java/training/guava/io/CharSource.java:334–348  ·  view source on GitHub ↗

Returns whether the source has zero chars. The default implementation returns true if #lengthIfKnown returns zero, falling back to opening a stream and checking for EOF if the length is not known. Note that, in cases where lengthIfKnown returns zero, it is possible that ch

()

Source from the content-addressed store, hash-verified

332 * @since 15.0
333 */
334 public boolean isEmpty() throws IOException {
335 Optional<Long> lengthIfKnown = lengthIfKnown();
336 if (lengthIfKnown.isPresent() && lengthIfKnown.get() == 0L) {
337 return true;
338 }
339 Closer closer = Closer.create();
340 try {
341 Reader reader = closer.register(openStream());
342 return reader.read() == -1;
343 } catch (Throwable e) {
344 throw closer.rethrow(e);
345 } finally {
346 closer.close();
347 }
348 }
349
350 /**
351 * Concatenates multiple {@link CharSource} instances into a single source. Streams returned from

Callers

nothing calls this directly

Calls 9

lengthIfKnownMethod · 0.95
createMethod · 0.95
registerMethod · 0.95
openStreamMethod · 0.95
rethrowMethod · 0.95
closeMethod · 0.95
getMethod · 0.65
isPresentMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected