@NotThreadSafe public class CachingGlobber extends Object implements Globber
Globber implementation that caches expanded paths from previous invocations and reuses
them in case the glob with same GlobSpec is requested again.
Most of the packages usually do not perform identical glob invocations, but when complex
macros are used, it's not uncommon to see repeated invocations of the same glob function.
There is a more important reason to use consistent glob resolution while parsing the same
package - caching. This approach guarantees that all glob invocations are expanded in the
exact same way and as such all execution paths that rely on glob results will be consistent as
well. In other words, the snippet: will always produce either
if glob(['foo']):
print("A")
else:
print("B")
if glob(['foo']):
print("C")
else:
print("D")
"AC" or "CD" and never "AD" or
"BC".
| Modifier and Type | Method and Description |
|---|---|
com.google.common.collect.ImmutableList<GlobSpecWithResult> |
createGlobManifest() |
static CachingGlobber |
of(Globber globber) |
Set<String> |
run(Collection<String> include,
Collection<String> exclude,
boolean excludeDirectories) |
public Set<String> run(Collection<String> include, Collection<String> exclude, boolean excludeDirectories) throws IOException, InterruptedException
run in interface GlobberIOExceptionInterruptedExceptionpublic com.google.common.collect.ImmutableList<GlobSpecWithResult> createGlobManifest()
GlobSpec.public static CachingGlobber of(Globber globber)