Class ResourceScanUtils
java.lang.Object
tech.guilhermekaua.spigotboot.core.scanner.ResourceScanUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanhasExtension(@NotNull String fileName, @NotNull String... extensions) Checks if a filename has any of the given extensions.static @NotNull StringnormalizePath(@NotNull String path) Normalizes a resource path by converting backslashes to forward slashes, removing leading slash, and ensuring trailing slash.scanDirectory(@NotNull Path directory, @NotNull Predicate<Path> filter) Scans a directory for files matching a filter (non-recursive).scanDirectoryRecursive(@NotNull Path directory, @NotNull Predicate<Path> filter) Scans a directory recursively for files matching a filter.Scans a JAR file for entries matching a path prefix and filter.scanJarRecursive(@NotNull JarFile jar, @NotNull String pathPrefix, @NotNull Predicate<JarEntry> filter) Scans a JAR file for all entries matching a path prefix and filter, including entries in subdirectories.
-
Method Details
-
normalizePath
Normalizes a resource path by converting backslashes to forward slashes, removing leading slash, and ensuring trailing slash.- Parameters:
path- the path to normalize- Returns:
- the normalized path
-
hasExtension
public static boolean hasExtension(@NotNull @NotNull String fileName, @NotNull @NotNull String... extensions) Checks if a filename has any of the given extensions.- Parameters:
fileName- the filename to checkextensions- the extensions to check for (without the dot)- Returns:
- true if the filename ends with any of the extensions
-
scanJar
@NotNull public static @NotNull List<String> scanJar(@NotNull @NotNull JarFile jar, @NotNull @NotNull String pathPrefix, @NotNull @NotNull Predicate<JarEntry> filter) Scans a JAR file for entries matching a path prefix and filter. Only non-directory entries directly under the path prefix are returned.- Parameters:
jar- the JAR file to scanpathPrefix- the path prefix to match (should end with '/')filter- additional filter for entries- Returns:
- list of matching entry names
-
scanJarRecursive
@NotNull public static @NotNull List<String> scanJarRecursive(@NotNull @NotNull JarFile jar, @NotNull @NotNull String pathPrefix, @NotNull @NotNull Predicate<JarEntry> filter) Scans a JAR file for all entries matching a path prefix and filter, including entries in subdirectories.- Parameters:
jar- the JAR file to scanpathPrefix- the path prefix to match (should end with '/')filter- additional filter for entries- Returns:
- list of matching entry names
-
scanDirectory
@NotNull public static @NotNull List<Path> scanDirectory(@NotNull @NotNull Path directory, @NotNull @NotNull Predicate<Path> filter) throws IOException Scans a directory for files matching a filter (non-recursive).- Parameters:
directory- the directory to scanfilter- filter for files- Returns:
- list of matching file paths
- Throws:
IOException- if an I/O error occurs
-
scanDirectoryRecursive
@NotNull public static @NotNull List<Path> scanDirectoryRecursive(@NotNull @NotNull Path directory, @NotNull @NotNull Predicate<Path> filter) throws IOException Scans a directory recursively for files matching a filter.- Parameters:
directory- the directory to scanfilter- filter for files- Returns:
- list of matching file paths
- Throws:
IOException- if an I/O error occurs
-