Class FluentHelperBasic<FluentHelperT,EntityT,ResultT>

java.lang.Object
com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperBasic<FluentHelperT,EntityT,ResultT>
Type Parameters:
FluentHelperT - The fluent helper type.
EntityT - The type of the entity this OData request operates on, if any.
ResultT - The type of the result entity, if any.
All Implemented Interfaces:
FluentHelperExecutable<Object>
Direct Known Subclasses:
FluentHelperByKey, FluentHelperFunction, FluentHelperModification, FluentHelperRead

public abstract class FluentHelperBasic<FluentHelperT,EntityT,ResultT> extends Object implements FluentHelperExecutable<Object>
Representation of any OData request as a fluent interface for further configuring the request and executing it.
  • Field Details

    • entityCollection

      @Nullable protected String entityCollection
      The entity collection to send the OData requests to
    • csrfTokenRetriever

      @Nonnull protected CsrfTokenRetriever csrfTokenRetriever
      The CSRF token retriever to be used for all explicit and implicit requests that are part of this FluentHelper implementation.
  • Constructor Details

    • FluentHelperBasic

      public FluentHelperBasic(@Nonnull String servicePath, @Nullable String entityCollection)
      Instantiates this fluent helper using the given service path to send the requests.
      Parameters:
      servicePath - The service path to direct the requests to.
      entityCollection - The entity collection to direct the requests to.
  • Method Details

    • getEntityClass

      @Nonnull protected abstract Class<? extends EntityT> getEntityClass()
      Returns a class object of the type this fluent helper works with.
      Returns:
      A class object of the handled type.
    • getThis

      @Nonnull protected FluentHelperT getThis()
      Returns the current fluent helper instance.
      Returns:
      The current fluent helper instance.
    • executeRequest

      @Nullable public abstract ResultT executeRequest(@Nonnull Destination destination)
      Description copied from interface: FluentHelperExecutable
      Executes this request.
      Specified by:
      executeRequest in interface FluentHelperExecutable<FluentHelperT>
      Parameters:
      destination - The target system this request should be issued against.
      Returns:
      A response according to the query criteria.
    • getHeaders

      protected Map<String,String> getHeaders()
      Get all headers for explicit and implicit requests.
      Returns:
      a map containing the headers for actual request and implicit requests, e.g. csrf token request. A map containing the headers to be used for all implicit requests that are part of this FluentHelper implementation (csrf, ...).
    • withHeader

      @Nonnull public FluentHelperT withHeader(@Nonnull String key, @Nullable String value)
      Gives the option to specify custom HTTP headers. The returned object allows to specify the requests the headers should be used in.
      Parameters:
      key - Name of the (first) desired HTTP header parameter.
      value - Value of the (first) desired HTTP header parameter.
      Returns:
      A fluent helper to specify further headers and their intended usage.
    • withHeaders

      @Nonnull public FluentHelperT withHeaders(@Nonnull Map<String,String> map)
      Gives the option to specify a map of custom HTTP headers. The returned object allows to specify the requests the headers should be used in.
      Parameters:
      map - A map of HTTP header key/value pairs.
      Returns:
      A fluent helper to specify further headers and their intended usage.
    • withQueryParameter

      @Nonnull protected FluentHelperT withQueryParameter(@Nonnull String key, @Nullable String value)
      Gives the option to specify custom query parameters for the request. The passed parameter value will be encoded with percentage encoding.

      Note: It is recommended to only use this function for query parameters which are not supported by the VDM by default. Using this function to bypass fluent helper method calls can lead to unsupported response handling. There is no contract on the order or priority of parameters added to the query.

      Example: Use the query option $search to reduce the result set, leaving only entities which match the specified search expression. This feature is supported in protocol OData v4.

       new DefaultBusinessPartnerService().getAllBusinessPartner().withQueryParameter("$search", "Köln OR Cologne")
       

      Parameters:
      key - Name of the query parameter.
      value - Unencoded value of the query parameter.
      Returns:
      The same fluent helper.
    • toRequest

      @Nonnull public abstract ODataRequestGeneric toRequest()
      Translate this OData v2 request into a OData request object extending ODataRequestGeneric.
      Returns:
      A protocol agnostic OData request instance.
    • getServicePath

      @Nonnull protected String getServicePath()
    • getParametersForRequestOnly

      protected Map<String,String> getParametersForRequestOnly()
      A map containing the custom query parameters to be used only for the actual request of this FluentHelper implementation.
    • getCsrfTokenRetriever

      @Nonnull protected CsrfTokenRetriever getCsrfTokenRetriever()
      The CSRF token retriever to be used for all explicit and implicit requests that are part of this FluentHelper implementation.