Example usage for java.util Collection stream

List of usage examples for java.util Collection stream

Introduction

In this page you can find the example usage for java.util Collection stream.

Prototype

default Stream<E> stream() 

Source Link

Document

Returns a sequential Stream with this collection as its source.

Usage

From source file:ch.sdi.report.SdiReporter.java

/**
 * @param aResult//from w  w  w.  j  a v a2s  .  c om
 * @param aProcessFailed
 */
private void appendFailedPersons(StringBuilder aSb, Collection<ReportMsg> aProcessFailed) {
    appendTitle(aSb, "Failed during processing", "-");

    aProcessFailed.stream()
            .filter(msg -> (msg.getKey().equals("FailedPersons")) && msg.getValue() instanceof Collection)
            .map(msg -> Collection.class.cast(msg.getValue())).forEach(list -> appendPersonList(aSb, list));
}

From source file:com.enitalk.configs.DateCache.java

@PostConstruct
public void init() throws ExecutionException {
    Collection<String> ids = finder.teachers();
    if (ids.isEmpty()) {
        logger.warn("No teachers found at all");
        return;/*from  w  ww  . ja v a  2  s.c om*/
    }

    ids.stream().forEach((String i) -> {
        try {
            datesMap().get(i);
        } catch (Exception ex) {
            logger.error(ExceptionUtils.getFullStackTrace(ex));
        }
    });
}

From source file:com.ikanow.aleph2.analytics.storm.services.RemoteStormController.java

/**
 * Merges any number of maps, later maps will overwrite any previous keys e.g. if maps[0].key1=5 and maps[2].key1=12
 * the final map will have key1=12 because it'll overwrite the prior value.
 * /*from   www. j  a v a2s.  com*/
 * Note: This does not use the google library ImmutableMap because they do not support
 * null values and the defaults.yaml this is commonly used to load up has many null values.
 * 
 * @param maps
 * @return
 */
private Map<String, Object> mergeMaps(final Collection<Map<String, Object>> maps) {
    final Map<String, Object> map_to_return = new HashMap<String, Object>();
    maps.stream().forEach(map -> map_to_return.putAll(map));
    return map_to_return;
}

From source file:io.github.moosbusch.lumpi.application.spi.AbstractLumpiApplicationContext.java

protected boolean isValidBeanConfigurationClasses(Collection<Class<?>> beanConfigurationClasses) {
    return beanConfigurationClasses.stream().anyMatch((
            beanConfigurationClass) -> (PivotBeanConfiguration.class.isAssignableFrom(beanConfigurationClass)));
}

From source file:com.ikanow.aleph2.analytics.services.DeduplicationEnrichmentContext.java

/** Called for every new/existing merge
 * @param id_duplicate_map/*  w  w w . ja  v a 2 s  .co m*/
 * @param grouping_key
 */
public void resetMutableState(final Collection<JsonNode> dups, final JsonNode grouping_key) {
    _mutable_state._id_set = dups.stream().map(j -> j.get(AnnotationBean._ID)).filter(id -> null != id)
            .collect(Collectors.toSet());

    _mutable_state._grouping_key = _json_to_grouping_key.apply(grouping_key);
    _mutable_state._num_emitted = 0;
    _mutable_state._manual_ids_to_delete = new LinkedList<JsonNode>();
}

From source file:com.thinkbiganalytics.metadata.jobrepo.nifi.provenance.NifiBulletinExceptionExtractor.java

/**
 * queries for bulletins from component, in the flow file
 *
 * @param processorIds The collection UUID of the flow file to extract the error message from
 * @return a list of bulletin objects that were posted by the component to the flow file
 * @throws NifiConnectionException if cannot query Nifi
 */// w  ww .j a  va2 s  .  c o  m
public List<BulletinDTO> getErrorBulletinsForProcessorId(Collection<String> processorIds, Long afterId)
        throws NifiConnectionException {
    List<BulletinDTO> bulletins;
    try {
        String regexPattern = processorIds.stream().collect(Collectors.joining("|"));
        if (afterId != null && afterId != -1L) {
            bulletins = nifiRestClient.getBulletinsMatchingSource(regexPattern, afterId);
        } else {
            bulletins = nifiRestClient.getBulletinsMatchingSource(regexPattern, null);
        }

        bulletins = nifiRestClient.getProcessorBulletins(regexPattern);
        log.info("Query for {} bulletins returned {} results ", regexPattern, bulletins.size());
        if (bulletins != null && !bulletins.isEmpty()) {
            bulletins = bulletins.stream()
                    .filter(bulletinDTO -> bulletinErrorLevels.contains(bulletinDTO.getLevel().toUpperCase()))
                    .collect(Collectors.toList());
        }

        return bulletins;
    } catch (NifiClientRuntimeException e) {
        if (e instanceof NifiConnectionException) {
            throw e;
        } else {
            log.error("Error getErrorBulletinsForProcessorId {} ,{}  ", processorIds, e.getMessage());
        }
    }
    return null;
}

From source file:grakn.core.server.session.reader.GraknCqlBridgeRecordReader.java

private String makeColumnList(Collection<String> columns) {
    return columns.stream().map(this::quote).collect(Collectors.joining(","));
}

From source file:io.mindmaps.engine.loader.DistributedLoader.java

public void submitBatch(Collection<Var> batch) {
    String batchedString = batch.stream().map(Object::toString).collect(Collectors.joining(";"));

    if (batchedString.length() == 0) {
        return;//  ww  w  . j  a  va  2 s  . c  o m
    }

    HttpURLConnection currentConn = acquireNextHost();
    String query = REST.HttpConn.INSERT_PREFIX + batchedString;

    executePost(currentConn, query);

    int responseCode = getResponseCode(currentConn);
    if (responseCode != REST.HttpConn.HTTP_TRANSACTION_CREATED) {
        throw new HTTPException(responseCode);
    }

    markAsLoading(getResponseBody(currentConn));
    LOG.info("Transaction sent to host: " + hostsArray[currentHost]);

    if (future == null) {
        startCheckingStatus();
    }

    currentConn.disconnect();
}

From source file:io.mindmaps.loader.DistributedLoader.java

public void submitBatch(Collection<Var> batch) {
    String batchedString = batch.stream().map(Object::toString).collect(Collectors.joining(";"));

    if (batchedString.length() == 0) {
        return;/*  w ww  . j a v  a2 s . c om*/
    }

    HttpURLConnection currentConn = acquireNextHost();
    String query = RESTUtil.HttpConn.INSERT_PREFIX + batchedString;

    executePost(currentConn, query);

    int responseCode = getResponseCode(currentConn);
    if (responseCode != RESTUtil.HttpConn.HTTP_TRANSACTION_CREATED) {
        throw new HTTPException(responseCode);
    }

    markAsLoading(getResponseBody(currentConn));
    LOG.info("Transaction sent to host: " + hostsArray[currentHost]);

    if (future == null) {
        startCheckingStatus();
    }

    currentConn.disconnect();
}

From source file:org.trustedanalytics.servicecatalog.unit.ServiceInstancesControllerTest.java

@Test
public void getAllServiceInstances_getInstancesCreatorsFromStore() {
    ServiceInstanceMetadata metadata = new ServiceInstanceMetadata(UUID.randomUUID(), "test-user");
    when(serviceInstanceRegistry.getInstanceCreator(any(UUID.class))).thenReturn(metadata);

    Collection<ServiceInstance> serviceInstances = sut.getAllServiceInstances(SPACE_GUID, null);

    verify(serviceInstanceRegistry, times(serviceInstances.size())).getInstanceCreator(any(UUID.class));
    serviceInstances.stream().allMatch(i -> i.getMetadata().getCreatorName() != null);
    serviceInstances.stream().allMatch(i -> i.getMetadata().getCreatorUUID() != null);
}