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 Details

    • name

      private final String name
      The name of the resource variable.
    • identToken

      private final DetailAST identToken
      The TokenTypes.IDENT token for the variable name. Used as the violation position.
    • used

      private boolean used
      Whether the resource has been referenced within the try scope.
  • Constructor Details

    • TryResourceDetails

      private TryResourceDetails(DetailAST identToken)
      Creates a new instance tracking the resource whose name-token is identToken.
      Parameters:
      identToken - the TokenTypes.IDENT token for the resource name
  • Method Details

    • registerAsUsed

      private void registerAsUsed()
      Marks this resource as having been referenced (used) in the try scope.
    • getName

      private String getName()
      Returns the name of the resource variable.
      Returns:
      variable name
    • getIdentToken

      Returns the TokenTypes.IDENT token used to report violations.
      Returns:
      IDENT token
    • isUsed

      private boolean isUsed()
      Returns whether this resource has been referenced in the try scope.
      Returns:
      true if used