List of usage examples for java.util List stream
default Stream<E> stream()
From source file:edu.umd.umiacs.clip.tools.classifier.LibSVMUtils.java
public static List<String> filter(List<String> training, int threshold) { Set<Integer> filtered = training.stream().flatMap(line -> Stream.of(line.split(" ")).skip(1)) .map(pair -> new Integer(pair.substring(0, pair.indexOf(":")))) .collect(groupingBy(i -> i, counting())).entrySet().stream() .filter(entry -> entry.getValue() >= threshold).map(Entry::getKey).collect(toSet()); return training.stream().map(line -> line.split(" ")) .map(fields -> fields[0] + " " + String.join(" ", Stream.of(fields).skip(1).filter( pair -> filtered.contains(new Integer(pair.substring(0, pair.indexOf(":"))))) .collect(toList()))) .map(String::trim).collect(toList()); }
From source file:info.archinnov.achilles.internals.parser.validator.BeanValidator.java
public static void validateHasPartitionKey(AptUtils aptUtils, TypeName rawClassType, List<TypeParsingResult> parsingResults) { final boolean hasPartitionKey = parsingResults.stream() .filter(x -> x.context.columnType == ColumnType.PARTITION).count() > 0; aptUtils.validateTrue(hasPartitionKey, "The class '%s' should have at least 1 partition key (@PartitionKey)", rawClassType); }
From source file:com.hubrick.raml.codegen.springweb.RestControllerClassGenerator.java
private static JExpression flushBuffer(List<String> stringBuffer) { final String str = stringBuffer.stream().collect(Collectors.joining("")); stringBuffer.clear();/*from ww w.ja va2 s. co m*/ return JExpr.lit(str); }
From source file:com.epam.ta.reportportal.core.widget.content.WidgetContentProvider.java
/** * Transform chart data fields names to database known names using criteria * holder./*from w w w .j a v a 2 s. co m*/ */ public static List<String> transformToDBStyle(CriteriaMap<?> criteriaMap, List<String> chartFields) { if (chartFields == null) return new ArrayList<>(); return chartFields.stream().map(it -> { return criteriaMap.getCriteriaHolder(it).getQueryCriteria(); //+ ((filterCriteria.getExtension() != null) ? "." + filterCriteria.getExtension() : ""); }).collect(toList()); }
From source file:com.freiheit.fuava.sftp.util.FilenameUtil.java
/** * Returns all filenames from the given entryList which match the search * conditions./*from w ww .j a va2 s . com*/ */ public static List<String> getAllMatchingFilenames(final String requestedTimestamp, final FileType fileType, final List<String> entryList, @Nullable final RemoteFileStatus status) { return entryList.stream().filter(p -> p != null) .filter(f -> FilenameUtil.matchesSearchedFile(f, fileType, requestedTimestamp, status)) .collect(Collectors.toList()); }
From source file:info.archinnov.achilles.internals.parser.validator.BeanValidator.java
public static boolean isCounterTable(AptUtils aptUtils, TypeName rawClassType, List<TypeParsingResult> parsingResults) { final boolean hasCounter = parsingResults.stream().filter(x -> x.context.columnType == ColumnType.COUNTER) .count() > 0;//ww w . j ava2 s. c o m final boolean hasStaticCounter = parsingResults.stream() .filter(x -> x.context.columnType == ColumnType.STATIC_COUNTER).count() > 0; final boolean hasNormal = parsingResults.stream().filter(x -> x.context.columnType == ColumnType.NORMAL) .count() > 0; if (hasCounter || hasStaticCounter) { aptUtils.validateFalse(hasNormal, "Class '%s' should not mix counter and normal columns", rawClassType); } return hasCounter || hasStaticCounter; }
From source file:internal.static_util.scorer.TermRelatednessScorer.java
/** * Helper method to run ScoredTerms through a filter and give the axe to ones that fall below the cutoff point. * * @param scoredTerms A list of terms that have scores. * @param minRelevanceRatio The minimum score a term must have to avoid being cut. If none is given, * #DEFAULT_CUTOFF_RATIO# is assumed. * @return A trimmed list of scored terms, containing only terms who scored greater than #minRelevanceRatio# *///from ww w .j a va 2 s . c om private static List<ScoredTerm> getRelevantTerms(List<ScoredTerm> scoredTerms, double minRelevanceRatio) { // If a cutoff is specified, use it, otherwise use the default. return scoredTerms.stream().filter(scoredTerm -> scoredTerm.getScore() >= minRelevanceRatio) .collect(Collectors.toList()); }
From source file:com.github.anba.es6draft.test262.Test262Strict.java
public static final Set<String> stringSet(List<?> xs) { Predicate<String> nonEmpty = ((Predicate<String>) String::isEmpty).negate(); return xs.stream().filter(Objects::nonNull).map(Object::toString).filter(nonEmpty) .collect(Collectors.toSet()); }
From source file:de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutElement.java
public static List<JSONDocumentLayoutElement> ofList(final List<DocumentLayoutElementDescriptor> elements, final JSONOptions jsonOpts) { return elements.stream().filter(jsonOpts.documentLayoutElementFilter()) .map(element -> new JSONDocumentLayoutElement(element, jsonOpts)) .collect(GuavaCollectors.toImmutableList()); }
From source file:alfio.controller.api.admin.ExtensionApiController.java
private static void ensureIdsArePresent(List<ExtensionMetadataValue> toUpdate, List<ExtensionParameterMetadataAndValue> system) { Set<Integer> validIds = system.stream().map(ExtensionParameterMetadataAndValue::getId) .collect(Collectors.toSet()); Set<Integer> toUpdateIds = toUpdate.stream().map(ExtensionMetadataValue::getId).collect(Collectors.toSet()); if (!validIds.containsAll(toUpdateIds)) { throw new IllegalStateException(); }/*from ww w. j a va 2 s .c o m*/ }