Class ResourceScanUtils

java.lang.Object
tech.guilhermekaua.spigotboot.core.scanner.ResourceScanUtils

public final class ResourceScanUtils extends Object
  • Method Details

    • normalizePath

      @NotNull public static @NotNull String normalizePath(@NotNull @NotNull String path)
      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 check
      extensions - 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 scan
      pathPrefix - 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 scan
      pathPrefix - 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 scan
      filter - 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 scan
      filter - filter for files
      Returns:
      list of matching file paths
      Throws:
      IOException - if an I/O error occurs