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

Method isEmpty

corpus/java/training/guava/io/ByteSource.java:138–152  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

136 * @since 15.0
137 */
138 public boolean isEmpty() throws IOException {
139 Optional<Long> sizeIfKnown = sizeIfKnown();
140 if (sizeIfKnown.isPresent() && sizeIfKnown.get() == 0L) {
141 return true;
142 }
143 Closer closer = Closer.create();
144 try {
145 InputStream in = closer.register(openStream());
146 return in.read() == -1;
147 } catch (Throwable e) {
148 throw closer.rethrow(e);
149 } finally {
150 closer.close();
151 }
152 }
153
154 /**
155 * Returns the size of this source in bytes, if the size can be easily determined without actually

Callers

nothing calls this directly

Calls 9

sizeIfKnownMethod · 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