Class DefaultJavaPackageFinder

    • Constructor Detail

      • DefaultJavaPackageFinder

        public DefaultJavaPackageFinder​(ProjectFilesystem projectFilesystem,
                                        com.google.common.collect.ImmutableSortedSet<String> pathsFromRoot,
                                        com.google.common.collect.ImmutableSet<String> pathElements)
    • Method Detail

      • findJavaPackageFolder

        public Path findJavaPackageFolder​(Path pathRelativeToProjectRoot)
        Description copied from interface: JavaPackageFinder
        Given the relative path to a file under the project root, return the Java package with which the file is associated. For .java files, this is generally obvious, as they contain an explicit "package" statement. For other files, such as resources, other heuristics must be used.
        Specified by:
        findJavaPackageFolder in interface JavaPackageFinder
        Parameters:
        pathRelativeToProjectRoot - may be a path to either a file or a directory. If a directory, then it must end in a slash.
        Returns:
        a path that always ends with a slash, or the empty string, indicating the root directory.
      • getPathsFromRoot

        public com.google.common.collect.ImmutableSortedSet<String> getPathsFromRoot()
      • getPathElements

        public com.google.common.collect.ImmutableSet<String> getPathElements()
      • createDefaultJavaPackageFinder

        public static DefaultJavaPackageFinder createDefaultJavaPackageFinder​(ProjectFilesystem projectFilesystem,
                                                                              Iterable<String> pathPatterns)
        Parameters:
        pathPatterns - elements that start with a slash must be prefix patterns; all other elements indicate individual directory names (and therefore cannot contain slashes).
      • findJavaPackageWithPackageFolder

        public static String findJavaPackageWithPackageFolder​(Path packageFolder)