Class PkgImportRule
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.checks.imports.AbstractImportRule
-
- com.puppycrawl.tools.checkstyle.checks.imports.PkgImportRule
-
class PkgImportRule extends AbstractImportRule
Represents whether a package is allowed to be imported or not.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanexactMatchIndicates if the package name must be an exact match.private java.lang.StringpkgNamePackage to control access to.
-
Constructor Summary
Constructors Constructor Description PkgImportRule(boolean allow, boolean localOnly, java.lang.String pkgName, boolean exactMatch, boolean regExp)Constructs an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AccessResultverifyImport(java.lang.String forImport)Verifies whether a package name is used.-
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.imports.AbstractImportRule
calculateResult, isLocalOnly, isRegExp
-
-
-
-
Field Detail
-
pkgName
private final java.lang.String pkgName
Package to control access to.
-
exactMatch
private final boolean exactMatch
Indicates if the package name must be an exact match.
-
-
Constructor Detail
-
PkgImportRule
PkgImportRule(boolean allow, boolean localOnly, java.lang.String pkgName, boolean exactMatch, boolean regExp)
Constructs an instance.- Parameters:
allow- whether to allow access.localOnly- whether the rule is to be applied locally onlypkgName- the package to apply the rule on.exactMatch- whether the package name must match exactly.regExp- whether the package name is to be interpreted as a regular expression.
-
-
Method Detail
-
verifyImport
public AccessResult verifyImport(java.lang.String forImport)
Verifies whether a package name is used.- Specified by:
verifyImportin classAbstractImportRule- Parameters:
forImport- the import to check.- Returns:
- a result
AccessResultindicating whether it can be used.
-
-