Class PathTools

java.lang.Object
rife.bld.extension.tools.PathTools

@NullMarked public final class PathTools extends Object
Path Tools.

Utility methods to facilitate paths and arguments handling.

Since:
1.0
Author:
Erik C. Thauvin
  • Method Details

    • formatCommandLine

      public static String formatCommandLine(@Nullable Collection<@Nullable String> args)
      Formats a collection of command-line arguments into a single string suitable for logging and safe copy/paste into a POSIX-compatible shell.
      Parameters:
      args - the collection of command-line arguments to format; may be null or empty, and may contain null or empty elements, which are rendered as ''
      Returns:
      a space-separated string with arguments quoted and escaped for POSIX shells; an empty string if the collection is null or empty
      Since:
      1.0
    • joinClasspath

      public static String joinClasspath()
      Returns an empty classpath string. This overload exists to disambiguate zero-argument calls between the various joinClasspath varargs overloads.
      Returns:
      an empty string
      Since:
      1.0
    • joinClasspath

      @SafeVarargs public static String joinClasspath(@Nullable Collection<File> @Nullable ... files)
      Joins multiple collections of files into a single classpath string using the system's path separator.

      Each file's normalized absolute path from all provided collections is included in the resulting classpath string. null collections and null individual file elements are silently ignored.

      Uses Path.toAbsolutePath() followed by Path.normalize() to resolve relative paths and eliminate redundant .. and . segments.

      Parameters:
      files - variable number of Collections of File objects representing the files to include in the classpath; may be null, and null collections or elements are skipped
      Returns:
      a classpath string where the normalized absolute paths of all provided files are joined by the system's path separator; an empty string if no valid files are provided
      Since:
      1.0
    • joinClasspath

      public static String joinClasspath(@Nullable File @Nullable ... files)
      Joins multiple files into a single classpath string using the system's path separator.

      Each file's normalized absolute path is included in the resulting classpath string. null individual file elements are silently ignored.

      Uses Path.toAbsolutePath() followed by Path.normalize() to resolve relative paths and eliminate redundant .. and . segments.

      Parameters:
      files - variable number of File objects representing the files to include in the classpath; may be null, and null elements are skipped
      Returns:
      a classpath string where the normalized absolute paths of all provided files are joined by the system's path separator; an empty string if no valid files are provided
      Since:
      1.0
    • joinClasspath

      public static String joinClasspath(@Nullable String @Nullable ... paths)
      Joins string paths into a single classpath by concatenating non-blank paths using the system's path separator.

      Blank or null paths are ignored.

      Parameters:
      paths - an array of strings representing individual classpath entries; may be null, and individual null or blank strings are silently skipped
      Returns:
      a string representing the concatenated classpath entries, separated by the system's path separator; an empty string if no valid paths are provided
      Since:
      1.0
    • joinClasspath

      public static String joinClasspath(@Nullable Collection<@Nullable Path> paths)
      Joins a collection of paths into a single classpath string using the system's path separator.

      Each path's normalized absolute path from the provided collection is included in the resulting classpath string. null individual path elements are silently ignored.

      Uses Path.toAbsolutePath() followed by Path.normalize() to resolve relative paths and eliminate redundant .. and . segments.

      Parameters:
      paths - a Collection of Path objects representing the paths to include in the classpath; may be null, and null elements are skipped
      Returns:
      a classpath string where the normalized absolute paths of all provided paths are joined by the system's path separator; an empty string if the collection is null or contains no valid paths
      Since:
      1.0
    • joinClasspath

      public static String joinClasspath(@Nullable Path @Nullable ... paths)
      Joins multiple paths into a single classpath string using the system's path separator.

      Each path's normalized absolute path is included in the resulting classpath string. null individual path elements are silently ignored.

      Uses Path.toAbsolutePath() followed by Path.normalize() to resolve relative paths and eliminate redundant .. and . segments.

      Parameters:
      paths - variable number of Path objects representing the paths to include in the classpath; may be null, and null elements are skipped
      Returns:
      a classpath string where the normalized absolute paths of all provided paths are joined by the system's path separator; an empty string if no valid paths are provided
      Since:
      1.0