Class ODataRequestResultGeneric
java.lang.Object
com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultGeneric
- All Implemented Interfaces:
ODataRequestResult
,ODataRequestResultDeserializable
,ODataRequestResultPagination
,Iterable<ResultElement>
public class ODataRequestResultGeneric
extends Object
implements ODataRequestResult, ODataRequestResultDeserializable, ODataRequestResultPagination
OData request result for reading entities.
-
Constructor Summary
ConstructorDescriptionODataRequestResultGeneric
(ODataRequestGeneric oDataRequest, org.apache.http.HttpResponse httpResponse) Default constructor.ODataRequestResultGeneric
(ODataRequestGeneric oDataRequest, org.apache.http.HttpResponse httpResponse, org.apache.http.client.HttpClient httpClient) Default constructor with enabled pagination. -
Method Summary
Modifier and TypeMethodDescription<T> T
Converts ODataRequestResult into POJO.<T> T
as
(Class<T> objectType, Function<com.google.gson.JsonElement, com.google.gson.JsonElement> resultExtractor) Converts ODataRequestResult into a POJO based on a function extracting the relevant JSON response object.<T> List<T>
Converts ODataRequestResult into list of POJOs.Construct and get a list of key-value maps from the OData response.asMap()
Construct and get a key-value map from the OData response.protected boolean
void
Method that allows consumers to disable buffering HTTP response entity.boolean
io.vavr.control.Option<String>
Get the delta link of the current result-set.org.apache.http.HttpResponse
Method that creates aBufferedHttpEntity
from theHttpEntity
if buffering the HTTP response is not turned off by usingdisableBufferingHttpResponse()
.long
Get the count of elements in the result set.io.vavr.control.Option<String>
Get the next page link of result-set.Get the originalODataRequestExecutable
instance that was used for running the OData request.io.vavr.control.Option<String>
Try to extract a version identifier from the ETag header.int
hashCode()
boolean
Check whether or not the HttpResponse contains (potentially empty) payload.iterator()
void
streamElements
(Consumer<ResultElement> handler) Run a consumer for fluent API type ResultElement to iterate over the OData response with a continuous data stream.io.vavr.control.Try<ODataRequestResultGeneric>
Get the next page link of result-set.withNumberDeserializationStrategy
(NumberDeserializationStrategy numberStrategy) Set the default number deserialization strategy for generic JSON numbers without target type mapping.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResult
getAllHeaderValues, getHeaderNames, getHeaderValues
Methods inherited from interface com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultPagination
iteratePages
-
Constructor Details
-
ODataRequestResultGeneric
public ODataRequestResultGeneric(@Nonnull ODataRequestGeneric oDataRequest, @Nonnull org.apache.http.HttpResponse httpResponse) Default constructor.- Parameters:
oDataRequest
- The original OData requesthttpResponse
- The original Http response
-
ODataRequestResultGeneric
public ODataRequestResultGeneric(@Nonnull ODataRequestGeneric oDataRequest, @Nonnull org.apache.http.HttpResponse httpResponse, @Nullable org.apache.http.client.HttpClient httpClient) Default constructor with enabled pagination.- Parameters:
oDataRequest
- The original OData requesthttpResponse
- The original Http responsehttpClient
- The original Http client
-
-
Method Details
-
withNumberDeserializationStrategy
@Nonnull public ODataRequestResultGeneric withNumberDeserializationStrategy(@Nonnull NumberDeserializationStrategy numberStrategy) Set the default number deserialization strategy for generic JSON numbers without target type mapping.- Parameters:
numberStrategy
- The number deserialization strategy to use.- Returns:
- The same instance of
ODataRequestGeneric
.
-
disableBufferingHttpResponse
public void disableBufferingHttpResponse()Method that allows consumers to disable buffering HTTP response entity. Note that once this is disabled, HTTP responses can only be streamed/read once -
getHttpResponse
@Nonnull public org.apache.http.HttpResponse getHttpResponse()Method that creates aBufferedHttpEntity
from theHttpEntity
if buffering the HTTP response is not turned off by usingdisableBufferingHttpResponse()
.- Specified by:
getHttpResponse
in interfaceODataRequestResult
- Returns:
- An HttpResponse
-
streamElements
Description copied from interface:ODataRequestResultDeserializable
Run a consumer for fluent API type ResultElement to iterate over the OData response with a continuous data stream. The HttpEntity will be consumed.- Specified by:
streamElements
in interfaceODataRequestResultDeserializable
- Parameters:
handler
- The consumer for generic ResultElement.
-
getVersionIdentifierFromHeader
Try to extract a version identifier from the ETag header.- Returns:
- An option holding the version identifier or
Option.None
, if none was found.
-
iterator
- Specified by:
iterator
in interfaceIterable<ResultElement>
-
as
Description copied from interface:ODataRequestResultDeserializable
Converts ODataRequestResult into POJO.- Specified by:
as
in interfaceODataRequestResultDeserializable
- Type Parameters:
T
- The generic type of POJO- Parameters:
objectType
- type of POJO- Returns:
- T - POJO
-
as
@Nonnull public <T> T as(@Nonnull Class<T> objectType, @Nonnull Function<com.google.gson.JsonElement, com.google.gson.JsonElement> resultExtractor) Converts ODataRequestResult into a POJO based on a function extracting the relevant JSON response object.- Type Parameters:
T
- The generic type of POJO- Parameters:
objectType
- type of POJOresultExtractor
- A function extracting the relevant result object of the JSON root object. In case of OData V2 the"d"
object is treated as the root object. PassFunction.identity()
in case no transformation should take place.- Returns:
- T - POJO
- Throws:
ODataResponseException
- When the HTTP status indicates an erroneous response.ODataDeserializationException
- When deserialization process failed for the OData response object.
-
asList
Description copied from interface:ODataRequestResultDeserializable
Converts ODataRequestResult into list of POJOs.- Specified by:
asList
in interfaceODataRequestResultDeserializable
- Type Parameters:
T
- Generic type of the POJO- Parameters:
objectType
- type of POJO- Returns:
- List
- list of POJOs
-
getInlineCount
public long getInlineCount()Description copied from interface:ODataRequestResultDeserializable
Get the count of elements in the result set.- Specified by:
getInlineCount
in interfaceODataRequestResultDeserializable
- Returns:
- The number of elements.
-
getNextLink
Description copied from interface:ODataRequestResultPagination
Get the next page link of result-set.- Specified by:
getNextLink
in interfaceODataRequestResultPagination
- Returns:
- the OData protocol specific value of next link property. Or
null
if last page of result-set.
-
getDeltaLink
Get the delta link of the current result-set.- Returns:
- the OData protocol specific value of delta link property.
-
asMap
Description copied from interface:ODataRequestResultDeserializable
Construct and get a key-value map from the OData response. The HttpEntity will be consumed.- Specified by:
asMap
in interfaceODataRequestResultDeserializable
- Returns:
- The key-value map.
-
asListOfMaps
Description copied from interface:ODataRequestResultDeserializable
Construct and get a list of key-value maps from the OData response. The HttpEntity will be consumed.- Specified by:
asListOfMaps
in interfaceODataRequestResultDeserializable
- Returns:
- The list of key-value maps.
-
tryGetNextPage
Description copied from interface:ODataRequestResultPagination
Get the next page link of result-set.- Specified by:
tryGetNextPage
in interfaceODataRequestResultPagination
- Returns:
- the OData protocol specific value of next link property. Or
null
if last page of result-set.
-
hasPayload
public boolean hasPayload()Check whether or not the HttpResponse contains (potentially empty) payload.- Returns:
- True, if the HTTP response contains an
HttpEntity
.
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getODataRequest
Description copied from interface:ODataRequestResult
Get the originalODataRequestExecutable
instance that was used for running the OData request.- Specified by:
getODataRequest
in interfaceODataRequestResult
- Specified by:
getODataRequest
in interfaceODataRequestResultPagination
- Returns:
- The original
ODataRequestExecutable
instance.
-