Browse Source

DATAMONGO-1521 - Added Aggregation.skip(…) overload to support longs.

Deprecated the one taking an int.
pull/407/head
Oliver Gierke 9 years ago
parent
commit
6a9823fd24
  1. 11
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/Aggregation.java
  2. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/SkipOperation.java
  3. 2
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationTests.java

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

@ -305,11 +305,22 @@ public class Aggregation {
* *
* @param elementsToSkip must not be less than zero. * @param elementsToSkip must not be less than zero.
* @return * @return
* @deprecated prepare to get this one removed in favor of {@link #skip(long)}.
*/ */
public static SkipOperation skip(int elementsToSkip) { public static SkipOperation skip(int elementsToSkip) {
return new SkipOperation(elementsToSkip); return new SkipOperation(elementsToSkip);
} }
/**
* Creates a new {@link SkipOperation} skipping the given number of elements.
*
* @param elementsToSkip must not be less than zero.
* @return
*/
public static SkipOperation skip(long elementsToSkip) {
return new SkipOperation(elementsToSkip);
}
/** /**
* Creates a new {@link LimitOperation} limiting the result to the given number of elements. * Creates a new {@link LimitOperation} limiting the result to the given number of elements.
* *

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2013-2015 the original author or authors. * Copyright 2013-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ public class SkipOperation implements AggregationOperation {
/** /**
* Creates a new {@link SkipOperation} skipping the given number of elements. * Creates a new {@link SkipOperation} skipping the given number of elements.
* *
* @param skipCount number of documents to skip. * @param skipCount number of documents to skip, must not be less than zero.
*/ */
public SkipOperation(long skipCount) { public SkipOperation(long skipCount) {

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

@ -1476,7 +1476,7 @@ public class AggregationTests {
newAggregation(match(new Criteria()), // newAggregation(match(new Criteria()), //
group("field1").count().as("totalCount"), // group("field1").count().as("totalCount"), //
out("collection1"), // out("collection1"), //
skip(100)); skip(100L));
} }
/** /**

Loading…
Cancel
Save