Example usage for javax.json JsonArray forEach

List of usage examples for javax.json JsonArray forEach

Introduction

In this page you can find the example usage for javax.json JsonArray forEach.

Prototype

default void forEach(Consumer<? super T> action) 

Source Link

Document

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

Usage

From source file:de.tu_dortmund.ub.data.dswarm.Transform.java

private JsonArray getMappingsFromProjects(final Collection<String> projectIDs, final String serviceName,
        final String engineDswarmAPI) throws Exception {

    final JsonArrayBuilder mappingArrayBuilder = Json.createArrayBuilder();

    for (final String projectID : projectIDs) {

        final JsonArray projectMappings = getMappingsFromProject(projectID, serviceName, engineDswarmAPI);

        if (projectMappings == null) {

            LOG.error(String.format("[%s][%d] couldn't determine mappings from project '%s'", serviceName, cnt,
                    projectID));//w w w . ja v a 2s  . c o m

            continue;
        }

        LOG.info(String.format("[%s][%d] retrieved '%d' mappings from project '%s'", serviceName, cnt,
                projectMappings.size(), projectID));

        projectMappings.forEach(mappingArrayBuilder::add);
    }

    final JsonArray mappingsArray = mappingArrayBuilder.build();

    LOG.info(String.format("[%s][%d] accumulated '%d' mappings from all projects", serviceName, cnt,
            mappingsArray.size()));

    return mappingsArray;
}