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.diorite.impl.entity.attrib.AttributePropertyImpl.java

public AttributePropertyImpl(final AttributeType type, final Collection<AttributeModifier> modifiers,
        final double value) {
    this.type = type;
    this.value = value;
    if (modifiers != null) {
        this.modifiers = new ConcurrentHashMap<>(modifiers.size() + 1, 0.3f, 8);
        modifiers.forEach(mod -> this.modifiers.put(mod.getUuid(), mod));
    } else {/*from www .j  a v  a 2 s  .  co  m*/
        this.modifiers = new ConcurrentHashMap<>(5, 0.3f, 8);
    }
    this.recalculateFinalValue();
}

From source file:com.antonjohansson.svncommit.core.utils.SubversionImpl.java

/** {@inheritDoc} */
@Override/*from w  w w  .  ja va 2  s . co m*/
public void commit(String message, Collection<String> filePaths, Consumer<String> onData,
        Consumer<Boolean> onComplete) {
    File temporaryFile = shell.getTemporaryFile(asList(message), "commit-message");

    StringBuilder command = new StringBuilder("svn commit").append(" --file '")
            .append(temporaryFile.getAbsolutePath()).append("'");

    filePaths.forEach(c -> command.append(" '").append(c).append("'"));

    shell.executeAndPipeOutput(onData, onData, onComplete, command.toString());
}

From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.PhotoInspectorImpl.java

private <T> void addExifCell(String key, Collection<T> entities, Function<T, Object> mapper) {
    Set<String> values = new HashSet<>();
    entities.forEach(t -> {
        String value = null;/*  w w w.j av  a2 s.c o  m*/
        Object obj = mapper.apply(t);
        if (obj != null) {
            value = obj.toString();
        }
        values.add(value);
    });
    boolean indetermined = values.size() != 1;

    KeyValueCell cell = new KeyValueCell();
    cell.setKey(key);
    cell.setIndetermined(indetermined);
    if (!indetermined) {
        cell.setValue(values.iterator().next());
    }
    exifList.getChildren().add(cell);
}

From source file:org.onosproject.drivers.ciena.waveserver.rest.CienaRestDevice.java

/**
 * remove the given flow rules form the cross-connect cache.
 *
 * @param flowRules flow rules that needs to be removed from cache.
 *//*from ww w  .  ja  v a 2s.  c  o  m*/
public void removeCrossConnectCache(Collection<FlowRule> flowRules) {
    flowRules.forEach(xc -> crossConnectCache.remove(Objects.hash(deviceId, xc.selector(), xc.treatment())));
}

From source file:org.onosproject.drivers.ciena.waveserver.rest.CienaRestDevice.java

/**
 * add the given flow rules to cross connect-cache.
 *
 * @param flowRules flow rules that needs to be cached.
 *//*from  w w  w. ja va  2 s .c om*/
public void setCrossConnectCache(Collection<FlowRule> flowRules) {
    flowRules.forEach(xc -> crossConnectCache.set(Objects.hash(deviceId, xc.selector(), xc.treatment()),
            xc.id(), xc.priority()));
}

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

public void addClusterNodes(String clusterId, Collection<NodeTask> nodes) {
    Preconditions.checkArgument(!Strings.isNullOrEmpty(clusterId));

    Cluster cluster = this.clusters.get(clusterId);

    // TODO(mohit): error handling

    nodes.forEach(node -> {
        cluster.addNode(node);/* ww  w.  j ava  2 s . c o  m*/
        String taskId = node.getTaskId();
        tasks.put(taskId, node);
        pendingTasks.add(taskId);
    });
}

From source file:io.klerch.alexa.state.handler.AWSS3StateHandler.java

/**
 * {@inheritDoc}//from   w ww  . j ava 2  s . com
 */
@Override
public void removeValues(final Collection<String> ids) throws AlexaStateException {
    super.removeValues(ids);
    final List<DeleteObjectsRequest.KeyVersion> keys = new ArrayList<>();
    ids.forEach(id -> keys.addAll(Arrays.asList(new DeleteObjectsRequest.KeyVersion(getUserScopedFilePath(id)),
            new DeleteObjectsRequest.KeyVersion(getAppScopedFilePath(id)))));
    final DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucketName).withKeys(keys);
    awsClient.deleteObjects(deleteObjectsRequest);
}

From source file:com.ethlo.geodata.restdocs.AbstractJacksonFieldSnippet.java

protected ObjectNode getSchema(Operation operation, final Class<?> pojo, boolean isResponse) {
    try {/*from   w w w  .  j  a v a  2 s .c o m*/
        final ObjectNode schema = (ObjectNode) generator.generateSchema(pojo, isResponse);

        final Collection<FieldDescriptor> fieldDescriptors = createFieldDescriptors(operation, pojo);

        // Add field descriptions on top of JSON schema
        fieldDescriptors.forEach(desc -> {
            final String[] pathArr = org.apache.commons.lang3.StringUtils.split(desc.getPath(), '.');
            final Iterator<String> path = Arrays.asList(pathArr).iterator();
            final ObjectNode definitionsNode = schema.get("definitions") != null
                    ? (ObjectNode) schema.get("definitions")
                    : schema.objectNode();
            handleSchema(pojo, schema, definitionsNode, desc, path);
        });

        allSchemas.put(pojo, schema);
        ((ObjectNode) schema).remove("definitions");

        return schema;
    } catch (RuntimeException exc) {
        exc.printStackTrace();
        throw exc;
    }
}

From source file:org.sonar.server.qualityprofile.QProfileFactoryImpl.java

@Override
public void delete(DbSession dbSession, Collection<QProfileDto> profiles) {
    if (profiles.isEmpty()) {
        return;//from   www.  j a  v  a  2  s  .  c o  m
    }

    Set<String> uuids = new HashSet<>();
    List<QProfileDto> customProfiles = new ArrayList<>();
    Set<String> rulesProfileUuidsOfCustomProfiles = new HashSet<>();
    profiles.forEach(p -> {
        uuids.add(p.getKee());
        if (!p.isBuiltIn()) {
            customProfiles.add(p);
            rulesProfileUuidsOfCustomProfiles.add(p.getRulesProfileUuid());
        }
    });

    // tables org_qprofiles, default_qprofiles and project_qprofiles
    // are deleted whatever custom or built-in
    db.qualityProfileDao().deleteProjectAssociationsByProfileUuids(dbSession, uuids);
    db.defaultQProfileDao().deleteByQProfileUuids(dbSession, uuids);
    db.qualityProfileDao().deleteOrgQProfilesByUuids(dbSession, uuids);

    // Permissions are only available on custom profiles
    db.qProfileEditUsersDao().deleteByQProfiles(dbSession, customProfiles);
    db.qProfileEditGroupsDao().deleteByQProfiles(dbSession, customProfiles);

    // tables related to rules_profiles and active_rules are deleted
    // only for custom profiles. Built-in profiles are never
    // deleted from table rules_profiles.
    if (!rulesProfileUuidsOfCustomProfiles.isEmpty()) {
        db.activeRuleDao().deleteParametersByRuleProfileUuids(dbSession, rulesProfileUuidsOfCustomProfiles);
        db.activeRuleDao().deleteByRuleProfileUuids(dbSession, rulesProfileUuidsOfCustomProfiles);
        db.qProfileChangeDao().deleteByRulesProfileUuids(dbSession, rulesProfileUuidsOfCustomProfiles);
        db.qualityProfileDao().deleteRulesProfilesByUuids(dbSession, rulesProfileUuidsOfCustomProfiles);
        activeRuleIndexer.commitDeletionOfProfiles(dbSession, customProfiles);
    } else {
        dbSession.commit();
    }
}

From source file:org.craftercms.deployer.impl.DeploymentResolverImpl.java

protected List<DeploymentContext> resolveContextsFromCustomConfigFile(Collection<File> configFiles) {
    List<DeploymentContext> deploymentContexts = new ArrayList<>();

    // Get current contexts
    configFiles.forEach(file -> {
        String deploymentId = getDeploymentIdFromFilename(file);
        DeploymentContext deploymentContext = getDeploymentContext(deploymentId, file);

        deploymentContexts.add(deploymentContext);
    });/*w ww.ja  v  a 2 s  .c  om*/

    return deploymentContexts;
}