public interface ResponseBuilder
Protocol
via the ResponseBuilderProvider.getResponseBuilder()
method and will be supplied to the user
for additional configuration via a Consumer
which accepts a ResponseBuilder
as input.
The expectation is that the protocol will supply whatever other builder methods are necessary for allowing the user to configure their response as they desire. This would include things like allowing the user to specify the body of the response, any response status codes, metadata to include, etc.
While writing a ResponseBuilder
for a protocol, it may be helpful to use the GenericResponseBuilder
internally to ensure proper construction of the Response
object.
It is important to note that the build()
method may not reset or alter the state of
the builder. It must be possible to call the build()
method multiple times in a row and
get equivalent (but different) objects. The GenericResponseBuilder
honors this rule.
Modifier and Type | Method and Description |
---|---|
Response |
build()
This method is primarily intended to be called by the framework to produce the
Response
object which will be used during playback. |
Response build()
Response
object which will be used during playback. However, no harm will result from calling it
elsewhere.
It is important to note that this method may not reset or alter the state of the builder. It must be possible to call this method multiple times in a row and get equivalent (but different) objects.