本文整理匯總了Java中java.util.stream.Stream.skip方法的典型用法代碼示例。如果您正苦於以下問題:Java Stream.skip方法的具體用法?Java Stream.skip怎麽用?Java Stream.skip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.stream.Stream
的用法示例。
在下文中一共展示了Stream.skip方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: applySkipToResults
import java.util.stream.Stream; //導入方法依賴的package包/類
private Stream<MemgraphCypherScope.Item> applySkipToResults(
MemgraphCypherQueryContext ctx,
Stream<MemgraphCypherScope.Item> results,
CypherSkip skipClause,
MemgraphCypherScope scope
) {
Object skipObj = ctx.getExpressionExecutor().executeExpression(ctx, skipClause.getExpression(), scope);
int skip;
if (skipObj instanceof Integer || skipObj instanceof Long) {
skip = ((Number) skipObj).intValue();
} else {
throw new MemgraphException("skip with a none integer not supported: " + skipObj);
}
results = results.skip(skip);
return results;
}
示例2: retrieve
import java.util.stream.Stream; //導入方法依賴的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());
}