super(adapters);
}
@Override
public EnumDeclaration adapt(EnumDeclarationContext context) {
EnumDeclaration enumDeclaration = createNode(context);
TerminalNode identifierNode = getTerminalNode(context, JavaParser.Identifier);
if (identifierNode != null) {
enumDeclaration.setName(getAdapter(IdentifierAdapter.class).adapt(identifierNode));
}
TypeListContext typeListContext = getChild(context, TypeListContext.class);
if (typeListContext != null) {
List<Type> implementsTypes =
transform(typeListContext, TypeContext.class, new Function<TypeContext, Type>() {
@Override
public Type apply(TypeContext context) {
return getAdapter(TypeAdapter.class).adapt(context);
}
});
enumDeclaration.setImplementsTypes(implementsTypes);
}
EnumConstantsContext enumConstantsContext = getChild(context, EnumConstantsContext.class);
if (enumConstantsContext != null) {
List<EnumConstant> constants =
transform(enumConstantsContext, EnumConstantContext.class,
new Function<EnumConstantContext, EnumConstant>() {
@Override
public EnumConstant apply(EnumConstantContext context) {
return getAdapter(EnumConstantAdapter.class).adapt(context);
}
});
enumDeclaration.setConstants(constants);
}
EnumBodyDeclarationsContext enumBodyDeclarationsContext =
getChild(context, EnumBodyDeclarationsContext.class);
if (enumBodyDeclarationsContext != null) {
List<ClassMemberDeclaration> memberDeclarations =
transform(enumBodyDeclarationsContext, ClassBodyDeclarationContext.class,
new Function<ClassBodyDeclarationContext, ClassMemberDeclaration>() {
@Override
public ClassMemberDeclaration apply(ClassBodyDeclarationContext context) {
return getAdapter(ClassBodyDeclarationAdapter.class).adapt(context);
}
});
enumDeclaration.setMemberDeclarations(memberDeclarations);
}
return enumDeclaration;
}