44
55package akka .stream .alpakka .couchbase .impl
66
7- import akka .NotUsed
7+ import akka .{ Done , NotUsed }
88import akka .annotation .InternalApi
99import akka .stream .alpakka .couchbase .javadsl .CouchbaseSession
10- import akka .stream .alpakka .couchbase .{javadsl , scaladsl }
10+ import akka .stream .alpakka .couchbase .{CouchbaseDocument , javadsl , scaladsl }
1111import akka .stream .javadsl .Source
1212import com .couchbase .client .java .json .{JsonArray , JsonObject , JsonValue }
1313import com .couchbase .client .java .kv .{InsertOptions , RemoveOptions , ReplaceOptions , UpsertOptions }
@@ -16,6 +16,7 @@ import com.couchbase.client.java.{AsyncCollection, AsyncScope}
1616
1717import java .time .Duration
1818import java .util .concurrent .{CompletionStage , TimeUnit }
19+ import scala .concurrent .Future
1920import scala .concurrent .duration .FiniteDuration
2021import scala .jdk .FutureConverters ._
2122
@@ -40,53 +41,53 @@ private[couchbase] final class CouchbaseCollectionSessionJavaAdapter(delegate: s
4041 * @param document A tuple where first element is id of the document and second is its value
4142 * @return A Future that completes with the id of the written document when the write is done
4243 */
43- override def insert [T ](document : ( String , T )) : CompletionStage [( String , T ) ] =
44- delegate.insert(document).asJava
44+ override def insert [T ](id : String , document : T ) : CompletionStage [Done ] =
45+ delegate.insert(id, document).asJava
4546
46- override def insert [T ](document : ( String , T ) , insertOptions : InsertOptions ): CompletionStage [( String , T ) ] =
47- delegate.insert(document, insertOptions).asJava
47+ override def insert [T ](id : String , document : T , insertOptions : InsertOptions ): CompletionStage [Done ] =
48+ delegate.insert(id, document, insertOptions).asJava
4849
49- override def getJsonObject (id : String ): CompletionStage [( String , JsonObject ) ] =
50+ override def getJsonObject (id : String ): CompletionStage [CouchbaseDocument [ JsonObject ] ] =
5051 delegate.getJsonObject(id).asJava
5152
52- override def getJsonArray (id : String ): CompletionStage [( String , JsonArray ) ] =
53+ override def getJsonArray (id : String ): CompletionStage [CouchbaseDocument [ JsonArray ] ] =
5354 delegate.getJsonArray(id).asJava
5455
55- override def get [T ](id : String , target : Class [T ]): CompletionStage [( String , T ) ] =
56+ override def get [T ](id : String , target : Class [T ]): CompletionStage [CouchbaseDocument [ T ] ] =
5657 delegate.get(id, target).asJava
5758 /**
5859 * @return A document if found or none if there is no document for the id
5960 */
60- override def getDocument (id : String ): CompletionStage [( String , JsonValue ) ] =
61+ override def getDocument (id : String ): CompletionStage [CouchbaseDocument [ JsonValue ] ] =
6162 delegate.getDocument(id).asJava
6263
6364 /**
6465 * @param id Identifier of the document to fetch
6566 * @return Raw data for the document or none
6667 */
67- override def getBytes (id : String ): CompletionStage [( String , Array [Byte ]) ] =
68+ override def getBytes (id : String ): CompletionStage [CouchbaseDocument [ Array [Byte ]] ] =
6869 delegate.getBytes(id).asJava
6970
7071 /**
7172 * @param timeout fail the returned future with a TimeoutException if it takes longer than this
7273 * @return A document if found or none if there is no document for the id
7374 */
74- override def getDocument (id : String , timeout : Duration ): CompletionStage [( String , JsonValue ) ] =
75+ override def getDocument (id : String , timeout : Duration ): CompletionStage [CouchbaseDocument [ JsonValue ] ] =
7576 delegate.getDocument(id, FiniteDuration .apply(timeout.toNanos, TimeUnit .NANOSECONDS )).asJava
7677
7778 /**
7879 * @return A raw document data if found or none if there is no document for the id
7980 */
80- override def getBytes (id : String , timeout : Duration ): CompletionStage [( String , Array [Byte ]) ] =
81+ override def getBytes (id : String , timeout : Duration ): CompletionStage [CouchbaseDocument [ Array [Byte ]] ] =
8182 delegate.getBytes(id, FiniteDuration .apply(timeout.toNanos, TimeUnit .NANOSECONDS )).asJava
8283
8384 /**
8485 * Upsert using the default write settings.
8586 *
8687 * @return a future that completes when the upsert is done
8788 */
88- override def upsert [T ](document : ( String , T )) : CompletionStage [( String , T ) ] =
89- delegate.upsert(document).asJava
89+ override def upsert [T ](id : String , document : T ) : CompletionStage [Done ] =
90+ delegate.upsert(id, document).asJava
9091
9192 /**
9293 * Upsert using the given write settings
@@ -95,19 +96,20 @@ private[couchbase] final class CouchbaseCollectionSessionJavaAdapter(delegate: s
9596 *
9697 * @return a future that completes when the upsert is done
9798 */
98- override def upsert [T ](document : ( String , T ) , upsertOptions : UpsertOptions ): CompletionStage [( String , T ) ] =
99- delegate.upsert(document, upsertOptions).asJava
99+ override def upsert [T ](id : String , document : T , upsertOptions : UpsertOptions ): CompletionStage [Done ] =
100+ delegate.upsert(id, document, upsertOptions).asJava
100101
101102 /**
102103 * Upsert using given write settings and timeout
103104 *
104- * @param document document id and value to upsert
105+ * @param id document id
106+ * @param document document value to upsert
105107 * @param upsertOptions Couchbase UpsertOptions
106108 * @param timeout timeout for the operation
107- * @return the document id and value
109+ * @return a future that completes after the operation is done
108110 */
109- override def upsert [T ](document : ( String , T ) , upsertOptions : UpsertOptions , timeout : Duration ): CompletionStage [( String , T ) ] =
110- delegate.upsert(document, upsertOptions, FiniteDuration .apply(timeout.toNanos, TimeUnit .NANOSECONDS )).asJava
111+ override def upsert [T ](id : String , document : T , upsertOptions : UpsertOptions , timeout : Duration ): CompletionStage [Done ] =
112+ delegate.upsert(id, document, upsertOptions, FiniteDuration .apply(timeout.toNanos, TimeUnit .NANOSECONDS )).asJava
111113
112114 /**
113115 * Replace using the default write settings.
@@ -116,8 +118,8 @@ private[couchbase] final class CouchbaseCollectionSessionJavaAdapter(delegate: s
116118 *
117119 * @return a future that completes when the replace is done
118120 */
119- override def replace [T ](document : ( String , T )) : CompletionStage [( String , T ) ] =
120- delegate.replace(document).asJava
121+ override def replace [T ](id : String , document : T ) : CompletionStage [Done ] =
122+ delegate.replace(id, document).asJava
121123
122124 /**
123125 * Replace using the given replace options
@@ -126,27 +128,28 @@ private[couchbase] final class CouchbaseCollectionSessionJavaAdapter(delegate: s
126128 *
127129 * @return a future that completes when the replace is done
128130 */
129- override def replace [T ](document : ( String , T ) , replaceOptions : ReplaceOptions ): CompletionStage [( String , T ) ] =
130- delegate.replace(document, replaceOptions).asJava
131+ override def replace [T ](id : String , document : T , replaceOptions : ReplaceOptions ): CompletionStage [Done ] =
132+ delegate.replace(id, document, replaceOptions).asJava
131133
132134 /**
133135 * Replace using write settings and timeout
134136 *
135- * @param document document id and value to replace
137+ * @param id id of the document to replace
138+ * @param document document value to replace
136139 * @param replaceOptions Couchbase replace options
137140 * @param timeout timeout for the operation
138- * @return the document id and value
141+ * @return a future that completes after the operation is done
139142 */
140- override def replace [T ](document : ( String , T ) , replaceOptions : ReplaceOptions , timeout : Duration ): CompletionStage [( String , T ) ] =
141- delegate.replace(document, replaceOptions, FiniteDuration .apply(timeout.toNanos, TimeUnit .NANOSECONDS )).asJava
143+ override def replace [T ](id : String , document : T , replaceOptions : ReplaceOptions , timeout : Duration ): CompletionStage [Done ] =
144+ delegate.replace(id, document, replaceOptions, FiniteDuration .apply(timeout.toNanos, TimeUnit .NANOSECONDS )).asJava
142145
143146 /**
144147 * Remove a document by id using the default write settings.
145148 *
146149 * @return Future that completes when the document has been removed, if there is no such document
147150 * the future is failed with a `DocumentDoesNotExistException`
148151 */
149- override def remove (id : String ): CompletionStage [String ] =
152+ override def remove (id : String ): CompletionStage [Done ] =
150153 delegate.remove(id).asJava
151154
152155 /**
@@ -155,7 +158,7 @@ private[couchbase] final class CouchbaseCollectionSessionJavaAdapter(delegate: s
155158 * @return Future that completes when the document has been removed, if there is no such document
156159 * the future is failed with a `DocumentDoesNotExistException`
157160 */
158- override def remove (id : String , removeOptions : RemoveOptions ): CompletionStage [String ] =
161+ override def remove (id : String , removeOptions : RemoveOptions ): CompletionStage [Done ] =
159162 delegate.remove(id, removeOptions).asJava
160163
161164 /**
@@ -179,7 +182,7 @@ private[couchbase] final class CouchbaseCollectionSessionJavaAdapter(delegate: s
179182 * if the index existed and `ignoreIfExist` is `true`. Completion of the future does not guarantee the index is online
180183 * and ready to be used.
181184 */
182- override def createIndex (indexName : String , createQueryIndexOptions : CreateQueryIndexOptions , fields : String * ): CompletionStage [Void ] =
185+ override def createIndex (indexName : String , createQueryIndexOptions : CreateQueryIndexOptions , fields : String * ): CompletionStage [Done ] =
183186 delegate.createIndex(indexName, createQueryIndexOptions, fields : _* ).asJava
184187
185188 /**
0 commit comments