Example usage for java.util List forEach

List of usage examples for java.util List forEach

Introduction

In this page you can find the example usage for java.util List 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.bbva.arq.devops.ae.mirrorgate.jenkins.plugin.listener.MirrorGateListenerHelper.java

private void sendBuildExtraData(BuildBuilder builder, TaskListener listener) {
    List<String> extraUrl = MirrorGateUtils.getURLList();

    extraUrl.forEach(u -> {
        MirrorGateResponse response = getMirrorGateService()
                .sendBuildDataToExtraEndpoints(builder.getBuildData(), u);

        String msg = "POST to " + u + " succeeded!";
        Level level = Level.FINE;
        if (response.getResponseCode() != HttpStatus.SC_CREATED) {
            msg = "POST to " + u + " failed with code: " + response.getResponseCode();
            level = Level.WARNING;
        }/*from  w w  w.  j a  v a2s. c  o  m*/

        if (listener != null && level == Level.FINE) {
            listener.getLogger().println(msg);
        }
        LOG.log(level, msg);
    });
}

From source file:bg.elkabel.calculator.service.CoreServiceImpl.java

@Override
public List<ChooseCoreView> findAll() {

    List<Core> core = this.coreRepository.findAll();
    List<ChooseCoreView> result = new ArrayList();
    core.forEach(c -> {
        ChooseCoreView currentCore = this.modelMapper.map(c, ChooseCoreView.class);
        result.add(currentCore);//from w ww.  ja v a2  s . co  m
    });

    return result.size() > 0 ? result : null;
}

From source file:fi.vm.kapa.identification.proxy.metadata.MetadataClient.java

public List<AuthenticationProvider> getAuthenticationProviders() {
    List<AuthenticationProvider> providers = new ArrayList<>();
    final String authenticationProviderMetadataReqUrl = metadataServerUrl + "?type="
            + ProviderType.AUTHENTICATION_PROVIDER.toString();
    logger.debug("url to metadata server - authenticationProviders: {}", authenticationProviderMetadataReqUrl);
    try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
        logger.debug("url to metadata server: {}", authenticationProviderMetadataReqUrl);
        HttpGet getMethod = new HttpGet(authenticationProviderMetadataReqUrl);
        List<MetadataDTO> metadata = getMetadataDTOs(httpClient, getMethod);
        metadata.forEach(data -> providers.add(new AuthenticationProvider(data.getName() + "",
                data.getDnsName(), AuthMethod.valueOf(data.getAttributeLevelOfAssurance()),
                data.getAcsAddress(), data.getEntityId())));
    } catch (Exception e) {
        logger.error("Error updating proxy ApprovedAuthenticationProviders", e);
    }/*  w  w w.j av  a2 s  .c om*/
    return providers;
}

From source file:com.zxy.commons.json.JsonTest.java

@Test
public void list() {
    List<Jsons> objects = Lists.newArrayList(jsons);
    String listStr = JsonUtils.toJson(objects);
    System.out.println("listStr:" + listStr);

    List<Jsons> list = JsonUtils.toList(listStr, Jsons.class);
    list.forEach(obj -> System.out.println(obj.getStr1()));
    Assert.assertNotNull(list);//  w ww.j a v  a2 s . c  om
}

From source file:fr.lepellerin.ecole.service.internal.UtilisateurServiceImpl.java

@Override
@Transactional(readOnly = true)/* ww  w .j ava2 s .c o  m*/
public List<String> getUserNameByEmail(final String email) {
    final List<String> accounts = new ArrayList<>();
    final List<Famille> fams = this.familleRepository.findFamilleByEmail(email);
    fams.forEach(fam -> accounts.add(fam.getInternetIdentifiant()));
    return accounts;
}

From source file:io.gravitee.repository.redis.management.internal.impl.ApplicationRedisRepositoryImpl.java

@Override
public Set<RedisApplication> findByGroups(List<String> groups) {
    Set<Object> keys = new HashSet<>();
    groups.forEach(group -> keys.addAll(redisTemplate.opsForSet().members(REDIS_KEY + ":group:" + group)));
    List<Object> apiObjects = redisTemplate.opsForHash().multiGet(REDIS_KEY, keys);

    return apiObjects.stream().map(event -> convert(event, RedisApplication.class)).collect(Collectors.toSet());
}

From source file:gr.aueb.cs.nlp.wordtagger.classifier.MetaClassifier.java

/**
 * creates a feature vector for each output of the input classfiers
 * @param wordSet/*from   w w  w  . j  a  va  2  s .com*/
 * @return
 */
private List<Word> tagsToFeats(List<Word> wordSet) {
    List<Word> words = new ArrayList<>();
    wordSet.forEach(w -> {
        Word a = new Word(w.getValue(), w.getCategory());

        a.setFeatureVec(new FeatureVector(new double[0], model.getCategoryAsOneOfAKDouble(w)));
        words.add(a);
    });
    classifiers.forEach(v -> {
        List<Word> result = v.classifySet(wordSet);
        for (int i = 0; i < result.size(); i++) {
            words.get(i).getFeatureVec().setValues(ArrayUtils.addAll(words.get(i).getFeatureVec().getValues(),
                    model.getCategoryAsOneOfAKDouble(result.get(i))));
        }
    });
    return words;

}

From source file:nc.noumea.mairie.appock.services.impl.ServiceServiceImpl.java

@Override
public List<Service> findAllActif() {
    List<Service> result = serviceRepository.findAllByActifOrderByLibelle(true);
    result.forEach(this::chargeLazy);

    return result;
}

From source file:org.openlmis.fulfillment.web.shipment.ShipmentDtoBuilder.java

private List<ShipmentLineItemDto> exportToDtos(List<ShipmentLineItem> lineItems) {
    List<ShipmentLineItemDto> lineItemDtos = new ArrayList<>(lineItems.size());
    lineItems.forEach(l -> lineItemDtos.add(exportToDto(l)));
    return lineItemDtos;
}

From source file:ch.wisv.areafiftylan.utils.TaskScheduler.java

@Scheduled(fixedRate = ORDER_EXPIRY_CHECK_INTERVAL_SECONDS * 1000)
public void ExpireOrders() {
    LocalDateTime expireBeforeDate = LocalDateTime.now().minusMinutes(ORDER_STAY_ALIVE_MINUTES);

    Collection<Order> allOrdersBeforeDate = orderRepository.findAllByCreationDateTimeBefore(expireBeforeDate);

    List<Order> expiredOrders = allOrdersBeforeDate.stream().filter(isExpired()).collect(Collectors.toList());

    expiredOrders.forEach(o -> orderService.expireOrder(o));
}