Class PathUtils


  • public final class PathUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private PathUtils()
      Private Constructor
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.StringBuilder appendUserHome​(java.lang.StringBuilder sb)  
      static java.lang.StringBuilder appendUserHome​(java.lang.StringBuilder sb, java.lang.String userHome)  
      static java.lang.StringBuilder appendUserHome​(java.lang.StringBuilder sb, java.nio.file.Path userHome)  
      static java.nio.file.Path getUserHomeFolder()  
      static java.lang.String normalizePath​(java.lang.String path)
      Replaces leading '~' with user's HOME directory Replaces any forward slashes with the O/S directory separator
      static int safeCompareFilename​(java.nio.file.Path p1, java.nio.file.Path p2, boolean caseSensitive)
      Compares 2 Path-s by their filename while allowing for one or both to be null.
      static void setUserHomeFolderResolver​(java.util.function.Supplier<? extends java.nio.file.Path> resolver)
      Set the reported value from getUserHomeFolder()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • BY_CASE_INSENSITIVE_FILENAME

        public static final java.util.Comparator<java.nio.file.Path> BY_CASE_INSENSITIVE_FILENAME
        Compares 2 Path-s by their case insensitive filename
      • EQ_CASE_INSENSITIVE_FILENAME

        public static final UnaryEquator<java.nio.file.Path> EQ_CASE_INSENSITIVE_FILENAME
      • BY_CASE_SENSITIVE_FILENAME

        public static final java.util.Comparator<java.nio.file.Path> BY_CASE_SENSITIVE_FILENAME
        Compares 2 Path-s by their case sensitive filename
      • EQ_CASE_SENSITIVE_FILENAME

        public static final UnaryEquator<java.nio.file.Path> EQ_CASE_SENSITIVE_FILENAME
      • USER_HOME_RESOLVER_HOLDER

        private static final java.util.concurrent.atomic.AtomicReference<java.util.function.Supplier<? extends java.nio.file.Path>> USER_HOME_RESOLVER_HOLDER
    • Constructor Detail

      • PathUtils

        private PathUtils()
        Private Constructor
    • Method Detail

      • safeCompareFilename

        public static int safeCompareFilename​(java.nio.file.Path p1,
                                              java.nio.file.Path p2,
                                              boolean caseSensitive)
        Compares 2 Path-s by their filename while allowing for one or both to be null.
        Parameters:
        p1 - 1st Path
        p2 - 2nd Path
        caseSensitive - Whether comparison is case sensitive
        Returns:
        Comparison results - null-s are considered "greater" than non-null-s
      • normalizePath

        public static java.lang.String normalizePath​(java.lang.String path)
        • Replaces leading '~' with user's HOME directory
        • Replaces any forward slashes with the O/S directory separator
        Parameters:
        path - Input path - ignored if null/empty/blank
        Returns:
        Adjusted path
      • setUserHomeFolderResolver

        public static void setUserHomeFolderResolver​(java.util.function.Supplier<? extends java.nio.file.Path> resolver)
        Set the reported value from getUserHomeFolder()
        Parameters:
        resolver - The Path provider to report - if null then "user.home" system property will be used
      • appendUserHome

        public static java.lang.StringBuilder appendUserHome​(java.lang.StringBuilder sb)
      • appendUserHome

        public static java.lang.StringBuilder appendUserHome​(java.lang.StringBuilder sb,
                                                             java.nio.file.Path userHome)
      • appendUserHome

        public static java.lang.StringBuilder appendUserHome​(java.lang.StringBuilder sb,
                                                             java.lang.String userHome)