Class AbstractAccessControlNameCheck
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
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
Abstract class for checking a class member (field/method)'s name conforms to
a specified pattern.
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", and private.
Level is configured using the following properties:
- applyToPublic, default true;
- applyToProtected, default true;
- applyToPackage, default true;
- applyToPrivate, default true;
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanIf true, applies the check be "package" members.private booleanIf true, applies the check be private members.private booleanIf true, applies the check be protected members.private booleanIf true, applies the check be public members.Fields inherited from class com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck
MSG_INVALID_PATTERN -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractAccessControlNameCheck(String format) Creates a newAbstractAccessControlNameCheckinstance. -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanChecks if given modifiers has public access.protected booleanmustCheckName(DetailAST ast) Decides whether the name of an AST should be checked against the format regexp.voidsetApplyToPackage(boolean applyTo) Setter to control if check should apply to package-private members.voidsetApplyToPrivate(boolean applyTo) Setter to control if check should apply to private members.voidsetApplyToProtected(boolean applyTo) Setter to control if check should apply to protected members.voidsetApplyToPublic(boolean applyTo) Setter to control if check should apply to public members.protected booleanshouldCheckInScope(DetailAST modifiers) Should we check member with given modifiers.Methods inherited from class com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck
setFormat, visitTokenMethods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
beginTree, clearViolations, destroy, finishTree, getAcceptableTokens, getDefaultTokens, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getRequiredTokens, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensMethods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityMethods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
configure, contextualize, getConfiguration, setupChild
-
Field Details
-
applyToPublic
If true, applies the check be public members. -
applyToProtected
If true, applies the check be protected members. -
applyToPackage
If true, applies the check be "package" members. -
applyToPrivate
If true, applies the check be private members.
-
-
Constructor Details
-
AbstractAccessControlNameCheck
Creates a newAbstractAccessControlNameCheckinstance.- Parameters:
format- format to check with
-
-
Method Details
-
mustCheckName
Description copied from class:AbstractNameCheckDecides whether the name of an AST should be checked against the format regexp.- Specified by:
mustCheckNamein classAbstractNameCheck- Parameters:
ast- the AST to check.- Returns:
- true if the IDENT subnode of ast should be checked against the format regexp.
-
shouldCheckInScope
Should we check member with given modifiers.- Parameters:
modifiers- modifiers of member to check.- Returns:
- true if we should check such member.
-
isPublic
Checks if given modifiers has public access. There are 2 cases - it is either has explicit modifier, or it is in annotation or interface.- Parameters:
modifiers- - modifiers to check- Returns:
- true if public
-
setApplyToPublic
Setter to control if check should apply to public members.- Parameters:
applyTo- new value of the property.
-
setApplyToProtected
Setter to control if check should apply to protected members.- Parameters:
applyTo- new value of the property.
-
setApplyToPackage
Setter to control if check should apply to package-private members.- Parameters:
applyTo- new value of the property.
-
setApplyToPrivate
Setter to control if check should apply to private members.- Parameters:
applyTo- new value of the property.
-