本文整理汇总了Java中java.util.Collection.stream方法的典型用法代码示例。如果您正苦于以下问题:Java Collection.stream方法的具体用法?Java Collection.stream怎么用?Java Collection.stream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Collection
的用法示例。
在下文中一共展示了Collection.stream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import java.util.Collection; //导入方法依赖的package包/类
private Stream<MemgraphCypherScope.Item> execute(MemgraphCypherQueryContext ctx, CypherUnwindClause clause, ExpressionScope scope) {
LOGGER.debug("execute: %s", clause);
Object exprResult = expressionExecutor.executeExpression(ctx, clause.getExpression(), scope);
Stream<?> stream;
if (exprResult == null) {
return Stream.of();
} else if (exprResult instanceof Stream) {
stream = (Stream<?>) exprResult;
} else if (exprResult instanceof Collection) {
Collection<?> collection = (Collection<?>) exprResult;
stream = collection.stream();
} else {
throw new MemgraphException("unhandled data type: " + exprResult.getClass().getName());
}
return stream
.map(o -> MemgraphCypherScope.newMapItem(clause.getName(), o, scope));
}
示例2: build
import java.util.Collection; //导入方法依赖的package包/类
@Override
public void build() {
List<ExplodedGraph.Node> egNodes = new ArrayList<>(explodedGraph.nodes().keySet());
int index = 0;
for (ExplodedGraph.Node node : egNodes) {
Collection<ExplodedGraph.Edge> egEdges = node.edges();
addNode(new EGDotNode(index, node, behaviorCache, semanticModel, !egEdges.isEmpty(), cfgFirstBlockId));
Stream<ExplodedGraph.Edge> edgeStream = egEdges.stream();
if (!SHOW_MULTIPLE_PARENTS) {
edgeStream = edgeStream.limit(1);
}
int finalIndex = index;
edgeStream.map(e -> new EGDotEdge(egNodes.indexOf(e.parent()), finalIndex, e, semanticModel)).forEach(this::addEdge);
index++;
}
}
示例3: ConcatTest
import java.util.Collection; //导入方法依赖的package包/类
public ConcatTest(String scenario, Collection<Integer> c1, Collection<Integer> c2, Collection<Integer> expected) {
this.scenario = scenario;
this.c1 = c1;
this.c2 = c2;
this.expected = expected;
// verify prerequisite
Stream<Integer> s1s = c1.stream();
Stream<Integer> s2s = c2.stream();
Stream<Integer> s1p = c1.parallelStream();
Stream<Integer> s2p = c2.parallelStream();
assertTrue(s1p.isParallel());
assertTrue(s2p.isParallel());
assertFalse(s1s.isParallel());
assertFalse(s2s.isParallel());
assertTrue(s1s.spliterator().hasCharacteristics(Spliterator.ORDERED));
assertTrue(s1p.spliterator().hasCharacteristics(Spliterator.ORDERED));
assertTrue(s2s.spliterator().hasCharacteristics(Spliterator.ORDERED));
assertTrue(s2p.spliterator().hasCharacteristics(Spliterator.ORDERED));
}
示例4: getBlogPostingCommentOptional
import java.util.Collection; //导入方法依赖的package包/类
/**
* Returns the blog posting comment that matches the specified ID, if that
* comment exists. Returns {@code Optional#empty()} otherwise.
*
* @param blogPostingCommentId the blog posting comment's ID
* @return the blog posting comment, if present; {@code Optional#empty()}
* otherwise
*/
public static Optional<BlogPostingComment> getBlogPostingCommentOptional(
long blogPostingCommentId) {
Collection<Map<Long, BlogPostingComment>> blogPostingComments =
_blogPostingComments.values();
Stream<Map<Long, BlogPostingComment>> blogPostingCommentsStream =
blogPostingComments.stream();
return blogPostingCommentsStream.map(
Map::values
).map(
Collection::stream
).flatMap(
stream -> stream
).filter(
blogPostingComment ->
blogPostingComment.getBlogPostingCommentId() ==
blogPostingCommentId
).findFirst();
}
示例5: getBlogPostingComments
import java.util.Collection; //导入方法依赖的package包/类
/**
* Returns the page of blog posting comments for a blog posting, as
* specified by the page's start and end positions.
*
* @param blogPostingId the blog posting's ID
* @param start the page's start position
* @param end the page's end position
* @return the page of blog posting comments
*/
public static List<BlogPostingComment> getBlogPostingComments(
long blogPostingId, int start, int end) {
Map<Long, BlogPostingComment> blogPostingComments =
_blogPostingComments.get(blogPostingId);
Collection<BlogPostingComment> blogPostingCommentsValues =
blogPostingComments.values();
Stream<BlogPostingComment> stream = blogPostingCommentsValues.stream();
return stream.skip(
start
).limit(
end
).collect(
Collectors.toList()
);
}
示例6: of
import java.util.Collection; //导入方法依赖的package包/类
/**
* Returns a header of columns of the same type with the characteristics specified
* @param keys the column keys
* @param type the data type
* @param <C> the column type
* @return the newly created header
*/
static <C> DataFrameHeader<C> of(Collection<C> keys, Class<?> type) {
return new DataFrameHeader<C>() {
@Override
public int size() {
return keys.size();
}
@Override
public Stream<C> keys() {
return keys.stream();
}
@Override
public Class<?> type(C colKey) {
return type;
}
};
}
示例7: streamOf
import java.util.Collection; //导入方法依赖的package包/类
private static <T extends QualifiedContent> Stream<T> streamOf(
Collection<TransformInput> inputs,
Function<TransformInput, Collection<T>> mapping) {
Collection<T> list = inputs.stream()
.map(mapping)
.flatMap(Collection::stream)
.collect(Collectors.toList());
if (list.size() >= Runtime.getRuntime().availableProcessors())
return list.parallelStream();
else
return list.stream();
}
示例8: AnalyzeTask
import java.util.Collection; //导入方法依赖的package包/类
AnalyzeTask(final Collection<OuterWrap> wraps, String... extraArgs) {
this(wraps.stream(),
new WrapSourceHandler(),
Util.join(new String[] {
"--should-stop:at=FLOW", "-Xlint:unchecked",
"-proc:none"
}, extraArgs));
}
示例9: getBlogPostings
import java.util.Collection; //导入方法依赖的package包/类
/**
* Returns the page of blog postings specified by the page's start and end
* positions.
*
* @param start the page's start position
* @param end the page's end position
* @return the page of blog postings
*/
public static List<BlogPosting> getBlogPostings(int start, int end) {
Collection<BlogPosting> blogPostings = _blogPostings.values();
Stream<BlogPosting> stream = blogPostings.stream();
return stream.skip(
start
).limit(
end
).collect(
Collectors.toList()
);
}
示例10: getPeople
import java.util.Collection; //导入方法依赖的package包/类
/**
* Returns the page of persons, as specified by the page's start and end
* positions.
*
* @param start the page's start position
* @param end the page's end position
* @return the page of persons
*/
public static List<Person> getPeople(int start, int end) {
Collection<Person> persons = _persons.values();
Stream<Person> stream = persons.stream();
return stream.skip(
start
).limit(
end
).collect(
Collectors.toList()
);
}
示例11: tests
import java.util.Collection; //导入方法依赖的package包/类
@TestFactory
public Stream<DynamicTest> tests() throws Exception {
Collection<DynamicTest> dynamicTests = new ArrayList<DynamicTest>();
for (YamlTestGroup yamlTestGroup : yamlTestGroups) {
if (!yamlTestGroup.isTagged()) {
logger.info("->testGroup skipped tag does not exist for testGroup name="
+ yamlTestGroup.getName()+", tags="+yamlTestGroup.getTags());
continue;
}
for (YamlTest yamlTest : yamlTestGroup.getTests()) {
final String testcaseName = "testGroup=" + yamlTestGroup.getName()
+ ", test=" + yamlTest.getName()
+ ", group tags="+yamlTestGroup.getTags()
+ ", test tags="+yamlTest.getTags();
if (!yamlTest.isTagged()) {
logger.info("->test skipped tag does not exist " + testcaseName);
continue;
}
Executable executable = setupTest(yamlTestGroup, yamlTest, testcaseName);
DynamicTest dTest = DynamicTest.dynamicTest(testcaseName, executable);
dynamicTests.add(dTest);
}
}
return dynamicTests.stream();
}
示例12: CompileTask
import java.util.Collection; //导入方法依赖的package包/类
CompileTask(final Collection<OuterWrap> wraps) {
super(wraps.stream(), new WrapSourceHandler(),
"-Xlint:unchecked", "-proc:none", "-parameters");
}
示例13: stream
import java.util.Collection; //导入方法依赖的package包/类
/**
* Returns {@link Collection#stream}.
*
* @deprecated There is no reason to use this; just invoke {@code collection.stream()} directly.
*/
@Deprecated
public static <T> Stream<T> stream(Collection<T> collection) {
return collection.stream();
}
示例14: addAllBooleans
import java.util.Collection; //导入方法依赖的package包/类
/**
* Adds all elements of a boolean collection as elements of the JSON
* array.
*
* @param collection the boolean collection to add to the JSON array
*/
public void addAllBooleans(Collection<Boolean> collection) {
Stream<Boolean> stream = collection.stream();
stream.forEach(_jsonArray::add);
}
示例15: addAllStrings
import java.util.Collection; //导入方法依赖的package包/类
/**
* Adds all elements of a string collection as elements of the JSON
* array.
*
* @param collection the string collection to add to the JSON array
*/
public void addAllStrings(Collection<String> collection) {
Stream<String> stream = collection.stream();
stream.forEach(_jsonArray::add);
}