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 Details

    • ODataRequestResultGeneric

      public ODataRequestResultGeneric(@Nonnull ODataRequestGeneric oDataRequest, @Nonnull org.apache.http.HttpResponse httpResponse)
      Default constructor.
      Parameters:
      oDataRequest - The original OData request
      httpResponse - 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 request
      httpResponse - The original Http response
      httpClient - 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 a BufferedHttpEntity from the HttpEntity if buffering the HTTP response is not turned off by using disableBufferingHttpResponse().
      Specified by:
      getHttpResponse in interface ODataRequestResult
      Returns:
      An HttpResponse
    • streamElements

      public void streamElements(@Nonnull Consumer<ResultElement> handler)
      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 interface ODataRequestResultDeserializable
      Parameters:
      handler - The consumer for generic ResultElement.
    • getVersionIdentifierFromHeader

      @Nonnull public io.vavr.control.Option<String> 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

      @Nonnull public Iterator<ResultElement> iterator()
      Specified by:
      iterator in interface Iterable<ResultElement>
    • as

      @Nonnull public <T> T as(@Nonnull Class<T> objectType)
      Description copied from interface: ODataRequestResultDeserializable
      Converts ODataRequestResult into POJO.
      Specified by:
      as in interface ODataRequestResultDeserializable
      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 POJO
      resultExtractor - 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. Pass Function.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

      @Nonnull public <T> List<T> asList(@Nonnull Class<T> objectType)
      Description copied from interface: ODataRequestResultDeserializable
      Converts ODataRequestResult into list of POJOs.
      Specified by:
      asList in interface ODataRequestResultDeserializable
      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 interface ODataRequestResultDeserializable
      Returns:
      The number of elements.
    • getNextLink

      @Nonnull public io.vavr.control.Option<String> getNextLink()
      Description copied from interface: ODataRequestResultPagination
      Get the next page link of result-set.
      Specified by:
      getNextLink in interface ODataRequestResultPagination
      Returns:
      the OData protocol specific value of next link property. Or null if last page of result-set.
    • getDeltaLink

      @Nonnull public io.vavr.control.Option<String> getDeltaLink()
      Get the delta link of the current result-set.
      Returns:
      the OData protocol specific value of delta link property.
    • asMap

      @Nonnull public Map<String,Object> 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 interface ODataRequestResultDeserializable
      Returns:
      The key-value map.
    • asListOfMaps

      @Nonnull public List<Map<String,Object>> 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 interface ODataRequestResultDeserializable
      Returns:
      The list of key-value maps.
    • tryGetNextPage

      @Nonnull public io.vavr.control.Try<ODataRequestResultGeneric> tryGetNextPage()
      Description copied from interface: ODataRequestResultPagination
      Get the next page link of result-set.
      Specified by:
      tryGetNextPage in interface ODataRequestResultPagination
      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

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(@Nullable Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getODataRequest

      @Nonnull public ODataRequestGeneric getODataRequest()
      Description copied from interface: ODataRequestResult
      Get the original ODataRequestExecutable instance that was used for running the OData request.
      Specified by:
      getODataRequest in interface ODataRequestResult
      Specified by:
      getODataRequest in interface ODataRequestResultPagination
      Returns:
      The original ODataRequestExecutable instance.