-
Notifications
You must be signed in to change notification settings - Fork 192
DATACOUCH-963 - Scope and collection api. #1071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2012-2020 the original author or authors | ||
* Copyright 2012-2021 the original author or authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -15,13 +15,14 @@ | |
*/ | ||
package org.springframework.data.couchbase.core; | ||
|
||
import org.springframework.data.couchbase.core.ReactiveExistsByIdOperationSupport.ReactiveExistsByIdSupport; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
import org.springframework.data.couchbase.core.ReactiveExistsByIdOperationSupport.ReactiveExistsByIdSupport; | ||
import org.springframework.util.Assert; | ||
|
||
import com.couchbase.client.java.kv.ExistsOptions; | ||
|
||
public class ExecutableExistsByIdOperationSupport implements ExecutableExistsByIdOperation { | ||
|
||
private final CouchbaseTemplate template; | ||
|
@@ -32,17 +33,25 @@ public class ExecutableExistsByIdOperationSupport implements ExecutableExistsByI | |
|
||
@Override | ||
public ExecutableExistsById existsById() { | ||
return new ExecutableExistsByIdSupport(template, null); | ||
return new ExecutableExistsByIdSupport(template, null, null, null); | ||
} | ||
|
||
static class ExecutableExistsByIdSupport implements ExecutableExistsById { | ||
|
||
private final CouchbaseTemplate template; | ||
private final String scope; | ||
private final String collection; | ||
private final ExistsOptions options; | ||
|
||
private final ReactiveExistsByIdSupport reactiveSupport; | ||
|
||
ExecutableExistsByIdSupport(final CouchbaseTemplate template, final String collection) { | ||
ExecutableExistsByIdSupport(final CouchbaseTemplate template, final String scope, final String collection, | ||
final ExistsOptions options) { | ||
this.template = template; | ||
this.reactiveSupport = new ReactiveExistsByIdSupport(template.reactive(), collection); | ||
this.scope = scope; | ||
this.collection = collection; | ||
this.options = options; | ||
this.reactiveSupport = new ReactiveExistsByIdSupport(template.reactive(), scope, collection, options); | ||
} | ||
|
||
@Override | ||
|
@@ -56,11 +65,22 @@ public Map<String, Boolean> all(final Collection<String> ids) { | |
} | ||
|
||
@Override | ||
public TerminatingExistsById inCollection(final String collection) { | ||
public ExistsByIdWithOptions inCollection(final String collection) { | ||
Assert.hasText(collection, "Collection must not be null nor empty."); | ||
return new ExecutableExistsByIdSupport(template, collection); | ||
return new ExecutableExistsByIdSupport(template, scope, collection, options); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was the assertion removed by accident? I wonder if it makes sense to validate those as well (also inScope) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At one point I removed the assertion to allow just calling without checking if the caller was using collections or not. That said - I put the assertion back in and all the tests pass - so it seems I'm not doing that anymore. I'll put it back for scope and collection. |
||
} | ||
|
||
@Override | ||
public TerminatingExistsById withOptions(final ExistsOptions options) { | ||
Assert.notNull(options, "Options must not be null."); | ||
return new ExecutableExistsByIdSupport(template, scope, collection, options); | ||
} | ||
|
||
@Override | ||
public ExistsByIdInCollection inScope(final String scope) { | ||
Assert.hasText(scope, "Scope must not be null nor empty."); | ||
return new ExecutableExistsByIdSupport(template, scope, collection, options); | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy/paste?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No - I tried to fill in some of the missing javadoc. From looking at javadoc on other classes that would have been created at the same time, I assumed the same author.