List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:de.unima.core.persistence.AbstractEntityRepository.java
@Override public List<R> saveAll(List<T> entities) { entities.forEach(this::checkEntityToBeNotNullAndHasIdSet); return store.writeWithConnection(connection -> connection.as(Dataset.class).map(dataset -> { return entities.stream().map(entity -> saveEntityInDataSetAsNamedModel(entity, dataset)) .collect(Collectors.toList()); })).get().get();//www .j a v a2 s . c om }
From source file:io.gravitee.repository.jdbc.JdbcTeamMembershipRepository.java
public void deleteMember(String teamName, String username) throws TechnicalException { final TeamJpa teamJpa = internalJpaTeamRepository.findOne(teamName); final List<TeamMemberJpa> membersJpa = teamJpa.getMembers(); if (membersJpa != null) { membersJpa.forEach(teamMemberJpa -> { if (username.equals(teamMemberJpa.getMember().getName())) { teamJpa.getMembers().remove(teamMemberJpa); }// w w w . j av a 2 s . c om }); internalJpaTeamRepository.save(teamJpa); } }
From source file:edu.usu.sdl.openstorefront.validation.ValidValueRule.java
@Override protected boolean validate(Field field, Object dataObject) { boolean valid = true; ValidValueType validValueType = field.getAnnotation(ValidValueType.class); if (validValueType != null) { try {/*from w w w .ja v a 2 s .com*/ String value = BeanUtils.getProperty(dataObject, field.getName()); //Note: null values are checked by a separate rule so null should be valid if (value != null) { Set<String> validValueSet = new HashSet<>(); Service serviceProxy = ServiceProxyFactory.getServiceProxy(); if (validValueType.lookupClass().length > 0) { for (Class lookupClass : validValueType.lookupClass()) { List<LookupEntity> lookups = serviceProxy.getLookupService().findLookup(lookupClass); lookups.forEach(item -> { validValueSet.add(item.getCode()); }); } } validValueSet.addAll(Arrays.asList(validValueType.value())); if (validValueType.enumClass().length > 0) { for (Class enumClass : validValueType.enumClass()) { Object enumValues[] = enumClass.getEnumConstants(); if (enumValues != null) { for (Object enumValue : enumValues) { validValueSet.add(enumValue.toString()); } } } } if (validValueSet.contains(value) == false) { valid = false; } } } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) { throw new OpenStorefrontRuntimeException("Unexpected error occur trying to get value from object.", ex); } } return valid; }
From source file:io.gravitee.repository.jdbc.JdbcTeamMembershipRepository.java
public void updateMember(String teamName, Member member) throws TechnicalException { final TeamJpa teamJpa = internalJpaTeamRepository.findOne(teamName); final List<TeamMemberJpa> membersJpa = teamJpa.getMembers(); if (membersJpa != null) { membersJpa.forEach(teamMemberJpa -> { if (member.getUsername().equals(teamMemberJpa.getMember().getName())) { teamMemberJpa.setRole(String.valueOf(member.getRole())); teamMemberJpa.setUpdatedAt(member.getUpdatedAt()); }// w w w . j av a2 s . co m }); internalJpaTeamRepository.save(teamJpa); } }
From source file:com.blackducksoftware.integration.hub.detect.help.html.HelpHtmlDataBuilder.java
public HelpHtmlData build() { final List<HelpHtmlGroup> sortedOptions = groupsByName.values().stream() .sorted((o1, o2) -> o1.groupName.compareTo(o2.groupName)).collect(Collectors.toList()); sortedOptions.forEach(it -> it.getOptions().sort((o1, o2) -> o1.key.compareTo(o2.key))); return new HelpHtmlData(sortedOptions); }
From source file:com.evolveum.midpoint.notifications.impl.WorkflowListener.java
private void checkOids(List<ObjectReferenceType> refs) { refs.forEach(r -> Validate.notNull(r.getOid(), "No OID in actor object reference " + r)); }
From source file:de.unima.core.persistence.AbstractEntityRepository.java
@Override public long deleteAll(List<T> entities) { entities.forEach(this::checkEntityToBeNotNullAndHasIdSet); return store//from w w w.j a va2s .c o m .writeWithConnection( connection -> connection.as(Dataset.class) .map(dataset -> entities.stream() .mapToLong(entity -> deleteGraphsOfEntity(entity, dataset)).sum())) .get().get(); }
From source file:com.devicehive.dao.riak.UserNetworkDaoRiakImpl.java
public Set<Long> findNetworksForUser(Long userId) { IntIndexQuery biq = new IntIndexQuery.Builder(USER_NETWORK_NS, "userId", userId).withKeyAndIndex(true) .build();//from www. j av a2 s .c o m try { IntIndexQuery.Response response = client.execute(biq); List<UserNetwork> networkList = fetchMultiple(response, UserNetwork.class); Set<Long> networks = new HashSet<>(); networkList.forEach(userNetwork -> networks.add(userNetwork.getNetworkId())); return networks; } catch (ExecutionException | InterruptedException e) { throw new HivePersistenceLayerException("Cannot find networks for user.", e); } }
From source file:com.anevis.jfreechartsamplespring.chart.ChartServiceImpl.java
private JFreeChart createPieChart() { List<PieChartData> dataList = pieChartDataRepository.findAll(); DefaultPieDataset dataSet = new DefaultPieDataset(); dataList.forEach(data -> dataSet.setValue(data.getCountry(), data.getWeight())); JFreeChart chart = ChartFactory.createPieChart("Anteil am Fondsvermgen", dataSet, true, false, Locale.GERMANY);//from w w w .j a va 2s . c om return chart; }
From source file:nc.noumea.mairie.appock.services.impl.DemandeServiceImpl.java
private List<Demande> initLazyListeDemande(List<Demande> listeDemande) { listeDemande.forEach(this::initLazyDemande); return listeDemande; }