List of usage examples for java.util Set forEach
default void forEach(Consumer<? super T> action)
From source file:org.onosproject.uiref.UiRefTopoOverlayMessageHandler.java
private Highlights fromLinks(Set<Link> links, DeviceId devId) { DemoLinkMap linkMap = new DemoLinkMap(); if (links != null) { log.debug("Processing {} links", links.size()); links.forEach(linkMap::add); } else {/*from ww w . ja v a 2s . com*/ log.debug("No egress links found for device {}", devId); } Highlights highlights = new Highlights(); for (DemoLink dlink : linkMap.biLinks()) { dlink.makeImportant().setLabel("Yo!"); highlights.add(dlink.highlight(null)); } return highlights; }
From source file:org.finra.herd.service.SearchableService.java
/** * Validates a set of search response fields. This method also trims and lowers the fields. * * @param fields the search response fields to be validated *//*from w w w.j av a2 s . c om*/ default void validateSearchResponseFields(Set<String> fields) { // Create a local copy of the fields set so that we can stream it to modify the fields set Set<String> localCopy = new HashSet<>(fields); // Clear the fields set fields.clear(); // Add to the fields set field the strings both trimmed and lower cased and filter out empty and null strings localCopy.stream().filter(StringUtils::isNotBlank).map(String::trim).map(String::toLowerCase) .forEachOrdered(fields::add); // Validate the field names fields.forEach(field -> Assert.isTrue(getValidSearchResponseFields().contains(field), String.format("Search response field \"%s\" is not supported.", field))); }
From source file:com.netflix.genie.core.jpa.services.JpaCommandServiceImpl.java
/** * {@inheritDoc}//w w w. j a v a 2 s .c o m */ @Override public void deleteCommand(@NotBlank(message = "No id entered. Unable to delete.") final String id) throws GenieException { log.debug("Called to delete command config with id {}", id); final CommandEntity commandEntity = this.findCommand(id); //Remove the command from the associated Application references final List<ApplicationEntity> originalApps = commandEntity.getApplications(); if (originalApps != null) { final List<ApplicationEntity> applicationEntities = Lists.newArrayList(originalApps); applicationEntities.forEach(commandEntity::removeApplication); } //Remove the command from the associated cluster references final Set<ClusterEntity> originalClusters = commandEntity.getClusters(); if (originalClusters != null) { final Set<ClusterEntity> clusterEntities = Sets.newHashSet(originalClusters); clusterEntities.forEach(clusterEntity -> clusterEntity.removeCommand(commandEntity)); } this.commandRepo.delete(commandEntity); }
From source file:se.uu.it.cs.recsys.service.preference.ConstraintSolverPreferenceBuilder.java
private void setAvoidMoreThanOneSelCollection(ConstraintSolverPreference instance, Set<CourseSchedule> scheduleInfo) { Set<Set<Integer>> totalAvoidMoreThanOneSelCollection = this.sameCourseFinder .getIdCollectionForSameCourse(scheduleInfo); Set<Set<String>> avoidMoreThanOneSelFromSameCourseSet = this.apiPref .getAvoidMoreThanOneFromTheSameCollection(); short firstPlanYear = getFirstPlanYear(scheduleInfo); if (avoidMoreThanOneSelFromSameCourseSet != null && !avoidMoreThanOneSelFromSameCourseSet.isEmpty()) { avoidMoreThanOneSelFromSameCourseSet.forEach(singleSet -> { LOGGER.debug("At most one from the collection can be selected: {}", singleSet); Set<Integer> partialAvoidSet = this.sameCourseFinder.getIdCollectionToAvoidMoreThanOneSel(singleSet, (int) firstPlanYear); totalAvoidMoreThanOneSelCollection.add(partialAvoidSet); });/*from ww w . jav a 2 s . c o m*/ } if (!totalAvoidMoreThanOneSelCollection.isEmpty()) { instance.getAvoidCollectionForCourseWithDiffIdSet().addAll(totalAvoidMoreThanOneSelCollection); } }
From source file:org.jboss.set.aphrodite.issue.trackers.jira.IssueWrapper.java
private void setLabels(JiraIssue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue) { Set<String> jiraLabels = jiraIssue.getLabels(); List<JiraLabel> labels = new ArrayList<>(); if (jiraLabels != null) jiraLabels.forEach(name -> labels.add(new JiraLabel(name))); issue.setLabels(labels);/* ww w . j ava2 s .co m*/ }
From source file:org.wso2.carbon.uuf.internal.deployment.AppCreator.java
private void addBindings(List<ComponentConfig.Binding> bindingEntries, Bindings bindings, String componentName, Set<Fragment> componentFragments, Set<Component> componentDependencies) { if (bindingEntries == null || bindingEntries.isEmpty()) { return;//from w ww . ja va 2 s. c o m } Map<String, Fragment> availableFragments = new HashMap<>(); componentFragments.forEach(fragment -> availableFragments.put(fragment.getName(), fragment)); componentDependencies .forEach(cmp -> cmp.getFragments().forEach(f -> availableFragments.put(f.getName(), f))); for (ComponentConfig.Binding entry : bindingEntries) { if (entry.getZoneName() == null) { throw new MalformedConfigurationException( "Zone name of a binding entry cannot be null. Found such binding entry in component '" + componentName + "'."); } else if (entry.getZoneName().isEmpty()) { throw new MalformedConfigurationException( "Zone name of a binding entry cannot be empty. Found such binding entry in component '" + componentName + "'."); } String zoneName = NameUtils.getFullyQualifiedName(componentName, entry.getZoneName()); if (entry.getFragments() == null) { throw new MalformedConfigurationException( "Fragments in a binding entry cannot be null. Found such binding entry in component '" + componentName + "'."); } List<Fragment> fragments = new ArrayList<>(entry.getFragments().size()); for (String fragmentName : entry.getFragments()) { Fragment fragment = availableFragments .get(NameUtils.getFullyQualifiedName(componentName, fragmentName)); if (fragment == null) { throw new IllegalArgumentException("Fragment '" + fragmentName + "' given in the binding entry '" + entry + "' does not exists in component '" + componentName + "' or its dependencies " + componentDependencies.stream().map(Component::getName).collect(joining(",")) + "."); } fragments.add(fragment); } bindings.addBinding(zoneName, fragments, entry.getMode()); } }
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component buildClippingsTab(User user) { HorizontalLayout root = new HorizontalLayout(); root.setCaption(Language.get(Word.CLIPPINGS)); root.setIcon(VaadinIcons.NEWSPAPER); root.setWidth("100%"); root.setSpacing(true);/* w w w .j a va 2 s .c om*/ root.setMargin(true); FormLayout formLayoutClippingDetails = new FormLayout(); formLayoutClippingDetails.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(formLayoutClippingDetails); CheckBox checkBoxReceiveEmails = new CheckBox(); checkBoxReceiveEmails.setValue(UserUtils.getEmailNewsletter(user)); checkBoxReceiveEmails.addValueChangeListener(v -> UserUtils.setEmailNewsletter(user, v.getValue())); HorizontalLayout layoutCheckBoxReceiveEmails = new HorizontalLayout(checkBoxReceiveEmails); layoutCheckBoxReceiveEmails.setCaption(Language.get(Word.EMAIL_SUBSCRIPTION)); layoutCheckBoxReceiveEmails.setMargin(false); layoutCheckBoxReceiveEmails.setSpacing(false); HorizontalLayout layoutAddNewClippingTime = new HorizontalLayout(); layoutAddNewClippingTime.setMargin(false); layoutAddNewClippingTime.setCaption(Language.get(Word.ADD_CLIPPING_TIME)); layoutAddNewClippingTime.setWidth("100%"); InlineDateTimeField dateFieldNewClippingTime = new InlineDateTimeField(); LocalDateTime value = LocalDateTime.now(ZoneId.of("Europe/Berlin")); dateFieldNewClippingTime.setValue(value); dateFieldNewClippingTime.setLocale(VaadinSession.getCurrent().getLocale()); dateFieldNewClippingTime.setResolution(DateTimeResolution.MINUTE); dateFieldNewClippingTime.addStyleName("time-only"); Button buttonAddClippingTime = new Button(); buttonAddClippingTime.setIcon(VaadinIcons.PLUS); buttonAddClippingTime.addStyleName(ValoTheme.BUTTON_PRIMARY); buttonAddClippingTime.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttonAddClippingTime.addClickListener(e -> { LocalTime generalTime = dateFieldNewClippingTime.getValue().toLocalTime(); layoutClippingTimes.addComponent(getTimeRow(user, generalTime)); UserUtils.addClippingSendTime(user, generalTime); }); layoutAddNewClippingTime.addComponents(dateFieldNewClippingTime, buttonAddClippingTime); layoutAddNewClippingTime.setComponentAlignment(dateFieldNewClippingTime, Alignment.MIDDLE_LEFT); layoutAddNewClippingTime.setComponentAlignment(buttonAddClippingTime, Alignment.MIDDLE_CENTER); layoutAddNewClippingTime.setExpandRatio(dateFieldNewClippingTime, 5); layoutClippingTimes = new VerticalLayout(); layoutClippingTimes.setMargin(new MarginInfo(true, false, false, true)); layoutClippingTimes.setCaption(Language.get(Word.CLIPPING_TIMES)); layoutClippingTimes.setWidth("100%"); layoutClippingTimes.addStyleName("times"); Set<LocalTime> userTimes = user.getClippingTime(); userTimes.forEach(t -> layoutClippingTimes.addComponent(getTimeRow(user, t))); formLayoutClippingDetails.addComponents(layoutCheckBoxReceiveEmails, layoutAddNewClippingTime, layoutClippingTimes); return root; }
From source file:nu.yona.server.batch.quartz.TriggerManagementService.java
@Transactional public Set<CronTriggerDto> updateTriggerGroup(String group, Set<CronTriggerDto> triggers) { try {/*from ww w . j av a 2 s . c o m*/ Set<String> trgNamesToBe = triggers.stream().map(CronTriggerDto::getName).collect(toSet()); Set<TriggerKey> existingTrgs = scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(group)); Set<TriggerKey> keysOfTrgsToDelete = existingTrgs.stream().filter(tk -> !contains(trgNamesToBe, tk)) .collect(toSet()); Set<CronTriggerDto> trgsToUpdate = triggers.stream().filter(t -> contains(existingTrgs, group, t)) .collect(toSet()); Set<CronTriggerDto> trgsToAdd = triggers.stream().filter(t -> !contains(existingTrgs, group, t)) .collect(toSet()); keysOfTrgsToDelete.forEach(tk -> deleteTrigger(tk.getGroup(), tk.getName())); trgsToUpdate.forEach(t -> updateTrigger(group, t)); trgsToAdd.forEach(t -> addTrigger(group, t)); return getTriggersInGroup(group); } catch (SchedulerException e) { throw YonaException.unexpected(e); } }
From source file:org.jbb.permissions.impl.role.DefaultPermissionRoleService.java
@Override public PermissionTable updatePermissionTable(Long roleId, PermissionTable permissionTable) { permissionCaches.clearCaches();//ww w.j a v a 2 s.co m AclRoleEntity roleEntity = aclRoleRepository.findById(roleId) .orElseThrow(() -> new PermissionRoleNotFoundException(roleId)); Set<Permission> permissions = permissionTable.getPermissions(); Set<AclPermissionEntity> permissionEntities = permissions.stream().map(permissionTranslator::toEntity) .collect(Collectors.toSet()); Set<AclRoleEntryEntity> roleEntries = permissionEntities.stream() .map(permissionEntity -> aclRoleEntryRepository .findByRoleAndPermission(roleEntity, permissionEntity) .orElse(AclRoleEntryEntity.builder().role(roleEntity).permission(permissionEntity).build())) .collect(Collectors.toSet()); roleEntries.forEach(entry -> updatePermissionValue(entry, permissions)); aclRoleEntryRepository.saveAll(roleEntries); eventBus.post(eventCreator.createRoleChangedEvent( permissionTypeTranslator.toApiModel(roleEntity.getPermissionType()), roleId)); return getPermissionTable(roleId); }
From source file:com.devicehive.handler.command.CommandSubscribeRequestHandler.java
@Override public Response handle(Request request) { CommandSubscribeRequest body = (CommandSubscribeRequest) request.getBody(); validate(body);//from w ww .j av a 2 s . c om Subscriber subscriber = new Subscriber(body.getSubscriptionId(), request.getReplyTo(), request.getCorrelationId()); Set<Subscription> subscriptions = new HashSet<>(); if (CollectionUtils.isEmpty(body.getNames())) { Subscription subscription = new Subscription(Action.COMMAND_EVENT.name(), body.getDevice()); subscriptions.add(subscription); } else { for (String name : body.getNames()) { Subscription subscription = new Subscription(Action.COMMAND_EVENT.name(), body.getDevice(), name); subscriptions.add(subscription); } } subscriptions.forEach(subscription -> eventBus.subscribe(subscriber, subscription)); Collection<DeviceCommand> commands = findCommands(body.getDevice(), body.getNames(), body.getTimestamp()); CommandSubscribeResponse subscribeResponse = new CommandSubscribeResponse(body.getSubscriptionId(), commands); return Response.newBuilder().withBody(subscribeResponse).withLast(false) .withCorrelationId(request.getCorrelationId()).buildSuccess(); }