Class BaseCloudEventMetadata<T>
- java.lang.Object
-
- io.smallrye.reactive.messaging.ce.impl.BaseCloudEventMetadata<T>
-
- Type Parameters:
T
- the type of data
- All Implemented Interfaces:
CloudEventMetadata<T>
- Direct Known Subclasses:
DefaultIncomingCloudEventMetadata
,DefaultOutgoingCloudEventMetadata
public class BaseCloudEventMetadata<T> extends Object implements CloudEventMetadata<T>
Default implementation of theCloudEventMetadata
interface
-
-
Field Summary
Fields Modifier and Type Field Description protected T
data
protected String
dataContentType
protected URI
dataSchema
protected Map<String,Object>
extensions
protected String
id
protected URI
source
protected String
specVersion
protected String
subject
protected ZonedDateTime
timestamp
protected String
type
-
Fields inherited from interface io.smallrye.reactive.messaging.ce.CloudEventMetadata
CE_ATTRIBUTE_DATA_CONTENT_TYPE, CE_ATTRIBUTE_DATA_SCHEMA, CE_ATTRIBUTE_ID, CE_ATTRIBUTE_SOURCE, CE_ATTRIBUTE_SPEC_VERSION, CE_ATTRIBUTE_SUBJECT, CE_ATTRIBUTE_TIME, CE_ATTRIBUTE_TYPE, CE_VERSION_1_0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
getData()
The event payload.Optional<String>
getDataContentType()
Content type of data value.Optional<URI>
getDataSchema()
Identifies the schema that data adheres to.<A> Optional<A>
getExtension(String name)
A CloudEvent may include any number of additional context attributes with distinct names, known as "extension attributes".Map<String,Object>
getExtensions()
A CloudEvent may include any number of additional context attributes with distinct names, known as "extension attributes".String
getId()
Identifies the event.URI
getSource()
Identifies the context in which an event happened.String
getSpecVersion()
The version of the CloudEvents specification which the event uses.Optional<String>
getSubject()
This describes the subject of the event in the context of the event producer (identified by source).Optional<ZonedDateTime>
getTimeStamp()
Timestamp of when the occurrence happened.String
getType()
This attribute contains a value describing the type of event related to the originating occurrence.void
validate()
-
-
-
Field Detail
-
id
protected final String id
-
specVersion
protected final String specVersion
-
source
protected final URI source
-
type
protected final String type
-
dataContentType
protected final String dataContentType
-
dataSchema
protected final URI dataSchema
-
subject
protected final String subject
-
timestamp
protected final ZonedDateTime timestamp
-
data
protected final T data
-
-
Method Detail
-
validate
public void validate()
-
getId
public String getId()
Description copied from interface:CloudEventMetadata
Identifies the event. Mandatory attribute.- Specified by:
getId
in interfaceCloudEventMetadata<T>
- Returns:
- the id, cannot be
null
-
getSource
public URI getSource()
Description copied from interface:CloudEventMetadata
Identifies the context in which an event happened. Mandatory attribute.- Specified by:
getSource
in interfaceCloudEventMetadata<T>
- Returns:
- the source, cannot be
null
-
getSpecVersion
public String getSpecVersion()
Description copied from interface:CloudEventMetadata
The version of the CloudEvents specification which the event uses. Mandatory attribute.- Specified by:
getSpecVersion
in interfaceCloudEventMetadata<T>
- Returns:
- the specification version
-
getType
public String getType()
Description copied from interface:CloudEventMetadata
This attribute contains a value describing the type of event related to the originating occurrence. Mandatory attribute.- Specified by:
getType
in interfaceCloudEventMetadata<T>
- Returns:
- the type
-
getDataContentType
public Optional<String> getDataContentType()
Description copied from interface:CloudEventMetadata
Content type of data value.- Specified by:
getDataContentType
in interfaceCloudEventMetadata<T>
- Returns:
- the content type if any, empty if none.
-
getDataSchema
public Optional<URI> getDataSchema()
Description copied from interface:CloudEventMetadata
Identifies the schema that data adheres to.- Specified by:
getDataSchema
in interfaceCloudEventMetadata<T>
- Returns:
- the schema URI if any, empty if none.
-
getSubject
public Optional<String> getSubject()
Description copied from interface:CloudEventMetadata
This describes the subject of the event in the context of the event producer (identified by source).- Specified by:
getSubject
in interfaceCloudEventMetadata<T>
- Returns:
- the subject if any, empty if none
-
getTimeStamp
public Optional<ZonedDateTime> getTimeStamp()
Description copied from interface:CloudEventMetadata
Timestamp of when the occurrence happened.- Specified by:
getTimeStamp
in interfaceCloudEventMetadata<T>
- Returns:
- the timestamp if any, empty if none
-
getExtension
public <A> Optional<A> getExtension(String name)
Description copied from interface:CloudEventMetadata
A CloudEvent may include any number of additional context attributes with distinct names, known as "extension attributes". This method allows retrieving these attributes.- Specified by:
getExtension
in interfaceCloudEventMetadata<T>
- Parameters:
name
- the name of the attribute, must not benull
- Returns:
- the value of the attribute, empty if not present.
-
getExtensions
public Map<String,Object> getExtensions()
Description copied from interface:CloudEventMetadata
A CloudEvent may include any number of additional context attributes with distinct names, known as "extension attributes". This method allows retrieving these attributes.- Specified by:
getExtensions
in interfaceCloudEventMetadata<T>
- Returns:
- the map of extension attributes, potentially empty.
-
getData
public T getData()
Description copied from interface:CloudEventMetadata
The event payload. It is the owner message payload.- Specified by:
getData
in interfaceCloudEventMetadata<T>
- Returns:
- the payload, can be
null
-
-