public class HalResponseBuilderImpl extends AbstractHalResponseBuilder implements HalResponseBuilder
ResponseBuilder that enables
a HAL Representation to be
constructed for the response.
It exposes a similar API to the
HALBuilder Representation
but automates the URI for the "self"
link to be that of the incoming request
(which is probably what you would want).
It also contains the methods for adding
ETag, Last-Modified, Date, Cache-Control
and Expires headers to help with caching
and bandwidth conservation.representationFactory, uri| Constructor and Description |
|---|
HalResponseBuilderImpl(com.theoryinpractise.halbuilder.api.RepresentationFactory representationFactory,
javax.servlet.http.HttpServletRequest request) |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.http.ResponseEntity<com.theoryinpractise.halbuilder.api.Representation> |
build() |
HalResponseBuilderImpl |
convert(Object bean)
Set the underlying
Representation
by converting the supplied Object
into a Representation using the
default conversion mechanism. |
<T> HalResponseBuilderImpl |
convert(T bean,
RepresentationWriter<T> writer)
Set the underlying
Representation
by converting the supplied Object
into a Representation using the
supplied RepresentationWriter
in favour of the default conversion mechanism. |
HalResponseBuilderImpl |
etag()
Create ETag header based
on the best available
ETagStrategy |
HalResponseBuilderImpl |
etag(Date date)
Create a weak ETag based
on the supplied date
|
HalResponseBuilderImpl |
etag(net.eusashead.hateoas.header.ETagHeaderStrategy strategy)
Create ETag header based
on the supplied
ETagStrategy |
HalResponseBuilderImpl |
etag(Integer version)
Create a strong ETag based
on the supplied version
number
|
HalResponseBuilderImpl |
etag(Long version)
Create a strong ETag based
on the supplied version
number
|
HalResponseBuilderImpl |
expireIn(long millis)
Set the the Expires and
Cache-Control headers
based on the supplied
number of milliseconds
|
HalResponseBuilderImpl |
lastModified(Date date)
Set the Last-Modified header
based on the supplied date
|
HalResponseBuilderImpl |
representation(com.theoryinpractise.halbuilder.api.Representation representation)
Set the HAL
Representation
that this response represents |
HalResponseBuilderImpl |
withBean(Object value)
Copy the fields from the supplied
Java Bean as properties of the
wrapped
Representation (entity) |
HalResponseBuilderImpl |
withBeanBasedRepresentation(String rel,
String href,
Object o)
Add the supplied bean as
an embedded
Representation
within the wrapped Representation
with the specified rel and href. |
HalResponseBuilderImpl |
withLink(String rel,
String href)
Add a link to the
wrapped
Representation |
HalResponseBuilderImpl |
withNamespace(String namespace,
String href)
Add a namespace to the
wrapped
Representation |
HalResponseBuilderImpl |
withProperty(String name,
Object value)
Add the supplied property
to the wrapped
Representation |
HalResponseBuilderImpl |
withRepresentation(String rel,
com.theoryinpractise.halbuilder.api.ReadableRepresentation resource)
Add the supplied
Representation
to the wrapped Representation
as an embedded resource. |
assertVerbassertEntity, buildResponseEntity, setEntity, setEtagHeader, setEtagHeaderaddHeader, addHeader, compareEtagWithIfNoneMatch, getRequest, setEtagHeader, setEtagHeader, setEtagHeader, setExpiryHeaders, setLastModifiedHeaderpublic HalResponseBuilderImpl(com.theoryinpractise.halbuilder.api.RepresentationFactory representationFactory,
javax.servlet.http.HttpServletRequest request)
public HalResponseBuilderImpl withProperty(String name, Object value)
HalResponseBuilderRepresentationwithProperty in interface HalResponseBuilderHalResponseBuilderpublic HalResponseBuilderImpl withRepresentation(String rel, com.theoryinpractise.halbuilder.api.ReadableRepresentation resource)
HalResponseBuilderRepresentation
to the wrapped Representation
as an embedded resource.withRepresentation in interface HalResponseBuilderHalResponseBuilderpublic HalResponseBuilderImpl withLink(String rel, String href)
HalResponseBuilderRepresentationwithLink in interface HalResponseBuilderHalResponseBuilderpublic HalResponseBuilderImpl withNamespace(String namespace, String href)
HalResponseBuilderRepresentationwithNamespace in interface HalResponseBuilderHalResponseBuilderpublic HalResponseBuilderImpl withBean(Object value)
HalResponseBuilderRepresentation (entity)withBean in interface HalResponseBuilderHalResponseBuilderpublic HalResponseBuilderImpl withBeanBasedRepresentation(String rel, String href, Object o)
HalResponseBuilderRepresentation
within the wrapped Representation
with the specified rel and href.withBeanBasedRepresentation in interface HalResponseBuilderrel - the name of the embedded representationhref - the URI of the representationo - the Java Bean object to create the representation fromHalResponseBuilderpublic HalResponseBuilderImpl representation(com.theoryinpractise.halbuilder.api.Representation representation)
HalResponseBuilderRepresentation
that this response representsrepresentation in interface HalResponseBuilderHalResponseBuilderpublic HalResponseBuilderImpl convert(Object bean)
HalResponseBuilderRepresentation
by converting the supplied Object
into a Representation using the
default conversion mechanism.convert in interface HalResponseBuilderbean - the Object to convertHalResponseBuilderpublic <T> HalResponseBuilderImpl convert(T bean, RepresentationWriter<T> writer)
HalResponseBuilderRepresentation
by converting the supplied Object
into a Representation using the
supplied RepresentationWriter
in favour of the default conversion mechanism.convert in interface HalResponseBuilderbean - the Object to convertwriter - the RepresentationWriter to perform the conversionHalResponseBuilderpublic HalResponseBuilderImpl etag()
HalResponseBuilderETagStrategyetag in interface HalResponseBuilderHalResponseBuilderpublic HalResponseBuilderImpl etag(net.eusashead.hateoas.header.ETagHeaderStrategy strategy)
HalResponseBuilderETagStrategyetag in interface HalResponseBuilderHalResponseBuilderpublic HalResponseBuilderImpl etag(Date date)
HalResponseBuilderetag in interface HalResponseBuilderdate - Date of last modificationHalResponseBuilderpublic HalResponseBuilderImpl etag(Integer version)
HalResponseBuilderetag in interface HalResponseBuilderversion - Integer version numberHalResponseBuilderpublic HalResponseBuilderImpl etag(Long version)
HalResponseBuilderetag in interface HalResponseBuilderversion - Long version numberHalResponseBuilderpublic HalResponseBuilderImpl lastModified(Date date)
HalResponseBuilderlastModified in interface HalResponseBuilderdate - Date of last modificationHalResponseBuilderpublic HalResponseBuilderImpl expireIn(long millis)
HalResponseBuilderexpireIn in interface HalResponseBuilderHalResponseBuilderpublic org.springframework.http.ResponseEntity<com.theoryinpractise.halbuilder.api.Representation> build()
build in interface net.eusashead.hateoas.response.ResponseBuilder<com.theoryinpractise.halbuilder.api.Representation>Copyright © 2013. All Rights Reserved.