List of usage examples for java.util.stream Stream collect
<R, A> R collect(Collector<? super T, A, R> collector);
From source file:net.riezebos.thoth.user.BasicUserManager.java
@Override public List<Group> listGroups() throws UserManagerException { Collection<Identity> identities = identityDao.getIdentities().values(); Stream<Group> filter = identities.stream()// .filter(grp -> grp instanceof Group)// .map(g -> (Group) g); List<Group> groups = filter.collect(Collectors.toList()); Collections.sort(groups);//w w w. java2s.co m return groups; }
From source file:org.thingsboard.server.msa.DockerComposeExecutor.java
public void invokeCompose() { // bail out early if (!CommandLine.executableExists(COMPOSE_EXECUTABLE)) { throw new ContainerLaunchException( "Local Docker Compose not found. Is " + COMPOSE_EXECUTABLE + " on the PATH?"); }/*from w w w .j a va 2 s . c om*/ final Map<String, String> environment = Maps.newHashMap(env); environment.put(ENV_PROJECT_NAME, identifier); final Stream<String> absoluteDockerComposeFilePaths = composeFiles.stream().map(File::getAbsolutePath) .map(Objects::toString); final String composeFileEnvVariableValue = absoluteDockerComposeFilePaths .collect(joining(File.pathSeparator + "")); log.debug("Set env COMPOSE_FILE={}", composeFileEnvVariableValue); final File pwd = composeFiles.get(0).getAbsoluteFile().getParentFile().getAbsoluteFile(); environment.put(ENV_COMPOSE_FILE, composeFileEnvVariableValue); log.info("Local Docker Compose is running command: {}", cmd); final List<String> command = Splitter.onPattern(" ").omitEmptyStrings() .splitToList(COMPOSE_EXECUTABLE + " " + cmd); try { new ProcessExecutor().command(command).redirectOutput(Slf4jStream.of(log).asInfo()) .redirectError(Slf4jStream.of(log).asError()).environment(environment).directory(pwd) .exitValueNormal().executeNoTimeout(); log.info("Docker Compose has finished running"); } catch (InvalidExitValueException e) { throw new ContainerLaunchException("Local Docker Compose exited abnormally with code " + e.getExitValue() + " whilst running command: " + cmd); } catch (Exception e) { throw new ContainerLaunchException("Error running local Docker Compose command: " + cmd, e); } }
From source file:org.cryptomator.frontend.webdav.jackrabbitservlet.DavFolder.java
@Override public DavResourceIterator getMembers() { final Stream<DavFolder> folders = node.folders().map(this::folderToDavFolder); final Stream<DavFile> files = node.files().map(this::fileToDavFile); final Stream<DavResource> members = AutoClosingStream.from(Stream.concat(folders, files)); return new DavResourceIteratorImpl(members.collect(Collectors.toList())); }
From source file:io.yields.math.framework.kpi.ExplorerJsonExporter.java
private <T> Values toValues(PropertyVerifications<T> verifications) { Stream<PropertyVerification<T>> stream = verifications.getResults().stream() .filter(verification -> verification.getProperty().isPresent()); Map<String, Object> map = stream .collect(Collectors.toMap(verification -> verification.getProperty().get().getLabel(), propertyVerification -> propertyVerification.getResult().getCode())); return new Values(map); }
From source file:org.trellisldp.rdfa.HtmlSerializer.java
/** * Send the content to an output stream. * * @param triples the triples//ww w . j a va 2 s . c o m * @param out the output stream * @param subject the subject */ @Override public void write(final Stream<Triple> triples, final OutputStream out, final String subject) { final Writer writer = new OutputStreamWriter(out, UTF_8); try { template.execute(writer, new HtmlData(namespaceService, subject, triples.collect(toList()), css, js, icon)).flush(); } catch (final IOException ex) { throw new UncheckedIOException(ex); } }
From source file:org.apache.geode.management.internal.cli.util.LogExporter.java
private List<Path> findFiles(Path workingDir, Predicate<Path> fileSelector) throws IOException { Stream<Path> selectedFiles/* = null */; if (!workingDir.toFile().isDirectory()) { return Collections.emptyList(); }// w w w .j a va2 s . c o m selectedFiles = Files.list(workingDir).filter(fileSelector).filter(this.logFilter::acceptsFile); return selectedFiles.collect(toList()); }
From source file:com.ikanow.aleph2.data_model.utils.CrudUtils.java
/** Returns a "multi" query component where all of the QueryComponents in the list (and added via andAlso) must match (NOTE: each component *internally* can use ORs or ANDs) * @param components - a stream of query components * @return the "multi" query component "helper" *///from w ww . j av a2 s. com public static <T> MultiQueryComponent<T> allOf(final Stream<QueryComponent<T>> components) { return new MultiQueryComponent<T>(Operator.all_of, components.collect(Collectors.toList())); }
From source file:com.ikanow.aleph2.data_model.utils.CrudUtils.java
/** Returns a "multi" query component where all of the QueryComponents in the list (and added via andAlso) must match (NOTE: each component *internally* can use ORs or ANDs) * @param components - a stream of query components * @return the "multi" query component "helper" *///from w w w . j av a 2 s. c o m public static <T> MultiQueryComponent<T> anyOf(final Stream<QueryComponent<T>> components) { return new MultiQueryComponent<T>(Operator.any_of, components.collect(Collectors.toList())); }
From source file:org.lightjason.agentspeak.common.CPath.java
/** * ctor/*from w w w . j a va 2s. c om*/ * * @param p_stream string collection */ public CPath(final Stream<String> p_stream) { m_path = p_stream.collect(CPath.collectorfactory()); this.normalize(); }
From source file:org.ajoberstar.reckon.core.git.GitInventorySupplier.java
private TaggedVersion findBase(RevWalk walk, RevCommit head, Stream<TaggedVersion> versions) throws IOException { walk.reset();//from ww w . j a v a 2s . c o m walk.setRevFilter(RevFilter.ALL); walk.markStart(head); Map<RevCommit, List<TaggedVersion>> versionsByCommit = versions .collect(Collectors.groupingBy(TaggedVersion::getCommit)); Stream.Builder<List<TaggedVersion>> builder = Stream.builder(); for (RevCommit commit : walk) { List<TaggedVersion> matches = versionsByCommit.get(commit); if (matches != null) { // Parents can't be "nearer". Exclude them to avoid extra walking. for (RevCommit parent : commit.getParents()) { walk.markUninteresting(parent); } builder.accept(matches); } } return builder.build().flatMap(List::stream).max(Comparator.comparing(TaggedVersion::getVersion)) .orElse(new TaggedVersion(Versions.VERSION_0, null)); }