Class ODataRequestResultGeneric
java.lang.Object
com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultGeneric
- All Implemented Interfaces:
ODataRequestResult,ODataRequestResultDeserializable,ODataRequestResultPagination,Iterable<ResultElement>
- Direct Known Subclasses:
ODataRequestResultResource
public class ODataRequestResultGeneric
extends Object
implements ODataRequestResult, ODataRequestResultDeserializable, ODataRequestResultPagination
OData request result for reading entities.
-
Constructor Summary
ConstructorsConstructorDescriptionODataRequestResultGeneric(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> TConverts ODataRequestResult into POJO.<T> Tas(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 booleanvoidDeprecated.booleanio.vavr.control.Option<String>Get the delta link of the current result-set.org.apache.http.HttpResponseGet the original ODataHttpResponseinstance, which holds the HttpEntity and header information.longGet the count of elements in the result set.io.vavr.control.Option<String>Get the next page link of result-set.Get the originalODataRequestExecutableinstance that was used for running the OData request.org.apache.http.StatusLineGet the HTTP response object status line.io.vavr.control.Option<String>Try to extract a version identifier from the ETag header.inthashCode()booleanCheck whether or not the HttpResponse contains (potentially empty) payload.iterator()voidstreamElements(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, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResult
getAllHeaderValues, getHeaderNames, getHeaderValuesMethods 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
-
getStatusLine
@Nullable public org.apache.http.StatusLine getStatusLine()Description copied from interface:ODataRequestResultGet the HTTP response object status line.- Specified by:
getStatusLinein interfaceODataRequestResult- Returns:
- the StatusLine.
-
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
Deprecated.Please useODataRequestRead.withoutResponseBuffering()orODataRequestReadByKey.withoutResponseBuffering()instead.Method that allows consumers to disable buffering HTTP response entity. Note that once this is disabled, HTTP responses can only be streamed/read once -
streamElements
Description copied from interface:ODataRequestResultDeserializableRun 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:
streamElementsin 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:
iteratorin interfaceIterable<ResultElement>
-
as
Description copied from interface:ODataRequestResultDeserializableConverts ODataRequestResult into POJO.- Specified by:
asin 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:ODataRequestResultDeserializableConverts ODataRequestResult into list of POJOs.- Specified by:
asListin 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:ODataRequestResultDeserializableGet the count of elements in the result set.- Specified by:
getInlineCountin interfaceODataRequestResultDeserializable- Returns:
- The number of elements.
-
getNextLink
Description copied from interface:ODataRequestResultPaginationGet the next page link of result-set.- Specified by:
getNextLinkin interfaceODataRequestResultPagination- Returns:
- the OData protocol specific value of next link property. Or
nullif 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:ODataRequestResultDeserializableConstruct and get a key-value map from the OData response. The HttpEntity will be consumed.- Specified by:
asMapin interfaceODataRequestResultDeserializable- Returns:
- The key-value map.
-
asListOfMaps
Description copied from interface:ODataRequestResultDeserializableConstruct and get a list of key-value maps from the OData response. The HttpEntity will be consumed.- Specified by:
asListOfMapsin interfaceODataRequestResultDeserializable- Returns:
- The list of key-value maps.
-
tryGetNextPage
Description copied from interface:ODataRequestResultPaginationGet the next page link of result-set.- Specified by:
tryGetNextPagein interfaceODataRequestResultPagination- Returns:
- the OData protocol specific value of next link property. Or
nullif 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:ODataRequestResultGet the originalODataRequestExecutableinstance that was used for running the OData request.- Specified by:
getODataRequestin interfaceODataRequestResult- Specified by:
getODataRequestin interfaceODataRequestResultPagination- Returns:
- The original
ODataRequestExecutableinstance.
-
getHttpResponse
@Nonnull public org.apache.http.HttpResponse getHttpResponse()Description copied from interface:ODataRequestResultGet the original ODataHttpResponseinstance, which holds the HttpEntity and header information.- Specified by:
getHttpResponsein interfaceODataRequestResult- Returns:
- The HttpResponse.
-
ODataRequestRead.withoutResponseBuffering()orODataRequestReadByKey.withoutResponseBuffering()instead.