}
@Override
public void visitToken(DetailAST aAST)
{
final DetailAST objBlock = aAST.findFirstToken(TokenTypes.OBJBLOCK);
DetailAST child = (DetailAST) objBlock.getFirstChild();
boolean hasMethodOrField = false;
boolean hasNonStaticMethodOrField = false;
boolean hasDefaultCtor = true;
boolean hasPublicCtor = false;
while (child != null) {
final int type = child.getType();
if (type == TokenTypes.METHOD_DEF
|| type == TokenTypes.VARIABLE_DEF)
{
hasMethodOrField = true;
final DetailAST modifiers =
child.findFirstToken(TokenTypes.MODIFIERS);
final boolean isStatic =
modifiers.branchContains(TokenTypes.LITERAL_STATIC);
final boolean isPrivate =
modifiers.branchContains(TokenTypes.LITERAL_PRIVATE);
if (!isStatic && !isPrivate) {
hasNonStaticMethodOrField = true;
}
}
if (type == TokenTypes.CTOR_DEF) {
hasDefaultCtor = false;
final DetailAST modifiers =
child.findFirstToken(TokenTypes.MODIFIERS);
if (!modifiers.branchContains(TokenTypes.LITERAL_PRIVATE)
&& !modifiers.branchContains(TokenTypes.LITERAL_PROTECTED))
{
// treat package visible as public
// for the purpose of this Check
hasPublicCtor = true;
}