Class ResourceRegistryResponse<T>
- java.lang.Object
-
- org.gcube.informationsystem.resourceregistry.api.client.ResourceRegistryResponse<T>
-
- Type Parameters:
T- payload type
public final class ResourceRegistryResponse<T> extends Object
Immutable successful Resource Registry response and its HTTP metadata.- Author:
- Luca Frosini (ISTI - CNR)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResourceRegistryResponse.OriginIdentifies whether an operation was served over HTTP or entirely from a client cache.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Tbody()Optional<String>contentLocation()Optional<String>firstHeaderValue(String name)static <T> ResourceRegistryResponse<T>fromCache(T body)static <T> ResourceRegistryResponse<T>fromServer(T body, ResponseMetadata metadata)Map<String,List<String>>headers()List<String>headerValues(String name)booleanisServerResponse()List<String>links()Optional<ResponseMetadata>metadata()ResourceRegistryResponse.Originorigin()Optional<String>preferenceApplied()Set<ResultScope>resultScopes()intstatusCode()List<String>warnings()
-
-
-
Method Detail
-
fromServer
public static <T> ResourceRegistryResponse<T> fromServer(T body, ResponseMetadata metadata)
- Type Parameters:
T- body type- Parameters:
body- response bodymetadata- HTTP metadata- Returns:
- a server-backed response
-
fromCache
public static <T> ResourceRegistryResponse<T> fromCache(T body)
- Type Parameters:
T- body type- Parameters:
body- cached value- Returns:
- a cache-backed response without fabricated HTTP metadata
-
body
public T body()
- Returns:
- the deserialized operation value, or
nullfor bodyless responses
-
origin
public ResourceRegistryResponse.Origin origin()
- Returns:
- whether the value originated from the server or a client cache
-
isServerResponse
public boolean isServerResponse()
- Returns:
truewhen HTTP metadata is available
-
statusCode
public int statusCode()
- Returns:
- HTTP status code @throws IllegalStateException for cache-backed values
-
headers
public Map<String,List<String>> headers()
- Returns:
- immutable response headers, or an empty map for cache-backed values
-
headerValues
public List<String> headerValues(String name)
- Parameters:
name- header name- Returns:
- immutable header values
-
firstHeaderValue
public Optional<String> firstHeaderValue(String name)
- Parameters:
name- header name- Returns:
- first header value, when present
-
metadata
public Optional<ResponseMetadata> metadata()
- Returns:
- HTTP metadata, empty for a cache-backed value
-
contentLocation
public Optional<String> contentLocation()
- Returns:
- the
Content-Locationvalue, when present
-
preferenceApplied
public Optional<String> preferenceApplied()
- Returns:
- the
Preference-Appliedvalue, when present
-
resultScopes
public Set<ResultScope> resultScopes()
- Returns:
- recognized immutable
X-Result-Scopevalues
-
-