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)
  • Method Details

    • fromServer

      public static <T> ResourceRegistryResponse<T> fromServer(T body, ResponseMetadata metadata)
      Type Parameters:
      T - body type
      Parameters:
      body - response body
      metadata - 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 null for bodyless responses
    • origin

      Returns:
      whether the value originated from the server or a client cache
    • isServerResponse

      public boolean isServerResponse()
      Returns:
      true when 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
    • links

      public List<String> links()
      Returns:
      all Link response header values
    • contentLocation

      public Optional<String> contentLocation()
      Returns:
      the Content-Location value, when present
    • preferenceApplied

      public Optional<String> preferenceApplied()
      Returns:
      the Preference-Applied value, when present
    • warnings

      public List<String> warnings()
      Returns:
      all X-Warning values
    • resultScopes

      public Set<ResultScope> resultScopes()
      Returns:
      recognized immutable X-Result-Scope values