Class ParsedFile
- java.lang.Object
-
- de.skuzzle.enforcer.restrictimports.parser.ParsedFile
-
public final class ParsedFile extends Object
Represents a source file that has been parsed for import statements.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ParsedFileandAddAnnotation(Annotation... furtherAnnotations)Returns a newParsedFilewith identical information as this one but merging this file's annotations with the provided annotations.booleanequals(Object obj)static ParsedFilefailedToParse(Path path, Annotation... annotations)Creates aParsedFilefor the situation where the file could not be parsed at all (technical problem occurred while parsing).List<Annotation>getAnnotations()A list of findings in this file apart from banned imports.StringgetFqcn()Collection<ImportStatement>getImports()PathgetPath()inthashCode()booleanisFailedToParse()Whether the file could not be parsed at all and we have no information about used imports.static ParsedFilesuccessful(Path path, String declaredPackage, String fqcn, Collection<ImportStatement> imports)Creates aParsedFilefor a source file that was parsed successfully.StringtoString()
-
-
-
Method Detail
-
successful
public static ParsedFile successful(Path path, String declaredPackage, String fqcn, Collection<ImportStatement> imports)
Creates aParsedFilefor a source file that was parsed successfully.- Parameters:
path- The path of the source file.declaredPackage- The package from the source file'spackagedeclarationfqcn- 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 aParsedFilefor 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 newParsedFilewith 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()
-
getImports
public Collection<ImportStatement> getImports()
-
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
-
-