java.lang.Object
io.cloudevents.core.message.impl.MessageUtils
Collection of utilities useful to implement
MessageReader and MessageWriter related code.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateAttributesToHeadersMapping(Function<String, V> headerNameMapping) Generate a map with cloudevents attributes as keys and header keys as valuesstatic IllegalStateExceptiongenerateWrongEncoding(Encoding expected, Encoding actual) static MessageReaderparseStructuredOrBinaryMessage(Supplier<String> contentTypeHeaderReader, Function<EventFormat, MessageReader> structuredMessageFactory, Supplier<String> specVersionHeaderReader, Function<io.cloudevents.SpecVersion, MessageReader> binaryMessageFactory) Common flow to parse an incoming message that could be structured or binary.
-
Constructor Details
-
MessageUtils
public MessageUtils()
-
-
Method Details
-
parseStructuredOrBinaryMessage
public static MessageReader parseStructuredOrBinaryMessage(Supplier<String> contentTypeHeaderReader, Function<EventFormat, MessageReader> structuredMessageFactory, Supplier<String> specVersionHeaderReader, Function<io.cloudevents.SpecVersion, throws io.cloudevents.rw.CloudEventRWExceptionMessageReader> binaryMessageFactory) Common flow to parse an incoming message that could be structured or binary.- Parameters:
contentTypeHeaderReader- supplier that returns the content type header, if anystructuredMessageFactory- factory to create the structuredMessageReaderfrom the providedEventFormatspecVersionHeaderReader- supplier that returns the spec version header, if anybinaryMessageFactory- factory to create the binaryMessageReaderfrom the providedSpecVersion- Returns:
- the instantiated
MessageReader - Throws:
io.cloudevents.rw.CloudEventRWException- if something goes wrong while resolving theSpecVersionor if the message has unknown encoding
-
generateAttributesToHeadersMapping
public static <V> Map<String,V> generateAttributesToHeadersMapping(Function<String, V> headerNameMapping) Generate a map with cloudevents attributes as keys and header keys as values- Type Parameters:
V- Header key type- Parameters:
headerNameMapping- mapper to generate the header name- Returns:
- the generated mapping
-
generateWrongEncoding
- Parameters:
expected- the expected encodingactual- the actual encoding- Returns:
- a new instance of
IllegalStateException.
-