Class MatchedFile


  • public final class MatchedFile
    extends Object
    Holds the matches that were found within a single source file. Instances can be constructed using forSourceFile(Path).
    Author:
    Simon Taddiken
    • Method Detail

      • forSourceFile

        public static MatchedFile.Builder forSourceFile​(Path sourceFile)
        Constructs a MatchedFile
        Parameters:
        sourceFile - The path to the java source file.
        Returns:
        A Builder for further configuration of the MatchedFile instance.
      • getSourceFile

        public Path getSourceFile()
        The java source file containing the matches.
        Returns:
        The java source file.
      • getMatchedImports

        public List<MatchedImport> getMatchedImports()
        The matches found in this file. Will be empty in case no banned imports were found but still warnings were detected while analyzing this file.
        Returns:
        The matches.
      • getMatchedBy

        public Optional<BannedImportGroup> getMatchedBy()
        Returns the group that contains the banned import that caused the match in this file.

        The result will be empty if this file wasn't matched by any group but warnings were found while parsings. In that case the list returned by getMatchedImports() will also be empty.

        Returns:
        The group. Will be empty if hasBannedImports() is false.
      • isFailedToParse

        public boolean isFailedToParse()
        Whether the file could not be parsed at all. When true, this file will not be matced against any banned import definitions but getWarnings() will contain a helpful message why parsing failed.
        Returns:
        Whether we failed to parse the file.
        See Also:
        getWarnings()
      • getWarnings

        public List<Warning> getWarnings()
        Returns:
      • hasWarning

        public boolean hasWarning()
      • hasBannedImports

        public boolean hasBannedImports()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object