com.puppycrawl.tools.checkstyle.checks.naming

Class MemberNameCheck

public class MemberNameCheck extends AbstractNameCheck

Checks that instance variable names conform to a format specified by the format property. The format is a {@link java.util.regex.Pattern regular expression} and defaults to ^[a-z][a-zA-Z0-9]*$.

An example of how to configure the check is:

 <module name="MemberName"/>
 

An example of how to configure the check for names that begin with "m", followed by an upper case letter, and then letters and digits is:

 <module name="MemberName">
    <property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/>
 </module>
 

Version: 1.0

Author: Rick Giles

Constructor Summary
MemberNameCheck()
Creates a new MemberNameCheck instance.
Method Summary
booleangetApplyToPackage()
booleangetApplyToPrivate()
booleangetApplyToProtected()
booleangetApplyToPublic()
int[]getDefaultTokens()
{@inheritDoc}
protected booleanmustCheckName(DetailAST aAST)
{@inheritDoc}
voidsetApplyToPackage(boolean aApplyTo)
Sets whether we should apply the check to package-private members.
voidsetApplyToPrivate(boolean aApplyTo)
Sets whether we should apply the check to private members.
voidsetApplyToProtected(boolean aApplyTo)
Sets whether we should apply the check to protected members.
voidsetApplyToPublic(boolean aApplyTo)
Sets whether we should apply the check to public members.

Constructor Detail

MemberNameCheck

public MemberNameCheck()
Creates a new MemberNameCheck instance.

Method Detail

getApplyToPackage

public boolean getApplyToPackage()

Returns: true if the check should be applied to package-private members.

getApplyToPrivate

public boolean getApplyToPrivate()

Returns: true if the check should be applied to private members.

getApplyToProtected

public boolean getApplyToProtected()

Returns: true if the check should be applied to protected members.

getApplyToPublic

public boolean getApplyToPublic()

Returns: true if the check should be applied to public members.

getDefaultTokens

public int[] getDefaultTokens()
{@inheritDoc}

mustCheckName

protected final boolean mustCheckName(DetailAST aAST)
{@inheritDoc}

setApplyToPackage

public void setApplyToPackage(boolean aApplyTo)
Sets whether we should apply the check to package-private members.

Parameters: aApplyTo new value of the property.

setApplyToPrivate

public void setApplyToPrivate(boolean aApplyTo)
Sets whether we should apply the check to private members.

Parameters: aApplyTo new value of the property.

setApplyToProtected

public void setApplyToProtected(boolean aApplyTo)
Sets whether we should apply the check to protected members.

Parameters: aApplyTo new value of the property.

setApplyToPublic

public void setApplyToPublic(boolean aApplyTo)
Sets whether we should apply the check to public members.

Parameters: aApplyTo new value of the property.