Skip to content

Commit d183231

Browse files
ehennumehennum
ehennum
authored andcommitted
#1294 generics for streaming handles
1 parent ad28a7e commit d183231

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/impl/OkHttpServices.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6241,8 +6241,8 @@ public <C,R> Stream<C> asStreamOfContent(
62416241
}
62426242
}
62436243
@Override
6244-
public <C,R> Stream<BufferableContentHandle<C,R>> asStreamOfHandles(
6245-
BytesHandle endpointStateHandle, BufferableContentHandle<C,R> outputHandle
6244+
public <T extends BufferableContentHandle<?,?>> Stream<T> asStreamOfHandles(
6245+
BytesHandle endpointStateHandle, T outputHandle
62466246
) {
62476247
try {
62486248
if (multipart == null) {
@@ -6251,15 +6251,15 @@ public <C,R> Stream<BufferableContentHandle<C,R>> asStreamOfHandles(
62516251

62526252
boolean hasEndpointState = (endpointStateHandle != null);
62536253

6254-
Stream.Builder<BufferableContentHandle<C,R>> builder = Stream.builder();
6254+
Stream.Builder<T> builder = Stream.builder();
62556255

62566256
int partCount = multipart.getCount();
62576257
for (int i=0; i < partCount; i++) {
62586258
BodyPart bodyPart = multipart.getBodyPart(i);
62596259
if (hasEndpointState && i == 0) {
62606260
updateHandle(bodyPart, endpointStateHandle);
62616261
} else {
6262-
builder.accept(updateHandle(bodyPart, outputHandle.newHandle()));
6262+
builder.accept(updateHandle(bodyPart, (T) outputHandle.newHandle()));
62636263
}
62646264
}
62656265
return builder.build();

marklogic-client-api/src/main/java/com/marklogic/client/impl/RESTServices.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,15 +608,17 @@ interface SingleCallResponse extends CallResponse {
608608
interface MultipleCallResponse extends CallResponse {
609609
Stream<byte[]> asStreamOfBytes();
610610
<C,R> Stream<C> asStreamOfContent(BytesHandle endpointStateHandle, BufferableContentHandle<C,R> outputHandle);
611-
<C,R> Stream<BufferableContentHandle<C,R>> asStreamOfHandles(BytesHandle endpointStateHandle, BufferableContentHandle<C,R> outputHandle);
611+
<T extends BufferableContentHandle<?,?>> Stream<T>
612+
asStreamOfHandles(BytesHandle endpointStateHandle, T outputHandle);
612613
Stream<InputStream> asStreamOfInputStream();
613614
Stream<InputStreamHandle> asStreamOfInputStreamHandle();
614615
Stream<Reader> asStreamOfReader();
615616
Stream<ReaderHandle> asStreamOfReaderHandle();
616617
Stream<String> asStreamOfString();
617618
byte[][] asArrayOfBytes();
618619
<C,R> C[] asArrayOfContent(BytesHandle endpointStateHandle, BufferableContentHandle<C,R> outputHandle);
619-
<C,R> BufferableContentHandle<C,R>[] asArrayOfHandles(BytesHandle endpointStateHandle, BufferableContentHandle<C,R> outputHandle);
620+
<C,R> BufferableContentHandle<C,R>[]
621+
asArrayOfHandles(BytesHandle endpointStateHandle, BufferableContentHandle<C,R> outputHandle);
620622
InputStream[] asArrayOfInputStream();
621623
InputStreamHandle[] asArrayOfInputStreamHandle();
622624
Reader[] asArrayOfReader();

ml-development-tools/src/test/java/com/marklogic/client/test/dbfunction/positive/AnyDocumentBundle.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ public Stream<com.marklogic.client.io.InputStreamHandle> sendReceiveDocs(Stream<
6565
);
6666
}
6767
private Stream<com.marklogic.client.io.InputStreamHandle> sendReceiveDocs(BaseProxy.DBFunctionRequest request, Stream<String> uris, Stream<com.marklogic.client.io.InputStreamHandle> docs) {
68-
/* TODO: revise to take sample handle for output and call asStreamOfHandles(endpointStateHandle, outputHandle)
69-
return BaseProxy.AnyDocumentType.toInputStreamHandle(
70-
request
71-
.withParams(
72-
BaseProxy.atomicParam("uris", true, BaseProxy.StringType.fromString(uris)),
73-
BaseProxy.documentParam("docs", true, docs)
74-
).responseMultiple(true, Format.UNKNOWN)
75-
);
76-
68+
/* TODO:
69+
generate code that
70+
instead of wrapping with BaseProxy.AnyDocumentType.toInputStreamHandle()
71+
calls .asStreamOfHandles()
7772
*/
78-
return null;
73+
return request
74+
.withParams(
75+
BaseProxy.atomicParam("uris", true, BaseProxy.StringType.fromString(uris)),
76+
BaseProxy.documentParam("docs", true, docs)
77+
).responseMultiple(true, Format.UNKNOWN)
78+
.asStreamOfHandles(null, new com.marklogic.client.io.InputStreamHandle());
7979
}
8080
}
8181

0 commit comments

Comments
 (0)