DATAMONGO-1783 - Polishing.

Move Meta cloning to Meta class. Consider all Meta properties.

Original pull request: #650.
This commit is contained in:
Mark Paluch
2019-02-26 16:13:01 +01:00
parent ed9173c384
commit 20fab74965
2 changed files with 21 additions and 9 deletions

View File

@@ -49,10 +49,24 @@ public class Meta {
}
}
private final Map<String, Object> values = new LinkedHashMap<String, Object>(2);
private final Set<CursorOption> flags = new LinkedHashSet<CursorOption>();
private final Map<String, Object> values = new LinkedHashMap<>(2);
private final Set<CursorOption> flags = new LinkedHashSet<>();
private Integer cursorBatchSize;
public Meta() {}
/**
* Copy a {@link Meta} object.
*
* @since 2.2
* @param source
*/
Meta(Meta source) {
this.values.putAll(source.values);
this.flags.addAll(source.flags);
this.cursorBatchSize = source.cursorBatchSize;
}
/**
* @return {@literal null} if not set.
*/

View File

@@ -30,6 +30,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.bson.Document;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
@@ -373,7 +374,7 @@ public class Query {
* Set the number of documents to return in each response batch. <br />
* Use {@literal 0 (zero)} for no limit. A <strong>negative limit</strong> closes the cursor after returning a single
* batch indicating to the server that the client will not ask for a subsequent one.
*
*
* @param batchSize The number of documents to return per batch.
* @return this.
* @see Meta#setCursorBatchSize(int)
@@ -432,7 +433,7 @@ public class Query {
}
/**
* @return never {@literal null}.ø
* @return never {@literal null}.
* @since 1.6
*/
public Meta getMeta() {
@@ -519,11 +520,8 @@ public class Query {
target.collation = source.collation;
target.restrictedTypes.addAll(source.restrictedTypes);
if (source.getMeta() != null && source.getMeta().hasValues()) {
Meta meta = new Meta();
source.getMeta().values().forEach(it -> meta.setValue(it.getKey(), it.getValue()));
target.setMeta(meta);
if (source.getMeta().hasValues()) {
target.setMeta(new Meta(source.getMeta()));
}
return target;