Class AbstractImportRule
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.checks.imports.AbstractImportRule
-
- Direct Known Subclasses:
ClassImportRule
,PkgImportRule
abstract class AbstractImportRule extends Object
Base class for import rules.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractImportRule(boolean allow, boolean localOnly, boolean regExp)
Constructs an instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected AccessResult
calculateResult(boolean matched)
Returns the appropriateAccessResult
based on whether there was a match and if the rule is to allow access.boolean
isLocalOnly()
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.
-
-
-
Constructor Detail
-
AbstractImportRule
protected AbstractImportRule(boolean allow, boolean localOnly, boolean regExp)
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 Detail
-
verifyImport
public abstract AccessResult verifyImport(String forImport)
Verifies whether a package name is used.- Parameters:
forImport
- the import to check.- Returns:
- a result
AccessResult
indicating whether it can be used.
-
isLocalOnly
public boolean 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
protected boolean 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
protected AccessResult calculateResult(boolean matched)
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
.
-
-