Class PathFinder


  • public final class PathFinder
    extends java.lang.Object
    The class PathFinder is a helper class for getting source folders from maven projects.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String SOURCE_FOLDER_SRC_MAIN_JAVA
      The Constant SOURCE_FOLDER_SRC_MAIN_JAVA keeps the relative path for the source folder 'src/main/java' in maven projects.
      static java.lang.String SOURCE_FOLDER_SRC_MAIN_RESOURCES
      The Constant SOURCE_FOLDER_SRC_MAIN_RESOURCES keeps the relative path for the source folder 'src/main/resources' in maven projects.
      static java.lang.String SOURCE_FOLDER_SRC_MAIN_WEBAPP
      The Constant SOURCE_FOLDER_SRC_MAIN_WEBAPP keeps the relative path for the source folder 'src/main/webapp' in maven projects.
      static java.lang.String SOURCE_FOLDER_SRC_TEST_JAVA
      The Constant SOURCE_FOLDER_SRC_TEST_JAVA keeps the relative path for the source folder 'src/test/java' in maven projects.
      static java.lang.String SOURCE_FOLDER_SRC_TEST_RESOURCES
      The Constant SOURCE_FOLDER_SRC_TEST_RESOURCES keeps the relative path for the source folder 'src/test/resources' in maven projects.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getAbsolutePath​(java.io.File file, boolean removeLastChar)
      Gets the absolute path.
      static java.io.File getProjectDirectory()
      Gets the project directory.
      static java.io.File getProjectDirectory​(java.io.File currentDir)
      Gets the project directory.
      static java.io.File getRelativePath​(java.io.File parent, java.lang.String... folders)
      Gets the file or directory from the given parent File object and the relative path given over the list as String objects.
      static java.io.File getRelativePathTo​(java.io.File parent, java.lang.String separator, java.lang.String folders, java.lang.String filename)
      Gets the file or directory from the given parent File object and the relative path given over the list as String objects.
      static java.io.File getRelativePathTo​(java.io.File parent, java.util.List<java.lang.String> folders)
      Gets the file or directory from the given parent File object and the relative path given over the list as String objects.
      static java.io.File getSrcMainJavaDir()
      Gets the src main java dir.
      static java.io.File getSrcMainJavaDir​(java.io.File projectDirectory)
      Gets the src main java dir.
      static java.io.File getSrcMainResourcesDir()
      Gets the src main resources dir.
      static java.io.File getSrcMainResourcesDir​(java.io.File projectDirectory)
      Gets the src main resources dir.
      static java.io.File getSrcTestJavaDir()
      Gets the src test java dir.
      static java.io.File getSrcTestJavaDir​(java.io.File projectDirectory)
      Gets the src test java dir.
      static java.io.File getSrcTestResourcesDir()
      Gets the src test resources dir.
      static java.io.File getSrcTestResourcesDir​(java.io.File projectDirectory)
      Gets the src test resources dir.
      • Methods inherited from class java.lang.Object

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

      • SOURCE_FOLDER_SRC_MAIN_JAVA

        public static final java.lang.String SOURCE_FOLDER_SRC_MAIN_JAVA
        The Constant SOURCE_FOLDER_SRC_MAIN_JAVA keeps the relative path for the source folder 'src/main/java' in maven projects.
        See Also:
        Constant Field Values
      • SOURCE_FOLDER_SRC_MAIN_RESOURCES

        public static final java.lang.String SOURCE_FOLDER_SRC_MAIN_RESOURCES
        The Constant SOURCE_FOLDER_SRC_MAIN_RESOURCES keeps the relative path for the source folder 'src/main/resources' in maven projects.
        See Also:
        Constant Field Values
      • SOURCE_FOLDER_SRC_MAIN_WEBAPP

        public static final java.lang.String SOURCE_FOLDER_SRC_MAIN_WEBAPP
        The Constant SOURCE_FOLDER_SRC_MAIN_WEBAPP keeps the relative path for the source folder 'src/main/webapp' in maven projects.
        See Also:
        Constant Field Values
      • SOURCE_FOLDER_SRC_TEST_JAVA

        public static final java.lang.String SOURCE_FOLDER_SRC_TEST_JAVA
        The Constant SOURCE_FOLDER_SRC_TEST_JAVA keeps the relative path for the source folder 'src/test/java' in maven projects.
        See Also:
        Constant Field Values
      • SOURCE_FOLDER_SRC_TEST_RESOURCES

        public static final java.lang.String SOURCE_FOLDER_SRC_TEST_RESOURCES
        The Constant SOURCE_FOLDER_SRC_TEST_RESOURCES keeps the relative path for the source folder 'src/test/resources' in maven projects.
        See Also:
        Constant Field Values
    • Method Detail

      • getAbsolutePath

        public static java.lang.String getAbsolutePath​(java.io.File file,
                                                       boolean removeLastChar)
        Gets the absolute path.
        Parameters:
        file - the file
        removeLastChar - the remove last char
        Returns:
        the absolute path
      • getProjectDirectory

        public static java.io.File getProjectDirectory()
        Gets the project directory.
        Returns:
        the project directory
      • getProjectDirectory

        public static java.io.File getProjectDirectory​(java.io.File currentDir)
        Gets the project directory.
        Parameters:
        currentDir - the current dir
        Returns:
        the project directory
      • getRelativePath

        public static java.io.File getRelativePath​(java.io.File parent,
                                                   java.lang.String... folders)
        Gets the file or directory from the given parent File object and the relative path given over the list as String objects.
        Parameters:
        parent - The parent directory.
        folders - The list with the directories and optional a filename.
        Returns:
        the resulted file or directory from the given arguments.
      • getRelativePathTo

        public static java.io.File getRelativePathTo​(java.io.File parent,
                                                     java.util.List<java.lang.String> folders)
        Gets the file or directory from the given parent File object and the relative path given over the list as String objects.
        Parameters:
        parent - The parent directory.
        folders - The list with the directories and optional a filename.
        Returns:
        the resulted file or directory from the given arguments.
      • getRelativePathTo

        public static java.io.File getRelativePathTo​(java.io.File parent,
                                                     java.lang.String separator,
                                                     java.lang.String folders,
                                                     java.lang.String filename)
        Gets the file or directory from the given parent File object and the relative path given over the list as String objects.
        Parameters:
        parent - The parent directory.
        separator - The separator for separate the String folders.
        folders - The relative path as a String object separated with the defined separator.
        filename - The filename.
        Returns:
        the resulted file or directory from the given arguments.
      • getSrcMainJavaDir

        public static java.io.File getSrcMainJavaDir()
        Gets the src main java dir.
        Returns:
        the src main java dir
      • getSrcMainJavaDir

        public static java.io.File getSrcMainJavaDir​(java.io.File projectDirectory)
        Gets the src main java dir.
        Parameters:
        projectDirectory - the project directory
        Returns:
        the src main java dir
      • getSrcMainResourcesDir

        public static java.io.File getSrcMainResourcesDir()
        Gets the src main resources dir.
        Returns:
        the src main resources dir
      • getSrcMainResourcesDir

        public static java.io.File getSrcMainResourcesDir​(java.io.File projectDirectory)
        Gets the src main resources dir.
        Parameters:
        projectDirectory - the project directory
        Returns:
        the src main resources dir
      • getSrcTestJavaDir

        public static java.io.File getSrcTestJavaDir()
        Gets the src test java dir.
        Returns:
        the src test java dir
      • getSrcTestJavaDir

        public static java.io.File getSrcTestJavaDir​(java.io.File projectDirectory)
        Gets the src test java dir.
        Parameters:
        projectDirectory - the project directory
        Returns:
        the src test java dir
      • getSrcTestResourcesDir

        public static java.io.File getSrcTestResourcesDir()
        Gets the src test resources dir.
        Returns:
        the src test resources dir
      • getSrcTestResourcesDir

        public static java.io.File getSrcTestResourcesDir​(java.io.File projectDirectory)
        Gets the src test resources dir.
        Parameters:
        projectDirectory - the project directory
        Returns:
        the src test resources dir