T - placeholder for the response type, used to avoid casting of responses. This is not
linked to the Type set on a request so a ClassCastException is possible if the type is set
incorrectly.public class ServiceReadRequestBuilder<T> extends Object
ServiceReadRequest instances. Static methods provide GET and OPTIONS requests configured
with the minimum fields needed to execute a request, and chaining methods are available to set additional attributes
on the request before an immutable instance is build with build().| Modifier and Type | Method and Description |
|---|---|
ServiceReadRequest<T> |
build()
Builds an immutable request instance from values provided to this builder.
|
protected Method |
getMethod() |
protected Map<String,String> |
getParams() |
protected String |
getPath() |
protected Type |
getResponseType() |
protected String |
getRuid() |
protected ServiceName |
getService() |
protected ServiceReadRequestBuilder<T> |
getThis() |
static <T> ServiceReadRequestBuilder<T> |
newGetRequest(ServiceName service,
String path,
Class<T> responseType)
Creates a new GET request builder configured with the URL to call and expected response type.
|
static <T> ServiceReadRequestBuilder<T> |
newGetRequest(ServiceName service,
String path,
Type responseType)
Creates a new GET request builder configured with the URL to call and expected response type.
|
static <T> ServiceReadRequestBuilder<T> |
newOptionsRequest(ServiceName service,
String path,
Class<T> responseType)
Creates a new OPTIONS request builder configured with the URL to call and expected response type.
|
static <T> ServiceReadRequestBuilder<T> |
newOptionsRequest(ServiceName service,
String path,
Type responseType)
Creates a new OPTIONS request builder configured with the URL to call and expected response type.
|
B |
withAddedParam(String name,
String value)
Add an additional unencoded querystring parameter to be added to the request, preserving the existing set but
overwriting any param with the same name.
|
B |
withAddedParams(Map<String,String> params)
Add additional unencoded querystring parameters to be added to the request, preserving the existing set but
overwriting any param with the same names.
|
B |
withParams(Map<String,String> params)
Add querystring parameters to the request, replacing any previously set.
|
B |
withPath(String path)
Set the path of the Brightpearl resource within the service provided to
withService(ServiceName). |
B |
withResponseType(Type responseType)
Set the generic type token representing the expected type of the response element in the JSON response body.
|
B |
withRuid(String ruid)
Set a unique identifier for the request.
|
B |
withService(ServiceName service)
Returns the name of the Brightpearl service that contains the resource to be called.
|
protected ServiceReadRequestBuilder<T> getThis()
public static <T> ServiceReadRequestBuilder<T> newGetRequest(ServiceName service, String path, Class<T> responseType)
T - placeholder for the response type, used to avoid casting of responses.service - Brightpearl service that contains the resource.path - path to the search resource, for example '/product'.responseType - type of result expected in the 'response' element of the JSON response body. Use Void or null if no response is expected, or the response is not required.public static <T> ServiceReadRequestBuilder<T> newGetRequest(ServiceName service, String path, Type responseType)
T - placeholder for the response type, used to avoid casting of responses.service - Brightpearl service that contains the resource.path - path to the search resource, for example '/product'.responseType - type of result expected in the 'response' element of the JSON response body. Use Void or null if no response is expected, or the response is not required.public static <T> ServiceReadRequestBuilder<T> newOptionsRequest(ServiceName service, String path, Class<T> responseType)
T - placeholder for the response type, used to avoid casting of responses.service - Brightpearl service that contains the resource.path - path to the search resource, for example '/product'.responseType - type of result expected in the 'response' element of the JSON response body. Use Void or null if no response is expected, or the response is not required.public static <T> ServiceReadRequestBuilder<T> newOptionsRequest(ServiceName service, String path, Type responseType)
T - placeholder for the response type, used to avoid casting of responses.service - Brightpearl service that contains the resource.path - path to the search resource, for example '/product'.responseType - type of result expected in the 'response' element of the JSON response body. Use Void or null if no response is expected, or the response is not required.public ServiceReadRequest<T> build()
public B withRuid(String ruid)
Note this RUID is applied only to the first request built by this builder; if you call build() more than
once, the second and subsequent requests will have randomly generated IDs unless you also call this method
between each invocation.
ruid - the custom unique identifier to use.public B withService(ServiceName service)
service - service containing the target resource.public B withPath(String path)
withService(ServiceName). For example, for
the product GET API, this would be '/product'.path - the path to be set.public B withResponseType(Type responseType)
Type is used instead of Class to provide support for deserialising
generic types e.g. collections and maps, however this does mean the type is not guaranteed to match the type token
T, which is used to avoid casting responses.responseType - the type to set.public B withAddedParam(String name, String value)
name - parameter name.value - parameter value.public B withAddedParams(Map<String,String> params)
params - map of querystring params.public B withParams(Map<String,String> params)
params - map of querystring params.protected String getRuid()
protected ServiceName getService()
protected Method getMethod()
protected String getPath()
protected Type getResponseType()
Copyright © 2014. All Rights Reserved.