Class ParsedFile


  • public final class ParsedFile
    extends Object
    Represents a source file that has been parsed for import statements.
    • Method Detail

      • successful

        public static ParsedFile successful​(Path path,
                                            String declaredPackage,
                                            String fqcn,
                                            Collection<ImportStatement> imports)
        Creates a ParsedFile for a source file that was parsed successfully.
        Parameters:
        path - The path of the source file.
        declaredPackage - The package from the source file's package declaration
        fqcn - The full qualified name of the class represented by the source file.
        imports - The detected import statements within the source file.
        Returns:
        The ParsedFile.
        Since:
        2.2.0
      • failedToParse

        public static ParsedFile failedToParse​(Path path,
                                               Annotation... annotations)
        Creates a ParsedFile for the situation where the file could not be parsed at all (technical problem occurred while parsing).
        Parameters:
        path - The file that could not be parsed.
        annotations - At least one annotation that roughly describes the failure.
        Returns:
        The ParsedFile.
        Since:
        2.2.0
      • andAddAnnotation

        public ParsedFile andAddAnnotation​(Annotation... furtherAnnotations)
        Returns a new ParsedFile with identical information as this one but merging this file's annotations with the provided annotations.
        Parameters:
        furtherAnnotations - Annotations to append to the resulting ParsedFile.
        Returns:
        A new ParsedFile.
        Since:
        2.2.0
      • getPath

        public Path getPath()
      • getFqcn

        public String getFqcn()
      • isFailedToParse

        public boolean isFailedToParse()
        Whether the file could not be parsed at all and we have no information about used imports.
        Returns:
        Whether the file could not be parsed at all.
        Since:
        2.2.0
      • getAnnotations

        public List<Annotation> getAnnotations()
        A list of findings in this file apart from banned imports. Those findings will be reported separately in the analysis report but will usually not fail the build.
        Returns:
        Any findings/warnings that were detected while parsing this file.
        Since:
        2.2.0
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object