List of usage examples for java.util Set stream
default Stream<E> stream()
From source file:io.fabric8.vertx.maven.plugin.mojos.AbstractRunMojo.java
/** * This will resolve the project's test and runtime dependencies along with classes directory, resources directory * to the collection of classpath urls//from w ww . ja va 2 s. com * * @return @{link {@link List<URL>}} which will have all the dependencies, classes directory, resources directory etc., * @throws MojoExecutionException any error that might occur while building collection like resolution errors */ protected List<URL> getClassPathUrls() throws MojoExecutionException { List<URL> classPathUrls = new ArrayList<>(); try { addProjectResources(classPathUrls); addClassesDirectory(classPathUrls); Set<Optional<File>> compileAndRuntimeDeps = extractArtifactPaths(this.project.getDependencyArtifacts()); Set<Optional<File>> transitiveDeps = extractArtifactPaths(this.project.getArtifacts()); classPathUrls.addAll(Stream.concat(compileAndRuntimeDeps.stream(), transitiveDeps.stream()) .filter(Optional::isPresent).map(file -> { try { return file.get().toURI().toURL(); } catch (Exception e) { getLog().error("Error building classpath", e); } return null; }).filter(Objects::nonNull).collect(Collectors.toList())); } catch (IOException e) { throw new MojoExecutionException("Unable to run:", e); } return classPathUrls; }
From source file:com.autonomy.aci.client.transport.impl.AciHttpClientImpl.java
/** * Turns the {@code parameters} and {@code serverDetails} into either an HTTP GET or POST request. * @param serverDetails The details of the ACI server the request will be sent to * @param parameters The parameters to send with the ACI action. * @return A HTTP GET or POST request that can be used to execute the ACI action * @throws EncryptionCodecException If something went wrong encrypting the parameters * @throws URISyntaxException If something went wrong creating the URI to send the action to * @throws UnsupportedEncodingException If there was a problem working with the parameters in the specified * character encoding *//* ww w.ja va2s . c om*/ private HttpUriRequest constructHttpRequest(final AciServerDetails serverDetails, final Set<? extends ActionParameter<?>> parameters) throws EncryptionCodecException, URISyntaxException, UnsupportedEncodingException { LOGGER.trace("constructHttpMethod() called..."); // Copy the parameters... final Set<? extends ActionParameter<?>> params = (serverDetails.getEncryptionCodec() == null) ? parameters : createEncryptedParameters(serverDetails, parameters); final boolean hasPostParameter = parameters.stream().anyMatch(ActionParameter::requiresPostRequest); // If an InputStream parameter has been provided, use a post request regardless if (usePostMethod || hasPostParameter) { return createPostMethod(serverDetails, params); } else { return createGetMethod(serverDetails, params); } }
From source file:io.gravitee.management.service.impl.ApiServiceImpl.java
@Override public Set<ApiEntity> findByVisibility(io.gravitee.management.model.Visibility visibility) { try {/*from w w w. java 2 s . c om*/ LOGGER.debug("Find APIs by visibility {}", visibility); Set<Api> publicApis = apiRepository.findByMember(null, null, Visibility.PUBLIC); return publicApis.stream().map(this::convert).collect(Collectors.toSet()); } catch (TechnicalException ex) { LOGGER.error("An error occurs while trying to find all APIs", ex); throw new TechnicalManagementException("An error occurs while trying to find all APIs", ex); } }
From source file:com.sinet.gage.delta.DomainUpdatesImporter.java
/** * Performs the delta imports for District & School Domain * /*from www . j a va 2 s . c o m*/ * @param domainIdsToProcessInsert */ public void processInsertsForDomains(Set<Integer> domainIdsToProcessInsert) { Set<Integer> domainIdsForInsert; List<DomainResponse> domainResponseList; List<Domain> domainList = new ArrayList<>(); for (Integer domainId : domainIdsToProcessInsert) { domainIdsForInsert = signalManager.getDomainIdsForDeltaImportsForADomain(domainId, serverSettings.getEntityCreatedSignalTypeCode()); if (!CollectionUtils.isEmpty(domainIdsForInsert)) { log.debug("Domain Ids to be inserted: " + domainIdsForInsert); String idsString = domainIdsForInsert.stream().map(Object::toString) .collect(Collectors.joining(", ")); domainResponseList = getDomainsWithData(domainId, idsString); for (DomainResponse domainResponse : domainResponseList) { DomainResponse parentDomainResponse = dlapDomainClient.getDomain(null, Long.parseLong(domainId.toString())); Domain domain = mapToDomain(domainResponse); if (domainResponse.getData() != null && domainResponse.getData().getCustomization() != null && domainResponse.getData().getCustomization().getEdivatelearn() != null) { if ("DISTRICT".equalsIgnoreCase( domainResponse.getData().getCustomization().getEdivatelearn().getDomaintype())) { domain.setStateDomainId(Long.parseLong(parentDomainResponse.getId())); domain.setStateDomainName(parentDomainResponse.getName()); domain.setParentDomainName(parentDomainResponse.getName()); } else if ("SCHOOL".equalsIgnoreCase( domainResponse.getData().getCustomization().getEdivatelearn().getDomaintype())) { DomainResponse stateDomainResponse = dlapDomainClient.getDomain(null, Long.parseLong(parentDomainResponse.getParentid())); domain.setStateDomainId(Long.parseLong(stateDomainResponse.getId())); domain.setStateDomainName(stateDomainResponse.getName()); domain.setParentDomainName(parentDomainResponse.getName()); } } else { domain.setStateDomainId(Long.parseLong(parentDomainResponse.getId())); domain.setStateDomainName(parentDomainResponse.getName()); domain.setParentDomainName(parentDomainResponse.getName()); } domainList.add(domain); } log.debug("Inserting domain ids: " + domainId); if (!CollectionUtils.isEmpty(domainList)) { domainsRepository.insertDomains(domainList); } } } }
From source file:com.sinet.gage.delta.DomainUpdatesImporter.java
/** * Performs the delta updates for Domains * //from w w w . ja v a2 s .c o m * @param domainIdsToProcessUpdates */ public void processUpdatesForDomains(Set<Integer> domainIdsToProcessUpdates) { Set<Integer> domainIdsForUpdate; List<DomainResponse> domainResponseList; List<Domain> domainList = new ArrayList<>(); for (Integer domainId : domainIdsToProcessUpdates) { domainIdsForUpdate = signalManager.getDomainIdsForDeltaImportsForADomain(domainId, serverSettings.getEntityChangedSignalTypeCode()); if (!CollectionUtils.isEmpty(domainIdsForUpdate)) { log.debug("Domain Ids to be updated: " + domainIdsForUpdate); String idsString = domainIdsForUpdate.stream().map(Object::toString) .collect(Collectors.joining(", ")); domainResponseList = getDomainsWithData(domainId, idsString); for (DomainResponse domainResponse : domainResponseList) { DomainResponse parentDomainResponse = dlapDomainClient.getDomain(null, Long.parseLong(domainId.toString())); Domain domain = mapToDomain(domainResponse); if (domainResponse.getData() != null && domainResponse.getData().getCustomization() != null && domainResponse.getData().getCustomization().getEdivatelearn() != null) { if ("DISTRICT".equalsIgnoreCase( domainResponse.getData().getCustomization().getEdivatelearn().getDomaintype())) { domain.setStateDomainId(Long.parseLong(parentDomainResponse.getId())); domain.setStateDomainName(parentDomainResponse.getName()); domain.setParentDomainName(parentDomainResponse.getName()); } else if ("SCHOOL".equalsIgnoreCase( domainResponse.getData().getCustomization().getEdivatelearn().getDomaintype())) { DomainResponse stateDomainResponse = dlapDomainClient.getDomain(null, Long.parseLong(parentDomainResponse.getParentid())); domain.setStateDomainId(Long.parseLong(stateDomainResponse.getId())); domain.setStateDomainName(stateDomainResponse.getName()); domain.setParentDomainName(parentDomainResponse.getName()); } } else { domain.setStateDomainId(Long.parseLong(parentDomainResponse.getId())); domain.setStateDomainName(parentDomainResponse.getName()); domain.setParentDomainName(parentDomainResponse.getName()); } domainList.add(domain); } log.debug("Updating domain ids: " + domainId); if (!CollectionUtils.isEmpty(domainList)) { domainsRepository.updateDomains(domainList); } } } }
From source file:io.gravitee.management.service.impl.ApiServiceImpl.java
@Override public int countByApplication(String applicationId) { try {//from w w w . j av a 2 s . c o m LOGGER.debug("Find APIs by application {}", applicationId); Set<ApiKey> applicationApiKeys = apiKeyRepository.findByApplication(applicationId); return (int) applicationApiKeys.stream().map(apiKey -> apiKey.getApi()).distinct().count(); } catch (TechnicalException ex) { LOGGER.error("An error occurs while trying to find all APIs", ex); throw new TechnicalManagementException("An error occurs while trying to find all APIs", ex); } }
From source file:it.unibo.alchemist.boundary.gui.effects.DrawShape.java
/** * Builds a new {@link DrawShape} effect. *///w w w. ja v a 2s .c o m public DrawShape() { final Set<String> availableIncarnations = SupportedIncarnations.getAvailableIncarnations(); if (availableIncarnations.isEmpty()) { throw new IllegalStateException( getClass().getSimpleName() + " can't work if no incarnation is available."); } curIncarnation = new ImmutableCollectionWithCurrentElement<>(availableIncarnations, availableIncarnations.stream().findAny().get()); }
From source file:com.haulmont.cuba.web.gui.components.WebFileUploadField.java
@Override public void setPermittedExtensions(Set<String> permittedExtensions) { if (permittedExtensions != null) { this.permittedExtensions = permittedExtensions.stream().map(String::toLowerCase) .collect(Collectors.toSet()); } else {//from w ww . j a va 2 s . co m this.permittedExtensions = null; } if (uploadButton instanceof CubaFileUpload) { ((CubaFileUpload) uploadButton).setPermittedExtensions(this.permittedExtensions); } }
From source file:com.haulmont.cuba.security.app.EntityLog.java
protected Set<String> filterRemovedAttributes(MetaClass metaClass, Set<String> attributes) { // filter attributes that do not exists in entity anymore return attributes.stream().filter(attributeName -> { if (DynamicAttributesUtils.isDynamicAttribute(attributeName)) { return DynamicAttributesUtils.getMetaPropertyPath(metaClass, attributeName) != null; } else {/*w w w .java 2 s . c o m*/ return metaClass.getProperty(attributeName) != null; } }).collect(Collectors.toSet()); }
From source file:cz.lbenda.rcp.DialogHelper.java
/** Show unsaved object if aren't saved. if user want cancel the closing then return false, elserwhere return true * @param savableRegistry register which hold unsaved data * @return true if window/object can be closed */ public boolean showUnsavedObjectDialog(SavableRegistry savableRegistry) { Set<Savable> savables = savableRegistry.dirtySavables(); if (savables.size() == 0) { return true; }//from ww w . ja va 2 s. c om Dialog<?> dialog = new Dialog<>(); dialog.setResizable(false); dialog.setTitle(msgNotSavedObjectsTitle); dialog.setHeaderText(msgNotSavedObjectsHeader); BorderPane pane = new BorderPane(); pane.setPrefHeight(400); pane.setPrefWidth(300); ListView<DialogHelper.Item> listView = new ListView<>(); listView.getItems() .addAll(savables.stream().map(savable -> new Item(savable, true)).collect(Collectors.toList())); listView.setCellFactory(CheckBoxListCell.forListView(DialogHelper.Item::onProperty)); pane.setCenter(listView); dialog.getDialogPane().setContent(pane); ButtonType btCancel = new ButtonType(button_cancel, ButtonBar.ButtonData.CANCEL_CLOSE); ButtonType btSaveClose = new ButtonType(button_saveAndClose, ButtonBar.ButtonData.OK_DONE); ButtonType btClose = new ButtonType(button_closeWithoutSave); dialog.getDialogPane().getButtonTypes().addAll(btClose, btSaveClose, btCancel); Optional<?> result = dialog.showAndWait(); if (result.isPresent()) { if (btCancel == result.get()) { return false; } if (btSaveClose == result.get()) { listView.getItems().stream().filter(Item::isOn).forEach(item -> item.getSavable().save()); } } else { return false; } return true; }