Class AbstractClassCouplingCheck.ClassContext

  • Enclosing class:
    AbstractClassCouplingCheck

    private class AbstractClassCouplingCheck.ClassContext
    extends java.lang.Object
    Encapsulates information about class coupling.
    • Field Detail

      • referencedClassNames

        private final java.util.Set<java.lang.String> referencedClassNames
        Set of referenced classes. Sorted by name for predictable error messages in unit tests.
      • className

        private final java.lang.String className
        Own class name.
      • lineNo

        private final int lineNo
        Line number of class definition.
      • columnNo

        private final int columnNo
        Column number of class definition.
    • Constructor Detail

      • ClassContext

        ClassContext​(AbstractClassCouplingCheck.FileContext parentContext,
                     java.lang.String className,
                     int lineNo,
                     int columnNo)
        Create new context associated with given class.
        Parameters:
        parentContext - Parent file context.
        className - name of the given class.
        lineNo - line of class definition.
        columnNo - column of class definition.
    • Method Detail

      • 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

        private void addReferencedClassName​(DetailAST ast)
        Adds new referenced class.
        Parameters:
        ast - a node which represents referenced class.
      • addReferencedClassName

        private void addReferencedClassName​(java.lang.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​(java.lang.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​(java.lang.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.