MCPcopy Index your code
hub / github.com/antlr/codebuff / isEmpty

Method isEmpty

output/java_guava/1.4.17/ByteSource.java:150–164  ·  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

148
149
150 public boolean isEmpty() throws IOException {
151 Optional<Long> sizeIfKnown = sizeIfKnown();
152 if (sizeIfKnown.isPresent() && sizeIfKnown.get() == 0L) {
153 return true;
154 }
155 Closer closer = Closer.create();
156 try {
157 InputStream in = closer.register(openStream());
158 return in.read() == -1;
159 } catch (Throwable e) {
160 throw closer.rethrow(e);
161 } finally {
162 closer.close();
163 }
164 }
165
166 /**
167 * 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