List of usage examples for java.util Collection stream
default Stream<E> stream()
From source file:de.qaware.showcase.spock.spring.UserManager.java
/** * Deactivate alle users in our repository. *///from www .j av a 2s.c om public void deactiveAll() { Collection<User> all = repository.all(); all.stream().map(User::deactivate).forEach(repository::store); }
From source file:com.github.horrorho.inflatabledonkey.requests.MappedHeaders.java
public MappedHeaders(Collection<Header> headers) { this.headers = headers.stream() .collect(Collectors.toMap(header -> header.getName().toLowerCase(Locale.US), Function.identity())); }
From source file:org.openmhealth.dsu.repository.ClientDetailsRepositoryIntegrationTests.java
protected List<GrantedAuthority> asGrantedAuthorities(Collection<String> roles) { return roles.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList()); }
From source file:org.vaadin.peholmst.samples.dddwebinar.domain.doctors.LicenseService.java
public Optional<License> selectBestLicense(Collection<Procedure> procedures, Collection<License> licenses) { Set<License> availableLicenses = licenses.stream().filter( l -> procedures.stream().allMatch(p -> p.getCategory().getLicenseTypes().containsKey(l.getType()))) .collect(Collectors.toSet()); if (availableLicenses.isEmpty()) { return Optional.empty(); } else {//w ww.j a v a2s . c o m License best = null; int bestRank = Integer.MAX_VALUE; for (License l : availableLicenses) { for (Procedure p : procedures) { int rank = p.getCategory().getLicenseTypes().get(l.getType()); if (rank < bestRank) { bestRank = rank; best = l; } } } return Optional.ofNullable(best); } }
From source file:oauth2.authentication.approvals.ApprovalServiceImpl.java
@Override public boolean addApprovals(Collection<Approval> approvals) { approvals.stream() // .map(ApprovalServiceImpl::toEntity) // .forEach(entity -> approvalRepository.save(entity)); return true;//from w ww .j a v a 2s .c om }
From source file:oauth2.authentication.approvals.ApprovalServiceImpl.java
@Override public boolean revokeApprovals(Collection<Approval> approvals) { approvals.stream() // .map(ApprovalServiceImpl::toPrimaryKey) // .forEach(pk -> approvalRepository.delete(pk)); return true;// w w w. ja v a2s .c o m }
From source file:org.trustedanalytics.cloud.uaa.UaaClient.java
@Override public Collection<UserIdNamePair> findUserNames(Collection<UUID> users) { String filter = users.stream().map(uuid -> "Id eq \"" + uuid + "\"").collect(joining(" or ")); String path = uaaBaseUrl + "/Users?attributes=id,userName&filter=" + filter; return uaaRestTemplate.getForObject(path, UserIdNameList.class).getUsers(); }
From source file:de.ks.flatadocdb.session.dirtycheck.DirtyChecker.java
public Collection<SessionEntry> findDirty(Collection<SessionEntry> values) { return values.stream()// .filter(e -> !insertions.contains(e.getObject()))// .filter(e -> !deletions.contains(e.getObject()))// .filter(e -> {/*from ww w . j a v a2 s . c om*/ EntityDescriptor entityDescriptor = e.getEntityDescriptor(); EntityPersister persister = entityDescriptor.getPersister(); byte[] fileContents = persister.createFileContents(repository, entityDescriptor, e.getObject()); byte[] md5 = DigestUtils.md5(fileContents); boolean dirty = !Arrays.equals(md5, e.getMd5()); if (dirty) { log.debug("Found dirty entity {} {}", e.getObject(), e.getFileName()); } else { log.trace("Non-dirty entity {} {}", e.getObject(), e.getFileName()); } return dirty; }).collect(Collectors.toSet()); }
From source file:com.github.horrorho.inflatabledonkey.args.ArgsManager.java
public ArgsManager(Collection<Arg> args) { this.args = args.stream().collect( Collectors.toMap(Arg::option, Function.identity(), ArgsManager::merge, LinkedHashMap::new)); }
From source file:com.groovycoder.BookService.java
public Collection<Book> listAvailableBooks() { Collection<Book> existingBooks = bookRepository.findAll(); Collection<Book> availableBooks = existingBooks.stream().filter(Book::isAvailable) .collect(Collectors.toList()); return availableBooks; }