Class AbstractClassCouplingCheck.ClassContext
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.checks.metrics.AbstractClassCouplingCheck.ClassContext
-
- Enclosing class:
- AbstractClassCouplingCheck
private class AbstractClassCouplingCheck.ClassContext extends java.lang.ObjectEncapsulates information about class coupling.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringclassNameOwn class name.private intcolumnNoColumn number of class definition.private intlineNoLine number of class definition.private AbstractClassCouplingCheck.FileContextparentContextParent file context.private java.util.Set<java.lang.String>referencedClassNamesSet of referenced classes.
-
Constructor Summary
Constructors Constructor Description ClassContext(AbstractClassCouplingCheck.FileContext parentContext, java.lang.String className, int lineNo, int columnNo)Create new context associated with given class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddReferencedClassName(DetailAST ast)Adds new referenced class.private voidaddReferencedClassName(java.lang.String referencedClassName)Adds new referenced class.voidcheckCoupling()Checks if coupling less than allowed or not.private booleanisFromExcludedPackage(java.lang.String candidateClassName)Checks if given class should be ignored as it belongs to excluded package.private booleanisSignificant(java.lang.String candidateClassName)Checks if given class shouldn't be ignored and not from java.lang.voidvisitLiteralNew(DetailAST ast)Visits NEW.voidvisitLiteralThrows(DetailAST literalThrows)Visits throws clause and collects all exceptions we throw.voidvisitType(DetailAST ast)Visits type.
-
-
-
Field Detail
-
parentContext
private final AbstractClassCouplingCheck.FileContext parentContext
Parent file context.
-
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.
-
-