当前位置: 首页>>代码示例>>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;未经允许,请勿转载。