Class AbstractAccessControlNameCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck
-
- com.puppycrawl.tools.checkstyle.checks.naming.AbstractAccessControlNameCheck
-
- All Implemented Interfaces:
Configurable
,Contextualizable
- Direct Known Subclasses:
ConstantNameCheck
,MemberNameCheck
,MethodNameCheck
,StaticVariableNameCheck
,TypeNameCheck
public abstract class AbstractAccessControlNameCheck extends AbstractNameCheck
Abstract class for checking a class member (field/method)'s name conforms to a format specified by the format property.This class extends
AbstractNameCheck
with support for access level restrictions. This allows the check to be configured to be applied to one of the four Java access levels:public
,protected
,"package"
, andprivate
.Level is configured using the following properties:
- applyToPublic, default true;
- applyToProtected, default true;
- applyToPackage, default true;
- applyToPrivate, default true;
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
applyToPackage
If true, applies the check be "package" members.private boolean
applyToPrivate
If true, applies the check be private members.private boolean
applyToProtected
If true, applies the check be protected members.private boolean
applyToPublic
If true, applies the check be public members.-
Fields inherited from class com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck
MSG_INVALID_PATTERN
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractAccessControlNameCheck(java.lang.String format)
Creates a newAbstractAccessControlNameCheck
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
mustCheckName(DetailAST ast)
Decides whether the name of an AST should be checked against the format regexp.void
setApplyToPackage(boolean applyTo)
Sets whether we should apply the check to package-private members.void
setApplyToPrivate(boolean applyTo)
Sets whether we should apply the check to private members.void
setApplyToProtected(boolean applyTo)
Sets whether we should apply the check to protected members.void
setApplyToPublic(boolean applyTo)
Sets whether we should apply the check to public members.protected boolean
shouldCheckInScope(DetailAST modifiers)
Should we check member with given modifiers.-
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck
setFormat, visitToken
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLine, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
-
-
-
-
Field Detail
-
applyToPublic
private boolean applyToPublic
If true, applies the check be public members.
-
applyToProtected
private boolean applyToProtected
If true, applies the check be protected members.
-
applyToPackage
private boolean applyToPackage
If true, applies the check be "package" members.
-
applyToPrivate
private boolean applyToPrivate
If true, applies the check be private members.
-
-
Method Detail
-
mustCheckName
protected boolean mustCheckName(DetailAST ast)
Description copied from class:AbstractNameCheck
Decides whether the name of an AST should be checked against the format regexp.- Specified by:
mustCheckName
in classAbstractNameCheck
- Parameters:
ast
- the AST to check.- Returns:
- true if the IDENT subnode of ast should be checked against the format regexp.
-
shouldCheckInScope
protected boolean shouldCheckInScope(DetailAST modifiers)
Should we check member with given modifiers.- Parameters:
modifiers
- modifiers of member to check.- Returns:
- true if we should check such member.
-
setApplyToPublic
public void setApplyToPublic(boolean applyTo)
Sets whether we should apply the check to public members.- Parameters:
applyTo
- new value of the property.
-
setApplyToProtected
public void setApplyToProtected(boolean applyTo)
Sets whether we should apply the check to protected members.- Parameters:
applyTo
- new value of the property.
-
setApplyToPackage
public void setApplyToPackage(boolean applyTo)
Sets whether we should apply the check to package-private members.- Parameters:
applyTo
- new value of the property.
-
setApplyToPrivate
public void setApplyToPrivate(boolean applyTo)
Sets whether we should apply the check to private members.- Parameters:
applyTo
- new value of the property.
-
-