List of usage examples for java.util Collection stream
default Stream<E> stream()
From source file:org.createnet.raptor.models.objects.ServiceObject.java
/** * Add a list of streams to the object/* w ww .j a v a 2 s . co m*/ * * @param streams list of streams * @return */ public ServiceObject addStreams(Collection<Stream> streams) { streams.stream().forEach((stream) -> { stream.setServiceObject(this); stream.channels.values().stream().forEach((channel) -> { channel.setServiceObject(this); }); this.streams.put(stream.name, stream); }); return this; }
From source file:com.haulmont.cuba.gui.config.WindowConfig.java
/** * All registered screens//from www . j a v a 2 s .c o m */ public Collection<WindowInfo> getWindows() { lock.readLock().lock(); try { checkInitialized(); Collection<List<WindowInfo>> values = screens.values(); return values.stream().flatMap(Collection::stream).collect(Collectors.toList()); } finally { lock.readLock().unlock(); } }
From source file:com.devicehive.service.DeviceCommandService.java
public CompletableFuture<List<DeviceCommand>> find(Collection<String> guids, Collection<String> names, Date timestampSt, Date timestampEnd, String status) { List<CompletableFuture<Response>> futures = guids.stream().map(guid -> { CommandSearchRequest searchRequest = new CommandSearchRequest(); searchRequest.setGuid(guid);/*from w w w . j av a 2s .c om*/ if (names != null) { searchRequest.setNames(new HashSet<>(names)); } searchRequest.setTimestampStart(timestampSt); searchRequest.setTimestampEnd(timestampEnd); searchRequest.setStatus(status); return searchRequest; }).map(searchRequest -> { CompletableFuture<Response> future = new CompletableFuture<>(); rpcClient.call( Request.newBuilder().withBody(searchRequest).withPartitionKey(searchRequest.getGuid()).build(), new ResponseConsumer(future)); return future; }).collect(Collectors.toList()); // List<CompletableFuture<Response>> => CompletableFuture<List<DeviceCommand>> return CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])) .thenApply(v -> futures.stream().map(CompletableFuture::join) // List<CompletableFuture<Response>> => CompletableFuture<List<Response>> .map(r -> ((CommandSearchResponse) r.getBody()).getCommands()) // CompletableFuture<List<Response>> => CompletableFuture<List<List<DeviceCommand>>> .flatMap(Collection::stream) // CompletableFuture<List<List<DeviceCommand>>> => CompletableFuture<List<DeviceCommand>> .collect(Collectors.toList())); }
From source file:com.github.tddts.jet.service.impl.SearchOperationsImpl.java
private Collection<Integer> getRegionIds(Collection<String> regions) { if (regions.isEmpty()) return regionsMap.values();// All regions else// www . j av a2 s. c om return regions.stream().map(region -> regionsMap.get(region)).collect(Collectors.toList());// Only selected regions }
From source file:org.kie.appformer.ala.wildfly.executor.AppFormerProvisioningHelper.java
public DriverDef findDriverDef(String uuid) { Collection<DriverDefInfo> defInfoList = dataSourceDefQueryService.findGlobalDrivers(); Optional<DriverDefInfo> defInfo = defInfoList.stream().filter(_defInfo -> uuid.equals(_defInfo.getUuid())) .findFirst();//from w w w . jav a2 s . c o m if (defInfo.isPresent()) { DriverDefEditorContent content = driverDefEditorService.loadContent(defInfo.get().getPath()); return content != null ? content.getDef() : null; } else { return null; } }
From source file:com.marand.thinkmed.medications.connector.impl.rest.RestMedicationsConnector.java
@Override public Map<String, PatientDisplayWithLocationDto> getPatientDisplayWithLocationMap( final Collection<String> careProviderIds, final Collection<String> patientIds) { final String patientsListJson; if (patientIds != null) { if (patientIds.isEmpty()) { return Collections.emptyMap(); }/*from ww w . java 2 s .com*/ final String patientIdsString = patientIds.stream().collect(Collectors.joining(",")); patientsListJson = restClient.getPatientsSummariesList(patientIdsString); } else { Preconditions.checkArgument(careProviderIds != null, "Both patientIds and careProviderId are null"); final String careProviderIdsString = careProviderIds.stream().collect(Collectors.joining(",")); patientsListJson = restClient.getCareProvidersPatientsSummariesList(careProviderIdsString); } final List<PatientDisplayWithLocationDto> patientsList = Arrays .asList(JsonUtil.fromJson(patientsListJson, PatientDisplayWithLocationDto[].class)); return patientsList.stream() .collect(Collectors.toMap(p -> p.getPatientDisplayDto().getId(), Function.identity())); }
From source file:ch.wisv.areafiftylan.security.authentication.CurrentUserServiceImpl.java
@Override public boolean canReserveSeat(Object principal, Long ticketId) { if (principal instanceof UserDetails) { User user = (User) principal;//from w ww . ja v a2 s . c o m Ticket ticket = ticketRepository.findOne(ticketId); if (ticket.getOwner().equals(user) || user.getAuthorities().contains(Role.ROLE_ADMIN)) { return true; } Collection<Team> userTeams = teamService.getTeamByCaptainId(user.getId()); // For each set of members in a team, check if the owner of the ticket is one of them. return userTeams.stream().map(Team::getMembers) .anyMatch(members -> members.contains(ticket.getOwner())); } else { return false; } }
From source file:ws.salient.aws.s3.AmazonS3Repository.java
public void resolveArtifact(String dependency, Collection<RemoteRepository> repositories) { Artifact artifact = new DefaultArtifact(dependency); ArtifactRequest artifactRequest = new ArtifactRequest(); artifactRequest.setArtifact(artifact); repositories.stream().forEach((repo) -> { artifactRequest.addRepository(repo); });/*from w w w .j a v a 2 s. c o m*/ try { aether.getSystem().resolveArtifact(aether.getSession(), artifactRequest); } catch (ArtifactResolutionException e) { log.warn("Unable to resolve artifact: " + dependency); } }
From source file:com.github.sevntu.checkstyle.ordering.MethodOrder.java
private int getMethodGroupSplitCount(Collection<Method> methodGroup) { final List<Integer> methodIndices = methodGroup.stream().map(this::getMethodIndex) .collect(Collectors.toList()); final MinMax<Integer> bounds = minMax(methodIndices); return bounds.getMax() - bounds.getMin() - methodIndices.size() + 1; }
From source file:io.klerch.alexa.state.handler.AWSS3StateHandler.java
/** * {@inheritDoc}//from w ww . j a v a 2 s .com */ @Override public void writeValues(final Collection<AlexaStateObject> stateObjects) throws AlexaStateException { // write to session super.writeValues(stateObjects); stateObjects.stream() // select only USER or APPLICATION scoped state objects .filter(stateObject -> stateObject.getScope().isIn(AlexaScope.USER, AlexaScope.APPLICATION)) .forEach(stateObject -> { final String id = stateObject.getId(); final String value = String.valueOf(stateObject.getValue()); final AlexaScope scope = stateObject.getScope(); final String filePath = AlexaScope.USER.includes(scope) ? getUserScopedFilePath(id) : getAppScopedFilePath(id); // write all app-scoped attributes to file awsClient.putObject(bucketName, filePath, value); }); }