if (resourcesContext != null) {
tryStatement.setResources(transform(resourcesContext, ResourceContext.class,
new Function<ResourceContext, Resource>() {
@Override
public Resource apply(ResourceContext context) {
Resource resource = createNode(context, Resource.class);
setModifiers(context, resource);
ClassOrInterfaceTypeContext classOrInterfaceTypeContext =
getChild(context, ClassOrInterfaceTypeContext.class);
if (classOrInterfaceTypeContext != null) {
resource.setType(
getAdapter(ClassOrInterfaceTypeAdapter.class).adapt(
classOrInterfaceTypeContext));
}
VariableDeclaratorIdContext variableDeclaratorIdContext =
getChild(context, VariableDeclaratorIdContext.class);
if (variableDeclaratorIdContext != null) {
TerminalNode identifierNode =
getTerminalNode(variableDeclaratorIdContext, JavaParser.Identifier);
if (identifierNode != null) {
resource.setName(getAdapter(IdentifierAdapter.class).adapt(identifierNode));
}
resource.setDimensions(
getAdapter(ArrayDimensionsAdapter.class).adapt(variableDeclaratorIdContext));
}
ExpressionContext expressionContext = getChild(context, ExpressionContext.class);
if (expressionContext != null) {
resource.setInitializer(
getAdapter(ExpressionAdapter.class).adapt(expressionContext));
}
return resource;
}