Package io.quarkus.paths
Interface PathTree
-
- All Known Subinterfaces:
OpenPathTree
- All Known Implementing Classes:
ArchivePathTree,CachingPathTree,DirectoryPathTree,EmptyPathTree,MultiRootPathTree,PathTreeWithManifest
public interface PathTree
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaccept(String relativePath, Consumer<PathVisit> consumer)Consumes a given path relative to the root of the tree.<T> Tapply(String relativePath, Function<PathVisit,T> func)Applies a function to a given path relative to the root of the tree.booleancontains(String relativePath)Checks whether the tree contains a relative path.ManifestgetManifest()IfMETA-INF/MANIFEST.MFfound, reads it and returns an instance ofManifest, otherwise returns null.Collection<Path>getRoots()The roots of the path tree.default booleanisEmpty()Checks whether the tree is emptystatic PathTreeofArchive(Path archive)Creates a newPathTreefor an existing path that is expected to be a ZIP-based archive.static PathTreeofArchive(Path archive, PathFilter filter)Creates a newPathTreefor an existing path that is expected to be a ZIP-based archive applying a providedPathFilterunless it isnull.static PathTreeofDirectoryOrArchive(Path p)Creates a newPathTreefor a given existing path which is expected to be either a directory or a ZIP-based archive.static PathTreeofDirectoryOrArchive(Path p, PathFilter filter)Creates a newPathTreefor a given existing path which is expected to be either a directory or a ZIP-based archive applying a providedPathFilterunless it isnull.static PathTreeofDirectoryOrFile(Path p)static PathTreeofDirectoryOrFile(Path p, PathFilter filter)OpenPathTreeopen()Returns anOpenPathTreefor this tree, which is supposed to be closed at the end of processing.voidwalk(PathVisitor visitor)Walks the tree.
-
-
-
Method Detail
-
ofDirectoryOrFile
static PathTree ofDirectoryOrFile(Path p, PathFilter filter)
-
ofDirectoryOrArchive
static PathTree ofDirectoryOrArchive(Path p)
Creates a newPathTreefor a given existing path which is expected to be either a directory or a ZIP-based archive.- Parameters:
p- path to a directory or an archive- Returns:
- an instance of
PathTreefor a given existing directory or an archive
-
ofDirectoryOrArchive
static PathTree ofDirectoryOrArchive(Path p, PathFilter filter)
Creates a newPathTreefor a given existing path which is expected to be either a directory or a ZIP-based archive applying a providedPathFilterunless it isnull.- Parameters:
p- path to a directory or an archivefilter- path filter to apply, could benull- Returns:
- an instance of
PathTreefor a given existing directory or an archive
-
ofArchive
static PathTree ofArchive(Path archive)
Creates a newPathTreefor an existing path that is expected to be a ZIP-based archive.- Parameters:
archive- path to an archive- Returns:
- an instance of
PathTreefor a given archive
-
ofArchive
static PathTree ofArchive(Path archive, PathFilter filter)
Creates a newPathTreefor an existing path that is expected to be a ZIP-based archive applying a providedPathFilterunless it isnull.- Parameters:
archive- path to an archivefilter- path filter to apply, could benull- Returns:
- an instance of
PathTreefor a given archive
-
getRoots
Collection<Path> getRoots()
The roots of the path tree.- Returns:
- roots of the path tree
-
isEmpty
default boolean isEmpty()
Checks whether the tree is empty- Returns:
- true, if the tree is empty, otherwise - false
-
getManifest
Manifest getManifest()
IfMETA-INF/MANIFEST.MFfound, reads it and returns an instance ofManifest, otherwise returns null.- Returns:
- parsed
META-INF/MANIFEST.MFif it's found, otherwisenull
-
walk
void walk(PathVisitor visitor)
Walks the tree.- Parameters:
visitor- path visitor
-
apply
<T> T apply(String relativePath, Function<PathVisit,T> func)
Applies a function to a given path relative to the root of the tree. If the path isn't found in the tree, thePathVisitargument passed to the function will benull.- Type Parameters:
T- resulting type- Parameters:
relativePath- relative path to processfunc- processing function- Returns:
- result of the function
-
accept
void accept(String relativePath, Consumer<PathVisit> consumer)
Consumes a given path relative to the root of the tree. If the path isn't found in the tree, thePathVisitargument passed to the consumer will benull.- Parameters:
relativePath- relative path to consumeconsumer- path consumer
-
contains
boolean contains(String relativePath)
Checks whether the tree contains a relative path.- Parameters:
relativePath- path relative to the root of the tree- Returns:
- true, in case the tree contains the path, otherwise - false
-
open
OpenPathTree open()
Returns anOpenPathTreefor this tree, which is supposed to be closed at the end of processing. It is meant to be an optimization when processing multiple paths of path trees that represent archives. If a path tree does not represent an archive but a directory, for example, this method is expected to be a no-op, returning the original tree as an instance ofOpenPathTree.- Returns:
- an instance of
OpenPathTreefor this path tree
-
-