Package com.opencqrs.esdb.client.jackson
Class JacksonMarshaller
java.lang.Object
com.opencqrs.esdb.client.jackson.JacksonMarshaller
- All Implemented Interfaces:
Marshaller
ObjectMapper
based Marshaller
implementation.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.opencqrs.esdb.client.Marshaller
Marshaller.QueryResponseElement, Marshaller.ResponseElement
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfromHealthResponse
(String response) Used byEsdbClient.health()
to transform the HTTP response body to aHealth
.fromJsonResponse
(String response) Used byEsdbClient
operations to transform any generic HTTP JSON response.fromQueryResponseLine
(String line) Used byEsdbClient
to transform an ND-JSON line from the HTTP response stream to aMarshaller.QueryResponseElement
.Used byEsdbClient
to transform an ND-JSON line from the HTTP response stream to aMarshaller.ResponseElement
.fromWriteEventsResponse
(String response) Used byEsdbClient.write(List, List)
to transform the HTTP response body to a list ofEvent
s.toQueryRequest
(String query) Used byEsdbClient
to transform the given parameters into a valid HTTP request body to be sent to the event store for query operations.toReadOrObserveEventsRequest
(String subject, Set<Option> options) Used byEsdbClient
to transform the given parameters into a valid HTTP request body toe be sent to the event store for read or observe operations.toWriteEventsRequest
(List<EventCandidate> eventCandidates, List<Precondition> preconditions) Used byEsdbClient.write(List, List)
to transform the givenEventCandidate
s andPrecondition
s to a valid HTTP request body to be sent to the event store.
-
Constructor Details
-
JacksonMarshaller
public JacksonMarshaller(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
fromJsonResponse
Description copied from interface:Marshaller
Used byEsdbClient
operations to transform any generic HTTP JSON response.- Specified by:
fromJsonResponse
in interfaceMarshaller
- Parameters:
response
- the JSON HTTP response body as string- Returns:
- a map representing the JSON response content
-
fromHealthResponse
Description copied from interface:Marshaller
Used byEsdbClient.health()
to transform the HTTP response body to aHealth
.- Specified by:
fromHealthResponse
in interfaceMarshaller
- Parameters:
response
- the JSON HTTP response body as string- Returns:
- the
Health
-
toWriteEventsRequest
public String toWriteEventsRequest(List<EventCandidate> eventCandidates, List<Precondition> preconditions) Description copied from interface:Marshaller
Used byEsdbClient.write(List, List)
to transform the givenEventCandidate
s andPrecondition
s to a valid HTTP request body to be sent to the event store.- Specified by:
toWriteEventsRequest
in interfaceMarshaller
- Parameters:
eventCandidates
- the list of event candidates to include within the request bodypreconditions
- the preconditions to include within the request body- Returns:
- the JSON HTTP request body as string
-
fromWriteEventsResponse
Description copied from interface:Marshaller
Used byEsdbClient.write(List, List)
to transform the HTTP response body to a list ofEvent
s.- Specified by:
fromWriteEventsResponse
in interfaceMarshaller
- Parameters:
response
- the JSON HTTP response body as string- Returns:
- the list of unmarshalled
Event
s
-
toReadOrObserveEventsRequest
Description copied from interface:Marshaller
Used byEsdbClient
to transform the given parameters into a valid HTTP request body toe be sent to the event store for read or observe operations.- Specified by:
toReadOrObserveEventsRequest
in interfaceMarshaller
- Parameters:
subject
- the subject to include within the request bodyoptions
- the options to include within the request body- Returns:
- the JSON HTTP request body as string
- See Also:
-
fromReadOrObserveResponseLine
Description copied from interface:Marshaller
Used byEsdbClient
to transform an ND-JSON line from the HTTP response stream to aMarshaller.ResponseElement
.- Specified by:
fromReadOrObserveResponseLine
in interfaceMarshaller
- Parameters:
line
- the ND-JSON element as string- Returns:
- an unmarshalled
Marshaller.ResponseElement
-
toQueryRequest
Description copied from interface:Marshaller
Used byEsdbClient
to transform the given parameters into a valid HTTP request body to be sent to the event store for query operations.- Specified by:
toQueryRequest
in interfaceMarshaller
- Parameters:
query
- the query- Returns:
- the JSON HTTP request body as string
- See Also:
-
fromQueryResponseLine
Description copied from interface:Marshaller
Used byEsdbClient
to transform an ND-JSON line from the HTTP response stream to aMarshaller.QueryResponseElement
.- Specified by:
fromQueryResponseLine
in interfaceMarshaller
- Parameters:
line
- the ND-JSON element as string- Returns:
- an unmarshalled
Marshaller.QueryResponseElement
-