Example usage for java.util Collection forEach

List of usage examples for java.util Collection forEach

Introduction

In this page you can find the example usage for java.util Collection 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:org.onosproject.vpls.IntentInstaller.java

/**
 * Requests to install the intents passed as argument to the Intent Service.
 *
 * @param intents intents to be submitted
 *//*from w w  w  .  j a  v a2s. c o  m*/
private void submitIntents(Collection<Intent> intents) {
    log.debug("Submitting intents to the Intent Synchronizer");
    intents.forEach(intent -> {
        intentSynchronizer.submit(intent);
    });
}

From source file:com.ebay.myriad.state.SchedulerState.java

public void deleteCluster(String clusterId) {
    Collection<NodeTask> nodes = clusters.get(clusterId).getNodes();
    nodes.forEach(node -> this.makeTaskKillable(node));
    // TODO(mohit): Make this more correct.
    this.clusters.remove(clusterId);
}

From source file:ch.sdi.core.util.ClassUtilTest.java

/**
 * Test method for {@link ch.sdi.core.util.ClassUtil#findCandidatesByAnnotation(java.lang.Class, java.lang.String)}.
 *//*from  ww  w .j  av  a2s.c o  m*/
@Test
public void testFindCandidatesByAnnotation() {
    myLog.debug("we parse all classes which are below the top level package");
    String pack = this.getClass().getPackage().getName();
    myLog.debug("found package: " + pack);
    pack = pack.replace('.', '/');
    String root = pack.split("/")[0];

    Collection<? extends Class<?>> received = ClassUtil.findCandidatesByAnnotation(SdiProps.class, root);

    Assert.assertNotNull(received);
    Assert.assertTrue(received.size() > 0);
    received.forEach(c -> myLog.debug("Found class with annotation @SdiProps: " + c.getName()));

}

From source file:org.lambda3.indra.core.RelatednessClient.java

Map<String, Map<String, Double>> getNeighborRelatedness(List<String> terms, int topk, Threshold threshold,
        Filter filter, RelatednessFunction func, VectorComposer termComposer,
        VectorComposer translationComposer) {
    logger.trace("getting neighbors Relatedness for {} terms and {} topk", terms.size(), topk);
    List<AnalyzedTerm> analyzedTerms = doAnalyze(null, terms);

    Map<String, Map<String, Double>> results = new HashMap<>();

    analyzedTerms.stream().parallel().forEach(at -> {
        Collection<String> nearestTerms = vectorSpace.getNearestTerms(at, topk, filter);

        List<AnalyzedTerm> analyzedNeighbors = new LinkedList<>();
        nearestTerms.forEach(t -> analyzedNeighbors.add(new AnalyzedTerm(t, Collections.singletonList(t))));
        analyzedNeighbors.add(at);/*from   w ww .ja v a  2 s .c  o  m*/

        Map<String, Double> relatedness = getRelatedness(at.getFirstToken(), nearestTerms, analyzedNeighbors,
                threshold, false, func, termComposer, translationComposer);

        results.put(at.getTerm(), relatedness);
    });

    logger.trace("done");
    return results;
}

From source file:org.lightjason.agentspeak.consistency.TestCMetric.java

/**
 * generates an agent//from w  ww  . ja  v  a2s  .c  om
 *
 * @param p_literals literal collection
 * @return agent
 */
private CAgent agent(final Collection<ILiteral> p_literals) {
    Assume.assumeNotNull(m_generator);

    final CAgent l_agent = m_agentgenerator.generatesingle();
    p_literals.forEach(i -> l_agent.beliefbase().generate(m_generator, i.functorpath()).add(i));
    return l_agent;
}

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

/**
 * @param aResult//from  www  . j ava 2  s  . c o  m
 * @param aMessages
 */
private void appendSummary(StringBuilder aSb, Collection<ReportMsg> aMessages) {
    aMessages.forEach(msg -> {
        Object value = msg.getValue();

        if (value instanceof Collection) {
            value = ((Collection<?>) value).size();
        }

        appendSimpleEntry(aSb, msg.getKey(), value);
    });
}

From source file:com.scottieknows.test.cassandra.CassandraClusterManager.java

private void execHqlInitFiles(ApplicationContext ctx) {
    String files = cassandraConfigurationProperties.getHqlInitFiles();
    if (files == null || files.trim().isEmpty()) {
        return;//ww w.ja va  2s .co  m
    }
    Cluster cluster = ctx.getBean(Cluster.class);
    Session session = cluster.connect();
    String[] toks = files.split(",");
    for (String f : toks) {
        try {
            Resource resource = ctx.getResource(f);
            File file = null;
            if (resource == null || (file = resource.getFile()) == null) {
                continue;
            }
            Collection<String> hqls = getHqls(file);
            hqls.forEach(hql -> session.execute(hql));
        } catch (IOException e) {
            throw new RuntimeException(format("problem initializing hql from file %s: %s", f, e), e);
        }
    }
}

From source file:com.netflix.spinnaker.clouddriver.google.controllers.GoogleNamedImageLookupController.java

private Map<String, List<Image>> listImagesByAccount() {
    Collection<String> identifiers = cacheView.filterIdentifiers(IMAGES.getNs(),
            GoogleCloudProvider.getID() + ":*");
    Map<String, List<Image>> result = new HashMap<>();

    Collection<CacheData> allCacheData = cacheView.getAll(IMAGES.getNs(), identifiers,
            RelationshipCacheFilter.none());
    allCacheData.forEach(cacheData -> {
        String account = Keys.parse(cacheData.getId()).get("account");
        if (!result.containsKey(account)) {
            result.put(account, new ArrayList<>());
        }//from w w w .  j  av  a 2 s . c  o m
        Object hashImage = cacheData.getAttributes().get("image");
        try {
            Image myImage = jsonMapper.fromString(objectMapper.writeValueAsString(hashImage), Image.class);
            result.get(account).add(myImage);
        } catch (IOException e) {
            throw new RuntimeException("Image deserialization failed");
        }
    });

    return result;
}

From source file:ch.sdi.core.util.ClassUtilTest.java

/**
 * Test method for {@link ch.sdi.core.util.ClassUtil#findCandidatesByAnnotation(java.lang.Class, java.lang.String)}.
 *//*w  ww .  j a v  a  2s . com*/
@Test
public void testFindCandidatesByAnnotationAndType() {
    myLog.debug("we parse all classes which are below the top level package");
    String pack = this.getClass().getPackage().getName();
    myLog.debug("found package: " + pack);
    pack = pack.replace('.', '/');
    String root = pack.split("/")[0];

    Collection<? extends Class<?>> received = ClassUtil.findCandidatesByAnnotation(ConverterFactory.class,
            Component.class, root);

    Assert.assertNotNull(received);
    Assert.assertEquals(1, received.size());
    received.forEach(c -> myLog
            .debug("Found class with annotation @Component and type 'ConverterFactory': " + c.getName()));

}

From source file:org.jboss.tools.openshift.internal.ui.models.ObservableResourceCache.java

@Override
public synchronized void flush() {
    Collection<IResource> clone = new ArrayList<>(cache.values());
    clone.forEach(r -> remove(r));
    imageRefToBuildConfigs.clear();/*from   ww w. ja va  2 s  . c  o  m*/
    imageRefToDeployConfigs.clear();
}