Class RequireThisCheck.ClassFrame

java.lang.Object
com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck.AbstractFrame
com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck.ClassFrame
Direct Known Subclasses:
RequireThisCheck.AnonymousClassFrame
Enclosing class:
RequireThisCheck

A frame initiated at class, enum or interface definition; holds instance variable names.
  • Field Details

  • Constructor Details

  • Method Details

    • getType

      Description copied from class: RequireThisCheck.AbstractFrame
      Get the type of the frame.
      Specified by:
      getType in class RequireThisCheck.AbstractFrame
      Returns:
      a FrameType.
    • addStaticMember

      public void addStaticMember(DetailAST ident)
      Adds static member's ident.
      Parameters:
      ident - an ident of static member of the class.
    • addStaticMethod

      public void addStaticMethod(DetailAST ident)
      Adds static method's name.
      Parameters:
      ident - an ident of static method of the class.
    • addInstanceMember

      public void addInstanceMember(DetailAST ident)
      Adds instance member's ident.
      Parameters:
      ident - an ident of instance member of the class.
    • addInstanceMethod

      public void addInstanceMethod(DetailAST ident)
      Adds instance method's name.
      Parameters:
      ident - an ident of instance method of the class.
    • hasInstanceMember

      public boolean hasInstanceMember(DetailAST ident)
      Checks if a given name is a known instance member of the class.
      Parameters:
      ident - the IDENT ast of the name to check.
      Returns:
      true is the given name is a name of a known instance member of the class.
    • hasInstanceMethod

      public boolean hasInstanceMethod(DetailAST ident)
      Checks if a given name is a known instance method of the class.
      Parameters:
      ident - the IDENT ast of the method call to check.
      Returns:
      true if the given ast is correspondent to a known instance method of the class.
    • hasStaticMethod

      public boolean hasStaticMethod(DetailAST ident)
      Checks if a given name is a known static method of the class.
      Parameters:
      ident - the IDENT ast of the method call to check.
      Returns:
      true is the given ast is correspondent to a known instance method of the class.
    • hasFinalField

      public boolean hasFinalField(DetailAST instanceMember)
      Checks whether given instance member has final modifier.
      Parameters:
      instanceMember - an instance member of a class.
      Returns:
      true if given instance member has final modifier.
    • containsFieldOrVariable

      protected boolean containsFieldOrVariable(DetailAST identToFind)
      Description copied from class: RequireThisCheck.AbstractFrame
      Check whether the frame contains a field or a variable with the given name.
      Overrides:
      containsFieldOrVariable in class RequireThisCheck.AbstractFrame
      Parameters:
      identToFind - the IDENT ast of the name we're looking for.
      Returns:
      whether it was found.
    • isProperDefinition

      protected boolean isProperDefinition(DetailAST ident, DetailAST ast)
      Description copied from class: RequireThisCheck.AbstractFrame
      Whether the definition is correspondent to the IDENT.
      Overrides:
      isProperDefinition in class RequireThisCheck.AbstractFrame
      Parameters:
      ident - the IDENT ast to check.
      ast - the IDENT ast of the definition to check.
      Returns:
      true if ast is correspondent to ident.
    • getIfContains

      protected RequireThisCheck.AbstractFrame getIfContains(DetailAST identToFind, boolean lookForMethod)
      Description copied from class: RequireThisCheck.AbstractFrame
      Check whether the frame contains a given name.
      Overrides:
      getIfContains in class RequireThisCheck.AbstractFrame
      Parameters:
      identToFind - IDENT ast of the name we're looking for.
      lookForMethod - whether we are looking for a method name.
      Returns:
      whether it was found.
    • containsMethod

      private boolean containsMethod(DetailAST methodToFind)
      Check whether the frame contains a given method.
      Parameters:
      methodToFind - the AST of the method to find.
      Returns:
      true, if a method with the same name and number of parameters is found.
    • containsMethodDef

      private static boolean containsMethodDef(Set<DetailAST> set, DetailAST ident)
      Whether the set contains a method definition with the same name and number of parameters.
      Parameters:
      set - the set of definitions.
      ident - the specified method call IDENT ast.
      Returns:
      true if the set contains a definition with the same name and number of parameters.
    • isSimilarSignature

      private static boolean isSimilarSignature(DetailAST ident, DetailAST ast)
      Whether the method definition has the same name and number of parameters.
      Parameters:
      ident - the specified method call IDENT ast.
      ast - the ast of a method definition to compare with.
      Returns:
      true if a method definition has the same name and number of parameters as the method call.