Package org.eclipse.hono.util
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
A container for the result returned by a Hono API that implements the request response pattern.
-
Constructor Summary
ConstructorDescriptionRequestResponseResult
(int status, T payload, CacheDirective cacheDirective, Map<String, Object> responseProperties) Creates a new result for a status code and payload. -
Method Summary
Modifier and TypeMethodDescriptionfinal CacheDirective
Gets the cache directive specifying how the payload of this response may be cached.final T
Gets the payload to convey to the sender of the request.Gets read-only access to the response message's additional properties.final int
Gets the status code indicating the outcome of the request.final boolean
isError()
Checks if this result's status code represents an error.final boolean
Checks if this result's status is Not Found.final boolean
isOk()
Checks if this result's status is OK.
-
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 ornull
, if the response does not contain any payload data.cacheDirective
- Restrictions regarding the caching of the payload by the receiver of the result ornull
if no restrictions apply.responseProperties
- Arbitrary additional properties conveyed in the response message ornull
, 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
Gets the payload to convey to the sender of the request.- Returns:
- The payload.
-
getCacheDirective
Gets the cache directive specifying how the payload of this response may be cached.- Returns:
- The directive or
null
if not set.
-
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.
-