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

  1. applyToPublic, default true;
  2. applyToProtected, default true;
  3. applyToPackage, default true;
  4. applyToPrivate, default true;
  • Field Details

    • 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.
  • Constructor Details

    • AbstractAccessControlNameCheck

      Creates a new AbstractAccessControlNameCheck instance.
      Parameters:
      format - format to check with
  • Method Details

    • 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.
    • isPublic

      private static boolean isPublic(DetailAST modifiers)
      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

      public void setApplyToPublic(boolean applyTo)
      Setter to control if check should apply to public members.
      Parameters:
      applyTo - new value of the property.
    • setApplyToProtected

      public void setApplyToProtected(boolean applyTo)
      Setter to control if check should apply to protected members.
      Parameters:
      applyTo - new value of the property.
    • setApplyToPackage

      public void setApplyToPackage(boolean applyTo)
      Setter to control if check should apply to package-private members.
      Parameters:
      applyTo - new value of the property.
    • setApplyToPrivate

      public void setApplyToPrivate(boolean applyTo)
      Setter to control if check should apply to private members.
      Parameters:
      applyTo - new value of the property.