Class RequestResponseResult<T>

java.lang.Object
org.eclipse.hono.util.RequestResponseResult<T>
Type Parameters:
T - The type of the payload contained in the result.
Direct Known Subclasses:
CredentialsResult, RegistrationResult, TenantResult

public class RequestResponseResult<T> extends Object
A container for the result returned by a Hono API that implements the request response pattern.
  • Constructor Details

    • RequestResponseResult

      public RequestResponseResult(int status, T payload, CacheDirective cacheDirective, Map<String,Object> responseProperties)
      Creates a new result for a status code and payload.
      Parameters:
      status - The code indicating the outcome of processing the request.
      payload - The payload contained in the response message or null, if the response does not contain any payload data.
      cacheDirective - Restrictions regarding the caching of the payload by the receiver of the result or null if no restrictions apply.
      responseProperties - Arbitrary additional properties conveyed in the response message or null, if the response does not contain additional properties.
  • Method Details

    • getStatus

      public final int getStatus()
      Gets the status code indicating the outcome of the request.
      Returns:
      The code.
    • getPayload

      public final T getPayload()
      Gets the payload to convey to the sender of the request.
      Returns:
      The payload.
    • getCacheDirective

      public final CacheDirective getCacheDirective()
      Gets the cache directive specifying how the payload of this response may be cached.
      Returns:
      The directive or null if not set.
    • getResponseProperties

      public final Map<String,Object> getResponseProperties()
      Gets read-only access to the response message's additional properties.
      Returns:
      An unmodifiable view on the (potentially empty) properties.
    • isOk

      public final boolean isOk()
      Checks if this result's status is OK.
      Returns:
      true if status == 200.
    • isNotFound

      public final boolean isNotFound()
      Checks if this result's status is Not Found.
      Returns:
      true if status == 404.
    • isError

      public final boolean isError()
      Checks if this result's status code represents an error.
      Returns:
      true if the result contains an error code.