Class MatchedFile
- java.lang.Object
-
- de.skuzzle.enforcer.restrictimports.analyze.MatchedFile
-
public final class MatchedFile extends Object
Holds the matches that were found within a single source file. Instances can be constructed usingforSourceFile(Path).- Author:
- Simon Taddiken
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMatchedFile.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)static MatchedFile.BuilderforSourceFile(Path sourceFile)Constructs a MatchedFileOptional<BannedImportGroup>getMatchedBy()Returns the group that contains the banned import that caused the match in this file.List<MatchedImport>getMatchedImports()The matches found in this file.PathgetSourceFile()The java source file containing the matches.List<Warning>getWarnings()booleanhasBannedImports()inthashCode()booleanhasWarning()booleanisFailedToParse()Whether the file could not be parsed at all.StringtoString()
-
-
-
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 butgetWarnings()will contain a helpful message why parsing failed.- Returns:
- Whether we failed to parse the file.
- See Also:
getWarnings()
-
hasWarning
public boolean hasWarning()
-
hasBannedImports
public boolean hasBannedImports()
-
-