Class UnusedTryResourceShouldBeUnnamedCheck.TryResourceDetails
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.coding.UnusedTryResourceShouldBeUnnamedCheck.TryResourceDetails
- Enclosing class:
UnusedTryResourceShouldBeUnnamedCheck
Maintains tracking information about a single try-with-resources resource.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DetailASTTheTokenTypes.IDENTtoken for the variable name.private final StringThe name of the resource variable.private booleanWhether the resource has been referenced within the try scope. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateTryResourceDetails(DetailAST identToken) Creates a new instance tracking the resource whose name-token isidentToken. -
Method Summary
Modifier and TypeMethodDescriptionprivate DetailASTReturns theTokenTypes.IDENTtoken used to report violations.private StringgetName()Returns the name of the resource variable.private booleanisUsed()Returns whether this resource has been referenced in the try scope.private voidMarks this resource as having been referenced (used) in the try scope.
-
Field Details
-
name
The name of the resource variable. -
identToken
TheTokenTypes.IDENTtoken for the variable name. Used as the violation position. -
used
Whether the resource has been referenced within the try scope.
-
-
Constructor Details
-
TryResourceDetails
Creates a new instance tracking the resource whose name-token isidentToken.- Parameters:
identToken- theTokenTypes.IDENTtoken for the resource name
-
-
Method Details
-
registerAsUsed
Marks this resource as having been referenced (used) in the try scope. -
getName
Returns the name of the resource variable.- Returns:
- variable name
-
getIdentToken
Returns theTokenTypes.IDENTtoken used to report violations.- Returns:
- IDENT token
-
isUsed
Returns whether this resource has been referenced in the try scope.- Returns:
trueif used
-