Module io.cloudevents.core
Package io.cloudevents.core.message.impl
Class GenericStructuredMessageReader
java.lang.Object
io.cloudevents.core.message.impl.BaseStructuredMessageReader
io.cloudevents.core.message.impl.GenericStructuredMessageReader
- All Implemented Interfaces:
MessageReader,StructuredMessageReader,io.cloudevents.rw.CloudEventReader
Generic implementation of a structured message.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfrom(io.cloudevents.CloudEvent event, EventFormat format) Create a generic structured message from aCloudEventCreate a generic structured message from aCloudEventfromContentType(String contentType, byte[] payload) Create a generic structured message from a payload<T> Tread(StructuredMessageWriter<T> writer) Read the message as structured encoded message using the provided writerMethods inherited from class io.cloudevents.core.message.impl.BaseStructuredMessageReader
getEncoding, readMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.cloudevents.core.message.MessageReader
read, read, toEvent, toEvent
-
Constructor Details
-
GenericStructuredMessageReader
-
-
Method Details
-
read
public <T> T read(StructuredMessageWriter<T> writer) throws io.cloudevents.rw.CloudEventRWException, IllegalStateException Description copied from interface:MessageReaderRead the message as structured encoded message using the provided writer- Type Parameters:
T- the return type of theStructuredMessageWriter- Parameters:
writer- Structured Message writer- Returns:
- the return value returned by
StructuredMessageWriter.setEvent(EventFormat, byte[]) - Throws:
io.cloudevents.rw.CloudEventRWException- if something went wrong during the visit.IllegalStateException- if the message is not in structured encoding.
-
fromContentType
Create a generic structured message from a payload- Parameters:
contentType- content type to use to resolve theEventFormatpayload- serialized event- Returns:
- null if format was not found, otherwise returns the built message
-
from
@Nullable public static GenericStructuredMessageReader from(io.cloudevents.CloudEvent event, String contentType) Create a generic structured message from aCloudEvent- Parameters:
event-contentType- content type to use to resolve theEventFormat- Returns:
- null if format was not found, otherwise returns the built message
-
from
public static GenericStructuredMessageReader from(io.cloudevents.CloudEvent event, EventFormat format) Create a generic structured message from aCloudEvent- Parameters:
event-format-- Returns:
- returns the built message
-