本文整理匯總了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);
}
示例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);
}
}
示例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());
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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();
}
示例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();
}