super(adapters);
}
@Override
public ClassDeclaration adapt(ClassDeclarationContext context) {
ClassDeclaration classDeclaration = createNode(context);
Identifier name =
transformOne(context, TerminalNode.class, new Function<TerminalNode, Identifier>() {
@Override
public Identifier apply(TerminalNode node) {
if (node.getSymbol().getType() == JavaParser.Identifier) {
return getAdapter(IdentifierAdapter.class).adapt(node);
} else {
return null;
}
}
});
classDeclaration.setName(name);
TypeParametersContext typeParametersContext = getChild(context, TypeParametersContext.class);
if (typeParametersContext != null) {
classDeclaration.setTypeParameters(
getAdapter(TypeParametersAdapter.class).adapt(typeParametersContext));
}
TypeContext typeContext = getChild(context, TypeContext.class);
if (typeContext != null) {
classDeclaration.setExtendsType(getAdapter(TypeAdapter.class).adapt(typeContext));
}
TypeListContext typeListContext = getChild(context, TypeListContext.class);
if (typeListContext != null) {
classDeclaration.setImplementsTypes(getAdapter(TypeListAdapter.class).adapt(typeListContext));
}
ClassBodyContext classBodyContext = getChild(context, ClassBodyContext.class);
if (classBodyContext != null) {
classDeclaration.setMemberDeclarations(
getAdapter(ClassBodyAdapter.class).adapt(classBodyContext));
}
return classDeclaration;
}