Class AbstractClassCouplingCheck.ClassContext

java.lang.Object
com.puppycrawl.tools.checkstyle.checks.metrics.AbstractClassCouplingCheck.ClassContext
Enclosing class:
AbstractClassCouplingCheck

private final class AbstractClassCouplingCheck.ClassContext extends Object
Encapsulates information about class coupling.
  • Field Details

  • Constructor Details

    • ClassContext

      private ClassContext (String className, DetailAST ast)
      Create new context associated with given class.
      Parameters:
      className - name of the given class.
      ast - ast of class definition.
  • Method Details

    • visitLiteralThrows

      public void visitLiteralThrows (DetailAST literalThrows)
      Visits throws clause and collects all exceptions we throw.
      Parameters:
      literalThrows - throws to process.
    • visitType

      public void visitType (DetailAST ast)
      Visits type.
      Parameters:
      ast - type to process.
    • visitLiteralNew

      public void visitLiteralNew (DetailAST ast)
      Visits NEW.
      Parameters:
      ast - NEW to process.
    • addReferencedClassName

      Adds new referenced class.
      Parameters:
      ast - a node which represents referenced class.
    • addReferencedClassName

      private void addReferencedClassName (String referencedClassName)
      Adds new referenced class.
      Parameters:
      referencedClassName - class name of the referenced class.
    • checkCoupling

      public void checkCoupling ()
      Checks if coupling less than allowed or not.
    • isSignificant

      private boolean isSignificant (String candidateClassName)
      Checks if given class shouldn't be ignored and not from java.lang.
      Parameters:
      candidateClassName - class to check.
      Returns:
      true if we should count this class.
    • isFromExcludedPackage

      private boolean isFromExcludedPackage (String candidateClassName)
      Checks if given class should be ignored as it belongs to excluded package.
      Parameters:
      candidateClassName - class to check
      Returns:
      true if we should not count this class.
    • getClassNameWithPackage

      private Optional<String> getClassNameWithPackage (String examineClassName)
      Retrieves class name with packages. Uses previously registered imports to get the full class name.
      Parameters:
      examineClassName - Class name to be retrieved.
      Returns:
      Class name with package name, if found, Optional.empty() otherwise.
    • isExcludedClassRegexp

      private boolean isExcludedClassRegexp (String candidateClassName)
      Checks if given class should be ignored as it belongs to excluded class regexp.
      Parameters:
      candidateClassName - class to check.
      Returns:
      true if we should not count this class.