forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for autocomplete functionality (Azure#73)
* implementation of the needed methods * adding UTs
- Loading branch information
Showing
19 changed files
with
1,151 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ure-search-data/src/main/java/com/azure/search/data/common/AutoCompletePagedResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.search.data.common; | ||
|
||
import com.azure.core.http.HttpHeaders; | ||
import com.azure.core.http.rest.SimpleResponse; | ||
import com.azure.core.implementation.http.PagedResponseBase; | ||
import com.azure.search.data.generated.models.AutocompleteItem; | ||
import com.azure.search.data.generated.models.AutocompleteResult; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
public class AutoCompletePagedResponse extends PagedResponseBase<String, AutocompleteItem> { | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param autoCompleteResponse an http response with the results | ||
*/ | ||
public AutoCompletePagedResponse(SimpleResponse<AutocompleteResult> autoCompleteResponse) { | ||
super(autoCompleteResponse.request(), | ||
autoCompleteResponse.statusCode(), | ||
autoCompleteResponse.headers(), | ||
autoCompleteResponse.value().results(), | ||
null, | ||
deserializeHeaders(autoCompleteResponse.headers())); | ||
} | ||
|
||
private static String deserializeHeaders(HttpHeaders headers) { | ||
return headers.toMap().entrySet().stream().map((entry) -> | ||
entry.getKey() + "," + entry.getValue() | ||
).collect(Collectors.joining(",")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.