Class FluentHelperFunction<FluentHelperT,ObjectT,ResultT>
java.lang.Object
com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperBasic<FluentHelperT,ObjectT,ResultT>
com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperFunction<FluentHelperT,ObjectT,ResultT>
- Type Parameters:
FluentHelperT
- The fluent helper type.ObjectT
- The type of the object this OData request operates on, if any.ResultT
- The type of the result entity, if any.
- All Implemented Interfaces:
FluentHelperExecutable<Object>
- Direct Known Subclasses:
CollectionValuedFluentHelperFunction
,SingleValuedFluentHelperFunction
public abstract class FluentHelperFunction<FluentHelperT,ObjectT,ResultT>
extends FluentHelperBasic<FluentHelperT,ObjectT,ResultT>
Representation of any OData function import as a fluent interface for further configuring the request and
executing
it.-
Field Summary
Fields inherited from class com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperBasic
csrfTokenRetriever, entityCollection
-
Constructor Summary
ConstructorDescriptionFluentHelperFunction
(String servicePath) Instantiates this fluent helper using the given service path to send the requests. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract org.apache.http.client.methods.HttpUriRequest
createRequest
(URI uri) Creates a request for this function based on the givenURI
.executeMultiple
(Destination destination) Default implementation for the case that this function returns a collection of entries.protected ObjectT
executeSingle
(Destination destination) Default implementation for the case that this function returns a single type.protected CsrfTokenRetriever
The CSRF token retriever to be used for all explicit and implicit requests that are part of this FluentHelper implementation.protected abstract String
The exact name of the function to be called on the OData Endpoint.Getter for the map of parameters to be used in the function call.protected com.google.gson.JsonElement
refineJsonResponse
(com.google.gson.JsonElement jsonElement) Transform the JSON element from the response to extract a result entity.Translate this OData v2 request into a OData request object extendingODataRequestGeneric
.Activates the CSRF token retrieval for this OData request.Deactivates the CSRF token retrieval for this OData request.Methods inherited from class com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperBasic
executeRequest, getEntityClass, getHeaders, getParametersForRequestOnly, getServicePath, getThis, withHeader, withHeaders, withQueryParameter
-
Constructor Details
-
FluentHelperFunction
Instantiates this fluent helper using the given service path to send the requests.- Parameters:
servicePath
- The service path to direct the requests to.
-
-
Method Details
-
getCsrfTokenRetriever
Description copied from class:FluentHelperBasic
The CSRF token retriever to be used for all explicit and implicit requests that are part of this FluentHelper implementation.- Overrides:
getCsrfTokenRetriever
in classFluentHelperBasic<FluentHelperT,
ObjectT, ResultT>
-
getParameters
Getter for the map of parameters to be used in the function call.The map maps the ODataName of a parameter to the corresponding unserialized value.
Only literal values are allowed as value. No complex or entity objects.
- Returns:
- A map containing the parameter for the function call.
-
getFunctionName
The exact name of the function to be called on the OData Endpoint.- Returns:
- The function name on the endpoint.
-
createRequest
@Nonnull protected abstract org.apache.http.client.methods.HttpUriRequest createRequest(@Nonnull URI uri) Creates a request for this function based on the givenURI
.Examples for such requests are
HttpGet
andHttpPost
.- Parameters:
uri
- TheURI
the request should target.- Returns:
- The instantiated request.
-
toRequest
Translate this OData v2 request into a OData request object extendingODataRequestGeneric
.The function import arguments are encoded as HTTP query expressions.
- Specified by:
toRequest
in classFluentHelperBasic<FluentHelperT,
ObjectT, ResultT> - Returns:
- A protocol agnostic OData request instance.
-
executeSingle
Default implementation for the case that this function returns a single type.This method can be used in subclasses to implement the
FluentHelperBasic.executeRequest(Destination)
method.- Parameters:
destination
- The destination to run the function against.- Returns:
- The single object returned by the function call. Returns
null
if the function did not return a result. - Throws:
ODataException
- If the execution of the function failed.
-
executeMultiple
@Nonnull protected List<ObjectT> executeMultiple(@Nonnull Destination destination) throws ODataException Default implementation for the case that this function returns a collection of entries.This method can be used in subclasses to implement the
FluentHelperBasic.executeRequest(Destination)
method.- Parameters:
destination
- The destination to run the function against.- Returns:
- A list of the objects returned by the function call. Returns an empty list if the function did not return a result.
- Throws:
ODataException
- If the execution of the function failed.
-
refineJsonResponse
@Nullable protected com.google.gson.JsonElement refineJsonResponse(@Nullable com.google.gson.JsonElement jsonElement) Transform the JSON element from the response to extract a result entity. By default this method returns the original object.- Parameters:
jsonElement
- The optional response JSON element- Returns:
- The refined JSON element
-
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
-
withoutCsrfToken
Deactivates the CSRF token retrieval for this OData request. This is useful if the server does not support or require CSRF tokens as part of the request.- Returns:
- The same builder
-