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:com.khartec.waltz.jobs.CapabilityHarness.java

public static void main(String[] args) {

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);

    DSLContext dsl = ctx.getBean(DSLContext.class);

    CapabilityDao dao = ctx.getBean(CapabilityDao.class);

    CapabilityIdSelectorFactory selectorFactory = ctx.getBean(CapabilityIdSelectorFactory.class);

    Select<Record1<Long>> selector = selectorFactory.apply(ImmutableIdSelectionOptions.builder()
            .entityReference(ImmutableEntityReference.builder().kind(EntityKind.APP_GROUP).id(5L).build())
            .scope(HierarchyQueryScope.PARENTS).build());

    Collection<Capability> caps = dao.findByIdSelector(selector);
    caps.forEach(c -> System.out.println(c.name()));

}

From source file:Main.java

public static void listValues(Map<String, String> map) {
    System.out.println("Values Collection:");
    Collection<String> values = map.values();
    values.forEach(System.out::println);
    System.out.println();/* w w  w  .  ja v a 2s.  com*/
}

From source file:com.ibm.watson.catalyst.corpus.util.JsonUtil.java

public static ArrayNode toArrayNodeString(Collection<String> aCollection) {
    ArrayNode result = MAPPER.createArrayNode();
    aCollection.forEach((aString) -> result.add(aString));
    return result;
}

From source file:org.apdplat.superword.rule.RootRule.java

public static TreeMap<Word, List<Word>> findByRoot(Collection<Word> words, Collection<Word> roots) {
    TreeMap<Word, List<Word>> map = new TreeMap<>();
    roots.forEach(root -> map.put(root, findByRoot(words, root)));
    return map;//from   w  w w.j a v a2 s . c om
}

From source file:com.ibm.watson.catalyst.corpus.util.JsonUtil.java

public static ArrayNode toArrayNodeJsonable(Collection<? extends Jsonable> aCollection) {
    ArrayNode result = MAPPER.createArrayNode();
    aCollection.forEach((aJsonable) -> result.add(aJsonable.toJson()));
    return result;
}

From source file:org.apache.syncope.common.lib.EntityTOUtils.java

public static Map<String, AttrTO> buildAttrMap(final Collection<AttrTO> attrs) {
    Map<String, AttrTO> result = new HashMap<>(attrs.size());
    attrs.forEach(attrTO -> result.put(attrTO.getSchema(), attrTO));

    return Collections.unmodifiableMap(result);
}

From source file:org.apache.syncope.common.lib.EntityTOUtils.java

public static Map<String, MembershipTO> buildMembershipMap(final Collection<MembershipTO> memberships) {
    Map<String, MembershipTO> result = new HashMap<>(memberships.size());
    memberships.forEach(memb -> result.put(memb.getGroupKey(), memb));

    return Collections.unmodifiableMap(result);
}

From source file:org.apache.syncope.common.lib.EntityTOUtils.java

public static Map<Pair<String, String>, RelationshipTO> buildRelationshipMap(
        final Collection<RelationshipTO> relationships) {

    Map<Pair<String, String>, RelationshipTO> result = new HashMap<>(relationships.size());
    relationships.forEach(rel -> result.put(Pair.of(rel.getType(), rel.getOtherEndKey()), rel));

    return Collections.unmodifiableMap(result);
}

From source file:io.github.pellse.decorator.util.reflection.ReflectionUtils.java

public static <T> void setFields(T obj, Collection<Field> fields, Object value, boolean override) {
    fields.forEach(field -> CheckedRunnable.of(() -> privateSetField(obj, field, value, override)).run());
}

From source file:org.kie.wb.test.rest.RestTestBase.java

protected static void deleteAllSpaces() {
    Collection<Space> spaces = client.getSpaces();
    log.info("Deleting {} spaces", spaces.size());
    spaces.forEach(space -> {
        stopWatch.reset();/*  ww  w .  j  av a 2  s.c  o m*/
        stopWatch.start();
        try {
            client.deleteSpace(space.getName());
        } finally {
            stopWatch.stop();
            log.debug("Deleting space '{}' took {} ms", space.getName(), stopWatch.getTime());
        }
    });
}