Class 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 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:

    1. applyToPublic, default true;
    2. applyToProtected, default true;
    3. applyToPackage, default true;
    4. applyToPrivate, default true;
    • Constructor Detail

      • AbstractAccessControlNameCheck

        protected AbstractAccessControlNameCheck​(java.lang.String format)
        Creates a new AbstractAccessControlNameCheck instance.
        Parameters:
        format - format to check with
    • 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 class AbstractNameCheck
        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.