Class FluentHelperByKey<FluentHelperT,EntityT extends VdmEntity<?>,SelectableT>

java.lang.Object
com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperBasic<FluentHelperT,EntityT,EntityT>
com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperByKey<FluentHelperT,EntityT,SelectableT>
Type Parameters:
FluentHelperT - The fluent helper type.
EntityT - The type of the result entity.
SelectableT - The type of the class that represents fields of the entity.
All Implemented Interfaces:
FluentHelperExecutable<Object>

public abstract class FluentHelperByKey<FluentHelperT,EntityT extends VdmEntity<?>,SelectableT> extends FluentHelperBasic<FluentHelperT,EntityT,EntityT>
Representation of an OData request to retrieve an entity by its key as a fluent interface for further configuring the request and executing it.
  • Constructor Details

    • FluentHelperByKey

      public FluentHelperByKey(@Nonnull String servicePath, @Nonnull String entityCollection)
      Instantiates this fluent helper using the given service path and entity collection 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

    • getKey

      @Nonnull protected abstract Map<String,Object> getKey()
      Getter for a map containing the OData name of key properties, each mapped to the value to search by.
      Returns:
      A name-value mapping for the OData key properties.
    • toRequest

      @Nonnull public ODataRequestReadByKey toRequest()
      Description copied from class: FluentHelperBasic
      Translate this OData v2 request into a OData request object extending ODataRequestGeneric.
      Specified by:
      toRequest in class FluentHelperBasic<FluentHelperT,EntityT extends VdmEntity<?>,EntityT extends VdmEntity<?>>
      Returns:
      A protocol agnostic OData request instance.
    • withQueryParameter

      @Nonnull public FluentHelperT withQueryParameter(@Nonnull String key, @Nullable String value)
      Description copied from class: FluentHelperBasic
      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")
       

      Overrides:
      withQueryParameter in class FluentHelperBasic<FluentHelperT,EntityT extends VdmEntity<?>,EntityT extends VdmEntity<?>>
      Parameters:
      key - Name of the query parameter.
      value - Unencoded value of the query parameter.
      Returns:
      The same fluent helper.
    • select

      @Nonnull public FluentHelperT select(@Nonnull SelectableT... fields)
      Query modifier to limit which field values of the entity get fetched & populated. If this method is never called, then all fields will be fetched & populated. But if this method is called at least once, then only the specified fields will be fetched & populated. Calling this multiple times will combine the set(s) of fields of each call.
      Parameters:
      fields - Array of fields to select.
      Returns:
      The same fluent helper with the provided fields selected.
    • executeRequest

      @Nonnull public EntityT executeRequest(@Nonnull Destination destination)
      Description copied from interface: FluentHelperExecutable
      Executes this request.
      Specified by:
      executeRequest in interface FluentHelperExecutable<FluentHelperT>
      Specified by:
      executeRequest in class FluentHelperBasic<FluentHelperT,EntityT extends VdmEntity<?>,EntityT extends VdmEntity<?>>
      Parameters:
      destination - The target system this request should be issued against.
      Returns:
      A response according to the query criteria.
    • withCsrfToken

      @Nonnull public FluentHelperT withCsrfToken()
      Activates the CSRF token retrieval for this OData request. This is useful if the server does require CSRF tokens as part of the request.
      Returns:
      The same builder