Class AbstractImportRule
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.imports.AbstractImportRule
- Direct Known Subclasses:
ClassImportRule
,PkgImportRule
Base class for import rules.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractImportRule
(boolean allow, boolean localOnly, boolean regExp) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected AccessResult
calculateResult
(boolean matched) Returns the appropriateAccessResult
based on whether there was a match and if the rule is to allow access.boolean
Return true if the guard is to only be applied locally or false.protected boolean
isRegExp()
Return true if the name is to be interpreted as a regular expression or false.abstract AccessResult
verifyImport
(String forImport) Verifies whether a package name is used.
-
Field Details
-
allowed
Indicates whether to allow access or not. -
localOnly
Indicates if the rule only applies to this package. -
regExp
Indicates if the name is to be interpreted as a regular expression.
-
-
Constructor Details
-
AbstractImportRule
Constructs an instance.- Parameters:
allow
- whether to allow access.localOnly
- whether the rule is to be applied locally only.regExp
- whether the name is to be interpreted as a regular expression.
-
-
Method Details
-
verifyImport
Verifies whether a package name is used.- Parameters:
forImport
- the import to check.- Returns:
- a result
AccessResult
indicating whether it can be used.
-
isLocalOnly
Return true if the guard is to only be applied locally or false.- Returns:
- whether the guard is to only be applied locally.
-
isRegExp
Return true if the name is to be interpreted as a regular expression or false.- Returns:
- whether the name is to be interpreted as a regular expression.
-
calculateResult
Returns the appropriateAccessResult
based on whether there was a match and if the rule is to allow access.- Parameters:
matched
- indicates whether there was a match.- Returns:
- An appropriate
AccessResult
.
-