List of usage examples for java.util.stream Collectors toList
public static <T> Collector<T, ?, List<T>> toList()
From source file:document_search.MultiQuerySearch.java
public static List<MultiQueryResults> search(Index i, int docLimit, String searchField, Analyzer a, String... queries) {/* w ww . j a va2 s. co m*/ ParseWrapper parser = new ParseWrapper(new QueryParser(searchField, a)); // Parse all available results List<QueryPair> queryList = Arrays.asList(queries).stream().map(parser::parseQuery) .filter(query -> query != null).collect(Collectors.toList()); // Create the overall query BooleanQuery query = new BooleanQuery(); for (QueryPair pair : queryList) { query.add(pair.query, BooleanClause.Occur.SHOULD); } // FIXME: We should not have index searchers here, but we still do! :-( Fuck Lucene and its vast plots of, features... IndexSearcher searcher = new IndexSearcher(i.getIndexer().getReader()); // TODO: Refactor this because it looks terrible, functional style is better, but the functional isn't good... List<MultiQueryResults> queryResults = Collections.checkedList(new ArrayList<>(), MultiQueryResults.class); for (Index.IndexDocument doc : i.runQuery(query, docLimit)) { // Create new multi query results MultiQueryResults results = new MultiQueryResults(doc.id, doc.score, Arrays.asList(queries)); // Explain the individual query results for (QueryPair queryPair : queryList) { try { double score = searcher.explain(queryPair.query, doc.lucene_id).getValue(); QueryResults individualResults = new QueryResults(doc.id, queryPair.term, score); results.addQueryResult(individualResults); } catch (IOException e) { e.printStackTrace(); } } // Add the Multi-query results to the overall list queryResults.add(results); } return queryResults; }
From source file:com.synopsys.integration.util.EnumUtils.java
public static <T extends Enum<T>> List<T> parseCommaDelimitted(String commaDelimittedEnumString, Class<T> enumClass) { return Arrays.stream(commaDelimittedEnumString.split(",")).map(String::trim).filter(StringUtils::isNotBlank) .map(token -> Enum.valueOf(enumClass, token)).collect(Collectors.toList()); }
From source file:com.baidu.rigel.biplatform.tesseract.isservice.search.agg.AggregateCompute.java
public static List<SearchIndexResultRecord> distinct(List<SearchIndexResultRecord> dataList) { return dataList.stream().distinct().collect(Collectors.toList()); }
From source file:io.syndesis.credential.CredentialFlowStateHelper.java
static Set<CredentialFlowState> restoreFrom(final Restorer restore, final HttpServletRequest request) { final Cookie[] servletCookies = request.getCookies(); if (ArrayUtils.isEmpty(servletCookies)) { return Collections.emptySet(); }/*w ww .j a v a 2s . c o m*/ final List<javax.ws.rs.core.Cookie> credentialCookies = Arrays.stream(servletCookies) .filter(c -> c.getName().startsWith(CredentialFlowState.CREDENTIAL_PREFIX)) .map(CredentialFlowStateHelper::toJaxRsCookie).collect(Collectors.toList()); try { return restore.apply(credentialCookies, CredentialFlowState.class); } catch (final IllegalArgumentException e) { return Collections.emptySet(); } }
From source file:org.ng200.openolympus.util.Beans.java
public static <T> void copy(T from, T to) { final BeanWrapper src = new BeanWrapperImpl(from); final BeanWrapper trg = new BeanWrapperImpl(to); for (final String propertyName : Stream.of(src.getPropertyDescriptors()).map(pd -> pd.getName()) .collect(Collectors.toList())) { if (!trg.isWritableProperty(propertyName)) { continue; }//from w w w . j a va2 s . c o m trg.setPropertyValue(propertyName, src.getPropertyValue(propertyName)); } }
From source file:com.formkiq.core.form.FormTransformer.java
/** * Update {@link FormJSON} by the selected 'optionsgroup'. * @param form {@link FormJSON}//from ww w . ja v a 2 s . c o m */ public static void updateOptionsGroup(final FormJSON form) { List<FormJSONField> list = stream(form).collect(Collectors.toList()); List<String> optionsGroup = list.stream() .filter(f -> !CollectionUtils.isEmpty(f.getOptionsgroup()) && f.getOptionsgroup().size() == f.getOptions().size() && f.getOptions().indexOf(f.getValue()) != -1) .map(f -> f.getOptionsgroup().get(f.getOptions().indexOf(f.getValue()))) .collect(Collectors.toList()); list.forEach(f -> { f.setHide(ListUtils.intersection(f.getGroups(), optionsGroup).isEmpty()); if (CollectionUtils.isEmpty(f.getGroups())) { f.setHide(false); } }); }
From source file:dz.jtsgen.processor.helper.OutputHelper.java
public static List<String> findSourceLine(Compilation c, String packageName, String fileName, Pattern pattern) throws IOException { Assert.assertTrue(c.generatedFile(StandardLocation.SOURCE_OUTPUT, packageName, fileName).isPresent()); JavaFileObject jfo = c.generatedFile(StandardLocation.SOURCE_OUTPUT, packageName, fileName).get(); try (Reader r = jfo.openReader(false)) { return IOUtils.readLines(r).stream().filter((x) -> pattern.matcher(x).find()) .collect(Collectors.toList()); }/*from www . j av a 2 s. c o m*/ }
From source file:com.evolveum.midpoint.model.api.util.DeputyUtils.java
@NotNull public static Collection<PrismReferenceValue> getDelegatorReferences(@NotNull UserType user) { return user.getDelegatedRef().stream().filter(ref -> ObjectTypeUtil.isDelegationRelation(ref.getRelation())) .map(ref -> ref.asReferenceValue().clone()).collect(Collectors.toList()); }
From source file:com.baifendian.swordfish.common.job.struct.node.BaseParam.java
/** * @param resourceInfos//from ww w. ja va 2 s.co m * @param resFiles */ public static void addProjectResourceFiles(List<ResourceInfo> resourceInfos, List<String> resFiles) { if (CollectionUtils.isNotEmpty(resourceInfos)) { resFiles.addAll(resourceInfos.stream().filter(p -> p.isProjectScope()).map(p -> p.getRes()) .collect(Collectors.toList())); } }
From source file:alfio.model.result.Result.java
public static <T> Result<T> validationError(List<ObjectError> errors) { return new Result<>(ResultStatus.VALIDATION_ERROR, null, errors.stream().map(ErrorDescriptor::fromObjectError).collect(Collectors.toList())); }