List of usage examples for java.util.stream Collectors toCollection
public static <T, C extends Collection<T>> Collector<T, ?, C> toCollection(Supplier<C> collectionFactory)
From source file:de.codesourcery.spring.contextrewrite.XMLRewrite.java
/** * Converts an array of <code>ReplaceRule</code> annotations into the corresponding rewriting rules. * /* w ww. j a v a 2 s . c o m*/ * @param rules * @return */ public static List<Rule> wrap(ReplaceRule[] rules) { Validate.notNull(rules, "rules must not be NULL"); return Stream.of(rules).map(XMLRewrite::wrap).collect(Collectors.toCollection(ArrayList::new)); }
From source file:io.github.lxgaming.teleportbow.util.Toolbox.java
@SafeVarargs public static <E> ArrayList<E> newArrayList(E... elements) { return Stream.of(elements).collect(Collectors.toCollection(ArrayList::new)); }
From source file:org.kie.workbench.common.forms.editor.backend.service.impl.ModuleFormFinderServiceImpl.java
private List<FormDefinition> findForms(final Path path, final Predicate<FormDefinition> predicate) { KieModule module = moduleService.resolveModule(path); org.uberfire.java.nio.file.Path nioPath = Paths.convert(module.getRootPath()); List<FormDefinition> moduleForms = VFSScanner .scan(ioService, nioPath, Collections.singleton(FormResourceTypeDefinition.EXTENSION), this::convert, predicate) .stream().map(VFSScanner.ScanResult::getResource).filter(Objects::nonNull) .collect(Collectors.toList()); List<String> moduleFormsIds = moduleForms.stream().map(FormDefinition::getId).collect(Collectors.toList()); Map<String, String> dependenciesForms = buildInfoService.getBuildInfo(module) .getKieModuleMetaDataIgnoringErrors().getForms(); return dependenciesForms.values().stream().map(serializer::deserialize).filter(predicate) .filter(formDefinition -> !moduleFormsIds.contains(formDefinition)) .collect(Collectors.toCollection(() -> moduleForms)); }
From source file:com.netflix.subtitles.cli.TtmlConverterCmdLineParser.java
/** * Parses command line.//from w ww . ja va 2s . co m * * @param args cli arguments * @return parsed parameters object * @throws ParseException */ public TtmlConverterCmdLineParams parse(String[] args) throws ParseException { TtmlConverterCmdLineParams params = new TtmlConverterCmdLineParams(); CommandLineParser parser = new DefaultParser(); CommandLine line; try { line = parser.parse(options, args); } catch (org.apache.commons.cli.ParseException e) { throw new ParseException(e); } // help if (line.hasOption(help.getOpt())) { // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp("ttml2stl", options); return null; } // outputFile if (line.hasOption(out.getOpt())) { params.setOutputFile(line.getOptionValue(out.getOpt())); } else { throw new ParseException("Output file option must be provided."); } // frameRate if (line.hasOption(frameRate.getOpt())) { params.setFrameRate(parseFrameRate(line.getOptionValue(frameRate.getOpt()))); } // ttml params.getTtmlOptions().addAll(Stream.of(line.getOptions()).filter((o) -> o.equals(ttml)).map((o) -> { TtmlOption ttmlOption = new TtmlOption(); try { ttmlOption.setFileName(o.getValue(0)); ttmlOption.setOffsetMS(parseTtmlParameter(o, 1, "offsetMS")); ttmlOption.setStartMS(parseTtmlParameter(o, 2, "startMS")); ttmlOption.setEndMS(parseTtmlParameter(o, 3, "endMS")); } catch (IndexOutOfBoundsException e) { //It is error only if don't have file name //For required file it may not be thrown. We will check it later. } if (ttmlOption.getFileName() == null) { throw new ParseException("--ttml parameter must have at least <file> attribute defined."); } return ttmlOption; }).collect(Collectors.toCollection(ArrayList::new))); if (params.getTtmlOptions().isEmpty()) { throw new ParseException("At least one input TTML file must be provided."); } return params; }
From source file:com.phoenixnap.oss.ramlapisync.data.ApiActionMetadata.java
private void parseRequest() { requestParameters = action.getQueryParameters().entrySet().stream() .map(param -> new ApiParameterMetadata(param.getKey(), param.getValue())) .collect(Collectors.toCollection(LinkedHashSet::new)); requestHeaders = action.getHeaders().entrySet().stream() .map(param -> new ApiParameterMetadata(param.getKey(), param.getValue())) .collect(Collectors.toCollection(LinkedHashSet::new)); if (action.getBody() != null && !action.getBody().isEmpty()) { action.getBody().entrySet().forEach(this::collectBodyParams); }/*from w w w.jav a 2s . c o m*/ }
From source file:org.jamocha.dn.compiler.pathblocks.PathFilterConsolidator.java
@Override public void visit(final OrFunctionConditionalElement<SymbolLeaf> ce) { final Map<VariableSymbol, EquivalenceClass> symbolToEC = this.rule.getCondition().getVariableSymbols() .stream().collect(toMap(Function.identity(), VariableSymbol::getEqual)); // For each child of the OrCE ... this.translateds = ce.getChildren().stream().map(child -> // ... collect all PathFilters in the child NoORsPFC.consolidate(this.initialFactTemplate, this.rule, child, symbolToEC)) .collect(Collectors.toCollection(ArrayList::new)); }
From source file:io.github.lxgaming.teleportbow.util.Toolbox.java
@SafeVarargs public static <E> HashSet<E> newHashSet(E... elements) { return Stream.of(elements).collect(Collectors.toCollection(HashSet::new)); }
From source file:de.codesourcery.spring.contextrewrite.XMLRewrite.java
/** * Converts an array of <code>RemoveRule</code> annotations into the corresponding rewriting rules. * /*from ww w . j a va 2 s . c o m*/ * @param rules * @return */ public static List<Rule> wrap(RemoveRule[] rules) { Validate.notNull(rules, "rules must not be NULL"); return Stream.of(rules).map(XMLRewrite::wrap).collect(Collectors.toCollection(ArrayList::new)); }
From source file:org.springframework.boot.actuate.endpoint.annotation.AnnotationEndpointDiscoverer.java
@Override public final Collection<EndpointInfo<T>> discoverEndpoints() { Class<T> operationType = getOperationType(); Map<Class<?>, DiscoveredEndpoint> endpoints = getEndpoints(operationType); Map<Class<?>, DiscoveredExtension> extensions = getExtensions(operationType, endpoints); Collection<DiscoveredEndpoint> exposed = mergeExposed(endpoints, extensions); verify(exposed);// w w w . ja v a 2 s .c o m return exposed.stream().map(DiscoveredEndpoint::getInfo).collect(Collectors.toCollection(ArrayList::new)); }
From source file:io.github.lxgaming.teleportbow.util.Toolbox.java
@SafeVarargs public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue(E... elements) { return Stream.of(elements).collect(Collectors.toCollection(LinkedBlockingQueue::new)); }