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.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
ClassContext(String className, DetailAST ast)
Create new context associated with given class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addReferencedClassName(DetailAST ast)
Adds new referenced class.private void
addReferencedClassName(String referencedClassName)
Adds new referenced class.void
checkCoupling()
Checks if coupling less than allowed or not.private Optional<String>
getClassNameWithPackage(String examineClassName)
Retrieves class name with packages.private boolean
isExcludedClassRegexp(String candidateClassName)
Checks if given class should be ignored as it belongs to excluded class regexp.private boolean
isFromExcludedPackage(String candidateClassName)
Checks if given class should be ignored as it belongs to excluded package.private boolean
isSignificant(String candidateClassName)
Checks if given class shouldn't be ignored and not from java.lang.void
visitLiteralNew(DetailAST ast)
Visits NEW.void
visitLiteralThrows(DetailAST literalThrows)
Visits throws clause and collects all exceptions we throw.void
visitType(DetailAST ast)
Visits type.
-
-
-
Constructor Detail
-
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 Detail
-
visitLiteralThrows
public void visitLiteralThrows(DetailAST literalThrows)
Visits throws clause and collects all exceptions we throw.- Parameters:
literalThrows
- throws 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(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.
-
-