ForbidCertainImportsCheck extends AbstractCheck { @Override public void visitToken(DetailAST ast) { switch (ast.getType()) { case TokenTypes.PACKAGE_DEF: if (packageNamesRegexp != null) { final String packageQualifiedName = getText(ast); packageMatches = packageNamesRegexp.matcher(packageQualifiedName) .matches(); } break; case TokenTypes.IMPORT: final String importQualifiedText = getText(ast); if (isImportForbidden(importQualifiedText)) { log(ast, importQualifiedText); } break; case TokenTypes.LITERAL_NEW: if (ast.findFirstToken(TokenTypes.DOT) != null) { final String classQualifiedText = getText(ast); if (isImportForbidden(classQualifiedText)) { log(ast, classQualifiedText); } } break; default: SevntuUtil.reportInvalidToken(ast.getType()); break; } }  void setPackageNameRegexp(String packageNameRegexp); String getForbiddenImportRegexp(); void setForbiddenImportsRegexp(String forbiddenImportsRegexp); void setForbiddenImportsExcludesRegexp(String
            forbiddenImportsExcludesRegexp); @Override int[] getDefaultTokens(); @Override int[] getAcceptableTokens(); @Override int[] getRequiredTokens(); @Override void beginTree(DetailAST rootAST); @Override void visitToken(DetailAST ast); static final String MSG_KEY; }
@Test public void testUnsupportedNode() { final DetailAstImpl sync = new DetailAstImpl(); sync.setType(TokenTypes.LITERAL_SYNCHRONIZED); try { final ForbidCertainImportsCheck check = new ForbidCertainImportsCheck(); check.visitToken(sync); fail("exception expected"); } catch (IllegalArgumentException ex) { Assert.assertEquals("Found unsupported token: LITERAL_SYNCHRONIZED", ex.getMessage()); } }