Skip to content

Commit 6a9823f

Browse files
committed
DATAMONGO-1521 - Added Aggregation.skip(…) overload to support longs.
Deprecated the one taking an int.
1 parent 2ae75a4 commit 6a9823f

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/Aggregation.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,22 @@ public static SortOperation sort(Direction direction, String... fields) {
305305
*
306306
* @param elementsToSkip must not be less than zero.
307307
* @return
308+
* @deprecated prepare to get this one removed in favor of {@link #skip(long)}.
308309
*/
309310
public static SkipOperation skip(int elementsToSkip) {
310311
return new SkipOperation(elementsToSkip);
311312
}
312313

314+
/**
315+
* Creates a new {@link SkipOperation} skipping the given number of elements.
316+
*
317+
* @param elementsToSkip must not be less than zero.
318+
* @return
319+
*/
320+
public static SkipOperation skip(long elementsToSkip) {
321+
return new SkipOperation(elementsToSkip);
322+
}
323+
313324
/**
314325
* Creates a new {@link LimitOperation} limiting the result to the given number of elements.
315326
*

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/SkipOperation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2015 the original author or authors.
2+
* Copyright 2013-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ public class SkipOperation implements AggregationOperation {
3838
/**
3939
* Creates a new {@link SkipOperation} skipping the given number of elements.
4040
*
41-
* @param skipCount number of documents to skip.
41+
* @param skipCount number of documents to skip, must not be less than zero.
4242
*/
4343
public SkipOperation(long skipCount) {
4444

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ public void outShouldOutBeTheLastOperation() {
14761476
newAggregation(match(new Criteria()), //
14771477
group("field1").count().as("totalCount"), //
14781478
out("collection1"), //
1479-
skip(100));
1479+
skip(100L));
14801480
}
14811481

14821482
/**

0 commit comments

Comments
 (0)