
io.sphere.client.FetchRequest Maven / Gradle / Ivy
package io.sphere.client;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
/** Request that fetches a single object.
* Use {@link #fetch} or {@link #fetchAsync} to execute the request. */
public interface FetchRequest {
/** Executes the request and returns the result, or {@code absent} if the object was not found. */
Optional fetch();
/** Executes the request asynchronously and returns a future
* providing the result, or {@code absent} if not found. */
ListenableFuture> fetchAsync();
/** Requests {@linkplain io.sphere.client.model.Reference Reference fields} to be expanded in the returned objects.
* Expanded references contain full target objects they link to.
*
* As an illustration, here is how reference expansion looks at the underlying JSON transport level.
* Given a customer object:
*
{@code
*{
* "name": "John Doe"
* "customerGroup": {
* "typeId": "customer-group",
* "id": "7ba61480-6a72-4a2a-a72e-cd39f75a7ef2"
* }
*}}
*
* This is what the result looks like when the path 'customerGroup' has been expanded:
*
*{@code
*{
* "name": "John Doe"
* "customerGroup": {
* typeId: "customer-group",
* id: "7ba61480-6a72-4a2a-a72e-cd39f75a7ef2"
* obj: {
* "name": "Gold"
* }
* }
*}}
*
* @param paths The paths to be expanded, such as 'customerGroup' */
FetchRequest expand(String... paths);
}