Package org.forgerock.json.resource
Interface ResourceResponse
- All Superinterfaces:
Response
A resource, comprising of a resource ID, a revision (etag), and its JSON
content.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name of the field which contains the resource content in the JSON representation.static final String
The name of the field in the resource content which contains the resource ID.static final String
The name of the field in the resource content which contains the resource revision.static final String
The name of the field which contains the resource ID in the JSON representation.static final String
The name of the field which contains the resource version in the JSON representation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addField
(JsonPointer... fields) Adds a field to the list of fields which should be included in this JSON resource after field filtering has occurred.Return this response as a result Promise.boolean
Returnstrue
if the provided object is a resource having the same resource ID and revision as this resource.Returns the JSON content of this resource.Returns the list of fields which should be included in this JSON resource after field filtering has occurred.getId()
Returns the ID of this resource, if applicable.Returns the revision of this resource, if known.boolean
Returns true if any fields have been added, indicating that the list of fields in this response should be included in this JSON resource after field filtering has occurred, otherwise returns false indicating that the original list of fields in the request should be used for filtering the response.int
hashCode()
Returns the hash code for this resource.default ResourceResponse
setCacheControl
(ResponseCacheControl cacheControl) Sets the cache control for this response.Methods inherited from interface org.forgerock.json.resource.Response
getCacheControl, getResourceApiVersion, setResourceApiVersion
-
Field Details
-
FIELD_ID
The name of the field which contains the resource ID in the JSON representation.Note: when encoding the resource ID as part of a resource's content the field name
FIELD_CONTENT_ID
should be used.- See Also:
-
FIELD_REVISION
The name of the field which contains the resource version in the JSON representation.Note: when encoding the resource revision as part of a resource's content the field name
FIELD_CONTENT_REVISION
should be used.- See Also:
-
FIELD_CONTENT_ID
The name of the field in the resource content which contains the resource ID. This field is semantically equivalent toFIELD_ID
and is intended for use in cases where a commons REST API wishes to expose the resource ID as part of the resource content.- See Also:
-
FIELD_CONTENT_REVISION
The name of the field in the resource content which contains the resource revision. This field is semantically equivalent toFIELD_REVISION
and is intended for use in cases where a commons REST API wishes to expose the resource revision as part of the resource content.- See Also:
-
FIELD_CONTENT
The name of the field which contains the resource content in the JSON representation.- See Also:
-
-
Method Details
-
getContent
JsonValue getContent()Returns the JSON content of this resource.- Returns:
- The JSON content of this resource.
-
getId
String getId()Returns the ID of this resource, if applicable.- Returns:
- The ID of this resource, or
null
if this resource does not have an ID.
-
getRevision
String getRevision()Returns the revision of this resource, if known.- Returns:
- The revision of this resource, or
null
if the version is not known.
-
getFields
List<JsonPointer> getFields()Returns the list of fields which should be included in this JSON resource after field filtering has occurred. This list will override the list of fields that is included in the request. An empty list indicates that the original list of fields in the request should be used for filtering the response.- Returns:
- The list of fields which should be included in this JSON resource after field filtering has occurred.
-
hasFields
boolean hasFields()Returns true if any fields have been added, indicating that the list of fields in this response should be included in this JSON resource after field filtering has occurred, otherwise returns false indicating that the original list of fields in the request should be used for filtering the response.- Returns:
- true if any fields have been added, false otherwise.
-
addField
Adds a field to the list of fields which should be included in this JSON resource after field filtering has occurred. This list will override the list of fields that is included in the request.- Parameters:
fields
- aJsonPointer
representing the field to add.
-
asPromise
Promise<ResourceResponse,ResourceException> asPromise()Return this response as a result Promise.- Returns:
- A Promise whose result is this ResourceResponse object.
-
setCacheControl
Sets the cache control for this response.- Parameters:
cacheControl
- the cache controls to apply to this response.- Returns:
- this resource response.
-
equals
Returnstrue
if the provided object is a resource having the same resource ID and revision as this resource. -
hashCode
int hashCode()Returns the hash code for this resource. Two resources are guaranteed to have the same hash code if they share the same resource ID and revision.
-