FluentHelperT
- The fluent helper type.ResultT
- The type of the result entity, if any.@Beta public abstract class FunctionRequestBuilder<FluentHelperT,ResultT> extends Object
executing
it.Constructor and Description |
---|
FunctionRequestBuilder(String servicePath,
String functionName)
Instantiates this fluent helper using the given service path to send the requests.
|
FunctionRequestBuilder(String servicePath,
String functionName,
Map<String,Object> parameters)
Instantiates this fluent helper using the given service path to send the requests.
|
Modifier and Type | Method and Description |
---|---|
protected <PrimitiveT> |
addFunctionParameter(String parameterName,
PrimitiveT value)
Adds a property to the OData function parameters representation.
|
abstract ResultT |
execute(HttpDestinationProperties destination)
Execute the OData request.
|
protected String |
getFunctionName() |
protected Map<String,String> |
getHeaders()
A map containing the headers to be used only for the actual request of this FluentHelper implementation.
|
protected List<ODataRequestListener> |
getListeners() |
protected Map<String,String> |
getParametersForRequestOnly()
A map containing the custom query parameters to be used only for the actual request of this FluentHelper
implementation.
|
protected String |
getServicePath() |
protected FluentHelperT |
getThis()
Get the reference to this instance.
|
ODataRequestFunction |
toRequest()
Creates an instance of
ODataRequestFunction based on the Entity class. |
io.vavr.control.Try<ResultT> |
tryExecute(HttpDestinationProperties destination)
Safely execute the OData request.
|
FluentHelperT |
withHeader(String key,
String value)
Gives the option to specify custom HTTP headers.
|
FluentHelperT |
withHeaders(Map<String,String> map)
Gives the option to specify a map of custom HTTP headers.
|
FluentHelperT |
withListener(ODataRequestListener listener)
An error handling class that implements the error result handler interface can be attached to this fluent helper.
|
FluentHelperT |
withQueryParameter(String key,
String value)
Gives the option to specify custom query parameters for the request.
|
public FunctionRequestBuilder(@Nonnull String servicePath, @Nonnull String functionName)
servicePath
- The service path to direct the requests to.functionName
- The name of the unbound functionpublic FunctionRequestBuilder(@Nonnull String servicePath, @Nonnull String functionName, @Nonnull Map<String,Object> parameters)
servicePath
- The service path to direct the requests to.functionName
- The name of the unbound function.parameters
- The parameters passed to the function.protected <PrimitiveT> void addFunctionParameter(@Nonnull String parameterName, @Nonnull PrimitiveT value)
PrimitiveT
- The Java type of the value.parameterName
- The name of the function parameter.value
- The value being passed as the function parameter@Nonnull public ODataRequestFunction toRequest()
ODataRequestFunction
based on the Entity class.
The following settings are used:
ODataRequestFunction
.protected String getFunctionName()
@Nonnull protected FluentHelperT getThis()
@Nonnull public abstract ResultT execute(@Nonnull HttpDestinationProperties destination)
destination
- The destination to be used as request target.DestinationAccessException
- If there is an issue accessing the Destination
.HttpClientInstantiationException
- If there is an issue creating the HttpClient
.ODataException
- If the OData request execution failed. Please find the documentation for ODataException
possible sub-types and error scenarios they can occur in.@Nonnull public io.vavr.control.Try<ResultT> tryExecute(@Nonnull HttpDestinationProperties destination)
destination
- The destination to be used as request target.Try
block.@Nonnull @Beta public FluentHelperT withListener(@Nonnull ODataRequestListener listener)
execute
method. If this method
is not called, then an instance of ODataRequestListener is used. Only one handler can be attached at a time per
fluent helper object, so calling this multiple times will replace the handler.listener
- Instance of an error handler class that implements the error result handler interface.@Nonnull @Beta public FluentHelperT withHeader(@Nonnull String key, @Nullable String value)
key
- Name of the (first) desired HTTP header parameter.value
- Value of the (first) desired HTTP header parameter.@Nonnull @Beta public FluentHelperT withHeaders(@Nonnull Map<String,String> map)
map
- A map of HTTP header key/value pairs.@Nonnull @Beta public FluentHelperT withQueryParameter(@Nonnull String key, @Nullable String value)
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 request.
Example: Use the request 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")
key
- Name of the query parameter.value
- Value of the query parameter.@Nonnull protected Map<String,String> getHeaders()
@Nonnull protected Map<String,String> getParametersForRequestOnly()
@Nonnull protected List<ODataRequestListener> getListeners()
Copyright © 2020 SAP SE. All rights reserved.