java.lang.Object
io.cloudevents.core.CloudEventUtils
This class contains a set of utility methods to deal with conversions of
io.cloudevents related interfaces-
Method Summary
Modifier and TypeMethodDescriptionstatic <R extends io.cloudevents.CloudEventData>
RmapData(io.cloudevents.CloudEvent event, io.cloudevents.rw.CloudEventDataMapper<R> mapper) Get the data contained ineventand map it using the provided mapper.static io.cloudevents.rw.CloudEventContextReadertoContextReader(io.cloudevents.CloudEventContext event) Convert aCloudEventto aCloudEventContextReader.static io.cloudevents.CloudEventtoEvent(io.cloudevents.rw.CloudEventReader reader) Convert aCloudEventReaderto aCloudEvent.static io.cloudevents.CloudEventtoEvent(io.cloudevents.rw.CloudEventReader reader, io.cloudevents.rw.CloudEventDataMapper<?> mapper) Convert aCloudEventReaderto aCloudEventmapping the data with the providedmapper.static io.cloudevents.rw.CloudEventReadertoReader(io.cloudevents.CloudEvent event) Convert aCloudEventto aCloudEventReader.
-
Method Details
-
toReader
public static io.cloudevents.rw.CloudEventReader toReader(io.cloudevents.CloudEvent event) Convert aCloudEventto aCloudEventReader. This method provides a default implementation for CloudEvent that doesn't implementCloudEventReader.It's safe to use the returned
CloudEventReadermultiple times.- Parameters:
event- the event to convert- Returns:
- the reader implementation
-
toContextReader
public static io.cloudevents.rw.CloudEventContextReader toContextReader(io.cloudevents.CloudEventContext event) Convert aCloudEventto aCloudEventContextReader. This method provides a default implementation forCloudEventthat doesn't implementCloudEventContextReader.It's safe to use the returned
CloudEventReadermultiple times.- Parameters:
event- the event to convert- Returns:
- the context reader implementation
-
toEvent
public static io.cloudevents.CloudEvent toEvent(io.cloudevents.rw.CloudEventReader reader) throws io.cloudevents.rw.CloudEventRWException Convert aCloudEventReaderto aCloudEvent.- Parameters:
reader- the reader where to read the message from- Returns:
- the reader implementation
- Throws:
io.cloudevents.rw.CloudEventRWException
-
toEvent
public static io.cloudevents.CloudEvent toEvent(io.cloudevents.rw.CloudEventReader reader, io.cloudevents.rw.CloudEventDataMapper<?> mapper) throws io.cloudevents.rw.CloudEventRWException Convert aCloudEventReaderto aCloudEventmapping the data with the providedmapper.- Parameters:
reader- the reader where to read the message frommapper- the mapper to use when reading the data- Returns:
- the reader implementation
- Throws:
io.cloudevents.rw.CloudEventRWException
-
mapData
@Nullable public static <R extends io.cloudevents.CloudEventData> R mapData(io.cloudevents.CloudEvent event, io.cloudevents.rw.CloudEventDataMapper<R> mapper) Get the data contained ineventand map it using the provided mapper.- Type Parameters:
R- the returnedCloudEventDataimplementation from the provided mapper- Parameters:
event- the event eventually containing the datamapper- the mapper to use to map the data- Returns:
- the data contained in
eventand mapped withmapper, if any, otherwise null
-