當前位置: 首頁>>代碼示例>>Java>>正文


Java List.stream方法代碼示例

本文整理匯總了Java中java.util.List.stream方法的典型用法代碼示例。如果您正苦於以下問題:Java List.stream方法的具體用法?Java List.stream怎麽用?Java List.stream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.List的用法示例。


在下文中一共展示了List.stream方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPageItems

import java.util.List; //導入方法依賴的package包/類
@Override
public PageItems<WebSite> getPageItems(
	Pagination pagination, long companyId) {

	List<Group> groups = _groupLocalService.getGroups(companyId, 0, true);

	List<Group> paginationGroups = ListUtil.subList(
		groups, pagination.getStartPosition(), pagination.getEndPosition());

	Stream<Group> stream = paginationGroups.stream();

	List<WebSite> webSites = stream.map(
		WebSiteImpl::new
	).collect(
		Collectors.toList()
	);

	int count = _groupLocalService.getGroupsCount(companyId, 0, true);

	return new PageItems<>(webSites, count);
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:22,代碼來源:WebSiteServiceImpl.java

示例2: potentialMatchersInOrder

import java.util.List; //導入方法依賴的package包/類
private static <R> Stream<Matcher<R>> potentialMatchersInOrder(
        List<Matcher<R>> cases,
        SortedSetMultimap<Class<?>, Indexed<Matcher<R>>> matchersByScopeType,
        Object object
) {
    if (object == null) {
        return cases.stream();
    } else {
        Stream<Class<?>> supertypes = Util.supertypes(object.getClass());
        TreeSet<Indexed<Matcher<R>>> indexedMatchersInOrder = supertypes
                .flatMap(type -> matchersByScopeType.get(type).stream())
                .collect(toCollection(TreeSet::new));
        return indexedMatchersInOrder.stream()
                .map(Indexed::value);
    }
}
 
開發者ID:matchmaker,項目名稱:matchmaker,代碼行數:17,代碼來源:MultiMatcherMatchFunctions.java

示例3: retrieve

import java.util.List; //導入方法依賴的package包/類
@Override
public List<Movie> retrieve(Query query) throws PersistException {
    List<Movie> movies = getMovies();
    Stream<Movie> stream = movies.stream();
    
    // filter
    if (query.hasFilters() || query.getSearch() != null) {
        stream = stream.filter(movie -> query.match(new JsonMatcher(movie.toJson())));
    }
    
    // sort
    if ((query.getSort() != null && !"title".equals(query.getSort())) || query.isDescending()) {
        stream = stream.sorted(new JsonableComparator(query, (j1, j2) -> {
            return getSortTitle(j1).compareToIgnoreCase(getSortTitle(j2));
        }));
    }
    
    // paginate
    if (query.getStart() > 0)
        stream = stream.skip(query.getStart());
    if (query.getMax() != Query.MAX_ALL)
        stream = stream.limit(query.getMax());
    
    return stream.collect(Collectors.toList());
}
 
開發者ID:limberest,項目名稱:limberest-demo,代碼行數:26,代碼來源:MoviesPersistFile.java

示例4: retrieveTagFromAnnotation

import java.util.List; //導入方法依賴的package包/類
private Stream<String> retrieveTagFromAnnotation(Annotation tagsAnnotation) {
    final List<String> tags = new ArrayList<>();
    if (TAG.equals(tagsAnnotation.annotationType().getName())) {
        final String tagName = getTagName(tagsAnnotation);
        if (tagName != null) {
            tags.add(tagName);
        }
    } else {
        tags.addAll(getMultipleTagNames(tagsAnnotation));
    }
    return tags.stream();
}
 
開發者ID:arquillian,項目名稱:smart-testing,代碼行數:13,代碼來源:TagsParser.java

示例5: denormalizeIdentifier

import java.util.List; //導入方法依賴的package包/類
public Stream<String> denormalizeIdentifier(String identifier) {
  if (!namespaceMatcher.asPredicate().test(identifier)) {
    return Stream.of(identifier);
  }

  List<String> identifiers = new ArrayList<>();
  identifiers.add(identifier);
  for (Map.Entry<String, String> entry : namespaceToAlias.entrySet()) {
    if (identifier.startsWith(entry.getKey())) {
      identifiers.add(identifier.replace(entry.getKey(), entry.getValue()));
    }
  }
  return identifiers.stream();
}
 
開發者ID:google,項目名稱:bamboo-soy,代碼行數:15,代碼來源:TemplateNameUtils.java

示例6: getSparsityTestLoop

import java.util.List; //導入方法依賴的package包/類
private static Stream<Double> getSparsityTestLoop() {
  List<Double> sparsity = new ArrayList<>();
  for(nonsparse = 0.02; nonsparse <= 1.0; nonsparse += 0.02) {
    sparsity.add(nonsparse);
  }
  return sparsity.stream();
}
 
開發者ID:flybotix,項目名稱:highfrequencyrobots,代碼行數:8,代碼來源:DataCoderTest.java

示例7: layers

import java.util.List; //導入方法依賴的package包/類
/**
 * Returns a stream of the layers that have at least one module defined to
 * the given class loader.
 */
static Stream<ModuleLayer> layers(ClassLoader loader) {
    List<ModuleLayer> list = CLV.get(loader);
    if (list != null) {
        return list.stream();
    } else {
        return Stream.empty();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:ModuleLayer.java

示例8: entries

import java.util.List; //導入方法依賴的package包/類
@Override
public Stream<ResourcePoolEntry> entries() {
    List<ResourcePoolEntry> lst = new ArrayList<>();
    module.entries().forEach(md -> {
        lst.add(getUncompressed(md));
    });
    return lst.stream();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:ImagePluginStack.java

示例9: getLabels

import java.util.List; //導入方法依賴的package包/類
private <T extends Annotation> Stream<Label> getLabels(final IterationInfo iterationInfo, final Class<T> clazz,
                                                       final Function<T, Label> extractor) {
    final List<Label> onFeature = getFeatureAnnotations(iterationInfo, clazz).stream()
            .map(extractor)
            .collect(Collectors.toList());
    if (!onFeature.isEmpty()) {
        return onFeature.stream();
    }
    return getSpecAnnotations(iterationInfo, clazz).stream()
            .map(extractor);
}
 
開發者ID:allure-framework,項目名稱:allure-java,代碼行數:12,代碼來源:AllureSpock.java

示例10: getLabels

import java.util.List; //導入方法依賴的package包/類
private <T extends Annotation> Stream<Label> getLabels(final Description result, final Class<T> labelAnnotation,
                                                       final Function<T, Label> extractor) {

    final List<Label> labels = getAnnotationsOnMethod(result, labelAnnotation).stream()
            .map(extractor)
            .collect(Collectors.toList());

    if (labelAnnotation.isAnnotationPresent(Repeatable.class) || labels.isEmpty()) {
        final Stream<Label> onClassLabels = getAnnotationsOnClass(result, labelAnnotation).stream()
                .map(extractor);
        labels.addAll(onClassLabels.collect(Collectors.toList()));
    }

    return labels.stream();
}
 
開發者ID:allure-framework,項目名稱:allure-java,代碼行數:16,代碼來源:AllureJunit4.java

示例11: getInput

import java.util.List; //導入方法依賴的package包/類
@Override
public Stream<Tuple<String>> getInput() {
    List<Tuple<String>> inputTuples = Arrays.asList(
            createMapTuple(1, 2, 3),
            createMapTuple(4, 5, 6),
            createMapTuple(7, 8, 9));
    return inputTuples.stream();
}
 
開發者ID:gchq,項目名稱:koryphe,代碼行數:9,代碼來源:TupleAndExample.java

示例12: flatten

import java.util.List; //導入方法依賴的package包/類
private Stream<String> flatten(String delimiter, Stream<Stream<String>> bumpy) {
    final List<String> flat = new ArrayList<>();
    bumpy.forEachOrdered(lines -> {
        if(!flat.isEmpty()) {
            final int last = flat.size() - 1;
            flat.set(last, flat.get(last) + delimiter);
        }
        lines.forEachOrdered(flat::add);
    });
    return flat.stream();
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:12,代碼來源:MultiLineTextInspector.java

示例13: createExecutionInterceptorFromResource

import java.util.List; //導入方法依賴的package包/類
private Stream<ExecutionInterceptor> createExecutionInterceptorFromResource(URL resource) {
    try {
        if (resource == null) {
            return Stream.empty();
        }

        List<ExecutionInterceptor> interceptors = new ArrayList<>();

        try (InputStream stream = resource.openStream();
             InputStreamReader streamReader = new InputStreamReader(stream, StandardCharsets.UTF_8);
             BufferedReader fileReader = new BufferedReader(streamReader)) {

            String interceptorClassName = fileReader.readLine();
            while (interceptorClassName != null) {
                ExecutionInterceptor interceptor = createExecutionInterceptor(interceptorClassName);
                if (interceptor != null) {
                    interceptors.add(interceptor);
                }
                interceptorClassName = fileReader.readLine();
            }
        }

        return interceptors.stream();
    } catch (IOException e) {
        throw new SdkClientException("Unable to instantiate execution interceptor chain.", e);
    }
}
 
開發者ID:aws,項目名稱:aws-sdk-java-v2,代碼行數:28,代碼來源:ClasspathInterceptorChainFactory.java

示例14: implList

import java.util.List; //導入方法依賴的package包/類
@Override
Stream<String> implList() throws IOException {
    // take snapshot to avoid async close
    List<String> names = jf.stream()
            .filter(e -> e.section() == JmodFile.Section.CLASSES)
            .map(JmodFile.Entry::name)
            .collect(Collectors.toList());
    return names.stream();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:ModuleReferences.java

示例15: getInput

import java.util.List; //導入方法依賴的package包/類
@Override
public Stream<Tuple2<Integer, Integer>> getInput() {
    List<Tuple2<Integer, Integer>> inputTuples = Arrays.asList(
            new Tuple2<>(8, 1),
            new Tuple2<>(8, 2),
            new Tuple2<>(8, 3));
    return inputTuples.stream();
}
 
開發者ID:gchq,項目名稱:koryphe,代碼行數:9,代碼來源:DivideExample.java


注:本文中的java.util.List.stream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。